Beginner project

Semantic search over your own notes

Builds on 2 lessonsabout 1 h of reading first

In this project

What you need first

Skills you will practise

  • Embeddings
  • Vector search
Skip to the tasks

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_search or nprobe), 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 at nprobe = 1, and keep ef_search at or above k, because an ef_search below 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.

Criterion0123
Recall and hit rateNot measuredMeasured on a few queriesHit rate and recall@10 against brute force on 30 queriesAs level 2, with latency at a few knob values and a chosen setting (a flat curve is stated, not hidden)
FilterMissingWorks on easy casesCorrect, including a rare valueCorrect, and the effect on result count and recall is measured
Edit handlingOld vector remainsRebuild everythingReplace by deterministic IDReplace by ID, with a store-level check (one vector per ID, new text and metadata)
Failure analysisNoneOne failing query shownFailing query explainedExplained, 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

Diagram: Notes and queries go through the same embedding model into the index, then a metadata filter (applied after the search, as in this sketch;...

changes text, not the vector

Notes

Embedding model

ANN index and brute-force store

Query

Same embedding model

Metadata filter

Ranked results

Edited note

Re-embed and replace by ID

Diagram summary: Notes and queries go through the same embedding model into the index, then a metadata filter (applied after the search, as in this sketch; the lesson also names engines that filter during the search), then ranked results. Staleness enters when a note is edited: the text changes but the stored vector does not until the re-embed step replaces it by ID. The same gap opens if you change the embedding model without re-embedding.
DecisionAlternative rejectedWhy
Brute force as ground truthTrust the ANN indexYou can only call the index good by comparing it with the exact answer.
Deterministic note IDsAppend a new vector on every editAppending 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.