RAG & Vector Lab

Eight interactive labs: text chunking, embeddings, semantic search, vector databases, the RAG pipeline, advanced retrieval, chat with your documents and evaluation, plus an assistant builder for your own documents and experiments that run in the browser.

44interactive experiments

Approximate nearest-neighbour search

← Back to Vector Databases Lab

Level 1: idea and analogy

Idea

Exhaustive comparison (Flat) is exact but slows as data grows. ANN indexes give up some accuracy (recall) in return for more speed and less memory.

Analogy

Instead of asking every resident of the city, you ask the one or two nearest neighbourhoods.

Level 2: how it works and when to use it

Steps

1. Build the index.

2. Query with an approximate index and with Flat.

3. Compute recall by comparing the two.

4. Pick the setting that reaches the required recall at the lowest cost.

When to use

When the number of vectors exceeds what can be scanned in acceptable time.

Strengths

Raises throughput a lot at large sizes.

Level 3: mathematics, assumptions, limits

Assumptions

The vectors are distributed in a way that allows clustering or a neighbourhood graph.

Limits

It may miss a true neighbour. The browser numbers here use synthetic data at small scale and are not comparable to real products.

Level 4: pitfalls and references for researchers

Common pitfalls

Judging an index by speed alone without recall.

References