Dive into Deep Learning · §19
Encoders, Embeddings and Retrieval
word vectors · pretrained encoders · text embeddings · sparse, dense and approximate retrieval · retrieval-augmented generation
The problem
| request | a prompted decoder |
|---|---|
how does the book’s load_array decide whether to shuffle? |
without the book, Qwen3.5-9B invents a shuffle argument; the answer is one paragraph among 5,324 passages |
| label 10,000 support messages an hour | re-reads its 8 solved examples for every item: about 1,500 tokens per item, against 40 for a fine-tuned encoder |
Both jobs need vectors that put related texts close together: one per passage to search, one per token for a small labeling head.
Goals
Running example: this book, 5,324 passages, and 220 questions with known sources, drafted and checked by models; the load_array question travels through the decks.
Idea: turn text into vectors that place related texts close together, then find the close ones fast.
Chapter map
| movement | section | question |
|---|---|---|
| vectors | Word Embeddings | which statistic does a word vector factorize? |
| Pretrained Encoders | when does a fine-tuned encoder beat a prompt? | |
| Text Embeddings from Contrastive Training | why do pooled states retrieve poorly until trained? | |
| finding | Sparse, Dense and Approximate Retrieval | what floor must vectors beat, and what does an index trade for speed? |
| using what is found | Retrieval-Augmented Generation | how is each stage of the system measured? |
| Failures and Fixes in RAG | which stage lost each wrong answer, and does a fix chosen in advance help? |