Retrieval pipeline
Embed a query, rank documents and select context using a small vector model.
Retrieval pipeline
Embed a query, rank documents and select context using a small vector model.
- Query ready
- Vectors compared
- Candidates ranked
- Context selected
Query: How does KV caching work? · vector [1, 0]
Manually assigned two-dimensional vectors illustrate ranking. No embedding service or language model runs in this demo.
Change the experiment
q = embed(query)
ranked = sort_by_cosine(q, documents)
context = ranked[:top_k]
# Pass context to a separate generatorTry it yourself
Switch the query and compare top-k values. Explain why adding more documents can introduce irrelevant context.
Query ready. Advance to inspect the next stage.
Vector similarity ranks candidates, but it does not prove relevance or factual correctness. Evaluate retrieval on your own queries.
Playback pauses in hidden tabs and offscreen. With reduced motion enabled, use the timeline or Next step.Turn the idea into an implementation
Switch the query and compare top-k values. Explain why adding more documents can introduce irrelevant context.
Predict a result, change one input, then explain what happened. Use the timeline to revisit a state and compare it with the algorithm sketch.
Explain it in an interview
Vector similarity ranks candidates, but it does not prove relevance or factual correctness. Evaluate retrieval on your own queries.
Describe the inputs, the state that changes, the computational cost and a limitation of the model before discussing a production implementation.