Beginner project
Semantic search over your own notes
Builds on 2 lessonsabout 1 h of reading first
In this project
What you need first
- Completed:Embeddings and similarity searchEmbeddings and vector search
- Completed:Vector databasesEmbeddings and vector search
Skills you will practise
- Embeddings
- Vector search
Problem
Search your own notes by meaning, and find out how much an approximate index costs you. You index 200 or more of your own text notes, search them with embeddings, compare brute force with an ANN index, add a metadata filter, and handle a note that you edit later.
Requirements
- At least 200 text notes that you wrote or own (no private data from other people). If you do not have 200, use openly licensed text and record its license. Each has an ID and metadata such as a tag or a year.
- One embedding model, used for both notes and queries. Record its name and version with the index.
- Brute-force search that returns the exact top 10 for a query. Use it as the ground truth. Reuse the recall harness (exact top-10 against ANN) from the Homework of Vector databases; the new work here is the filter, the edit, the failure analysis and the whole pipeline.
- An ANN index (HNSW or IVF, from a library such as FAISS or from Postgres with pgvector) with settings you can change.
- A set of at least 30 queries you write, with the note you expect to find for each. The expected note measures the hit rate of the whole search. It is separate from ANN recall, which compares the index with brute force.
- A metadata filter, for example “tag = work”, and a check that filtered results are correct.
- A re-index step that handles an edited note: the old vector is replaced, not left behind, using a deterministic ID.
- Report recall@10 of the ANN index against brute force at a few values of one knob (
ef_searchornprobe), with time per query, reusing your harness. At about 200 notes a flat curve (recall near 1.0) is a valid finding; say so rather than inventing a trade-off. To see a difference, try IVF starting atnprobe = 1, and keepef_searchat or above k, because anef_searchbelow k limits how many rows come back, which is not the same as worse search. - Acceptance: after you edit a note and re-index, exactly one vector exists for that note ID, and the text and metadata returned for it are the new version.
Prerequisites
Tasks
- To do: Collect 200 or more notes with IDs and metadata.
- To do: Embed them with one model and store the model name with the index.
- To do: Implement brute-force search.
- To do: Build the ANN index and run the 30 queries through both, using your recall harness from Vector databases.
- To do: Report hit rate of the expected note, recall@10 against brute force and time per query, at a few knob values. Say if the curve is flat.
- To do: Add the metadata filter and test queries where the filter matches few notes. Check whether you get fewer than 10 results.
- To do: Edit one note and re-index it. Show that exactly one vector exists for its ID and that the stored text and metadata are the new version.
- To do: Find one query that fails, say why (see the failure list), and name a fix.
- To do: Draw the data flow in the Architecture part and mark where staleness enters.
- To do: Stretch: combine keyword search and vector search, and compare on your failing query.
Evaluation
Record real measurements and never invent numbers. With 200 notes, brute force may be fast enough on its own; say so if the measurements show it.
| Criterion | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| Recall and hit rate | Not measured | Measured on a few queries | Hit rate and recall@10 against brute force on 30 queries | As level 2, with latency at a few knob values and a chosen setting (a flat curve is stated, not hidden) |
| Filter | Missing | Works on easy cases | Correct, including a rare value | Correct, and the effect on result count and recall is measured |
| Edit handling | Old vector remains | Rebuild everything | Replace by deterministic ID | Replace by ID, with a store-level check (one vector per ID, new text and metadata) |
| Failure analysis | None | One failing query shown | Failing query explained | Explained, with a fix tried and re-measured |
Pass mark: at least 2 on every criterion, so 8 out of 12 with no criterion below 2.
Architecture
| Decision | Alternative rejected | Why |
|---|---|---|
| Brute force as ground truth | Trust the ANN index | You can only call the index good by comparing it with the exact answer. |
| Deterministic note IDs | Append a new vector on every edit | Appending leaves a stale copy that can still be returned. |
Interview questions
Provenance: Generated practice. Not reported from any company.
- Explain HNSW. Is ANN exact, and how do you know your index is good enough? Practise with I4 in the Intermediate bank.
- A document was updated but search still returns the old version. Where do you look first? Practise with S5 in the Scenario-based bank.
- Why does a query for an error code return on-topic but wrong notes? Practise with F8 in the Fundamentals bank.
Portfolio checklist
- To do: The README shows the recall and latency table and the chosen setting.
- To do: The embedding model name and version are recorded with the index.
- To do: The edit test and the failing query are documented.
- To do: No private data of other people is in the repository.