Basic

Checking a retrieval system

A retrieval system is a program with a quality you can measure. Take real questions, write the passage that should answer each, and run the search. The list of questions that missed is the honest state of the system.

What you will see

A count out of the total. 2 2 is ready; 1 2 is a system with a known bug to fix.

About 1 min of reading

Try It

Score a tiny system.

1

The test set

cases = [('refund policy', 'Damaged items get a full refund within 30 days.'), ('shipping time', 'We ship within two business days.')] print(len(cases))

Before you run it, say out loud what it will print. Then open the answer.

What it prints
2 cases, each with the passage that must be retrieved.
2

The check

hits = sum(1 for q, want in cases if want in retrieved(q)) print(hits, len(cases))

Before you run it, say out loud what it will print. Then open the answer.

What it prints
A count out of the total. 2 2 is ready; 1 2 is a system with a known bug to fix.

Data Flow

Questions and expected passages score the system.
1 Collect real questions
↓
2 Write the expected passage for each
↓
3 Run the search
↓
4 Report the miss rate
Line by line

Read the first example one line at a time. A line that prints shows what appears on screen; the rest set things up quietly.

cases = [('refund policy', 'Damaged items get a full refund within 30 days.'), ('shipping time', 'We ship within two business days.')] sets nothing on screen
print(len(cases)) 2 cases, each with the passage that must be retrieved.
Why this works
Write the expected passage

A test needs a right answer. Naming the passage that should be retrieved turns a vague worry into a check, and it is the step that finds a missing document before a user does.

Re-run after every change

Chunk size, model, and k all change the score. Re-running the test set after each change is what keeps an improvement real rather than a shuffle that happened to look better.

Examples

A test set of questions

Twenty questions from real users, each with the passage that answers it. Run the search and check the right passage is in the top few. That is a test suite, and it is the only way quality is measured.

Recall at k

How often the right passage is in the top k. That number, not a feeling about the answers, is what decides whether the system is ready, and it is the number a team can argue about.

Fix the misses, not the hits

Read the questions that missed and find what they have in common: a code, a phrasing, a missing document. Each pattern is a fix, and fixing hits changes nothing.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Citing what was used
Previous Lesson
Citing what was used
Next Lesson
Storing vectors so search is fast
Storing vectors so search is fast →