Check a few questions

Four questions

Before you trust an answer, check that each question finds the right section. Two of these questions are not in the note.

Each question prints, then the matching line, or Not in the note. This page does not ask the model. It checks the search.

Example

from praisonai.knowledge import KeywordIndex

lines = [
    "Apples grow on trees in the orchard.",
    "The secret colour of the boat is blue.",
    "Tickets for the ferry cost four pounds.",
]
index = KeywordIndex()
index.add_documents(lines)
questions = [
    "What colour is the boat?",
    "How much is the ferry?",
    "Where do apples grow?",
    "Who wrote the handbook?",
]
for question in questions:
    print(question)
    words = [word.strip("?.!,").lower() for word in question.split() if len(word) > 3]
    hit = index.query(question, top_k=1)[0]
    if any(word in hit["text"].lower() for word in words):
        print(hit["text"])
    else:
        print("Not in the note.")
    print()

Try it Yourself

Example explained

  • for question — The same check, once per question.

Build a balanced 3-bucket RAG test set

Every reliable RAG evaluation checks three buckets: (1) direct facts clearly present in the note, (2) trick questions sharing a keyword with the wrong section, and (3) completely out-of-scope questions that must return a refusal.

Common pitfall: only testing easy questions copied verbatim from the first paragraph hides retrieval bugs until users hit them.

Reference: documentation