Data & storage / 5 / 15
Vector search
An online store's help centre has 2 million article chunks, and customers ask in their own words: "can I get my money back for a broken kettle". Keyword search misses the answer when it uses other words. We add embeddings and cosine similarity, see why exact kNN is too slow, trade a little recall for milliseconds with HNSW, shrink memory with int8, handle filters, combine BM25 and vectors with reciprocal rank fusion, and feed the result to an LLM.
- 14 min
- Advanced
- 11 steps
- Recall@10 (golden set)
- 41 %
- Search p95
- 12 ms
- Index memory
- —
- Empty results
- 0 %
- request
- reply
- redelivery
- duplicate
- lost
- call: the reply returns on the same line
Numbers are a model scenario, not measurements
The real request
Search API → Keyword indexRequest
q = "singan choynak uchun pulimni qaytarib olsam bo'ladimi"
BM25 top 312
1 "Choynak tanlash: 5 maslahat" 7.9
2 "Elektr choynakni tozalash" 7.1
3 "Singan ekran: ustaxona manzillari" 5.4
-- the answer is "Mablag'ni qaytarish: 14 kun ichida": no shared word3
BM25— Keyword ranking: it can only score words the text actually contains.top 3— What the chat shows. All three are about kettles, none about refunds.no shared word— "pulimni" and "mablag'ni" mean the same money; for an index they are unrelated tokens.
Build it yourselfCheat sheetCompare lessons
Course: 74 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes
11 Case studies