Each chunk is passed through the embedding model and stored as a vector.
That vector is what retrieval searches, so it must represent the chunk fairly.
The original text is stored alongside, since the vector cannot be read back into words.
A chunk taken out of its document loses the context that framed it.
Prepending the document title and section heading restores much of that.
It costs a few tokens and reliably improves recall.
Contextual retrieval goes further, adding a generated sentence explaining where the chunk sits.
Watch the model's input limit, since anything over it is silently truncated.
A chunk of 2,000 tokens sent to a 512-token model is mostly discarded without warning.
Embedding is a batch job and providers charge per token, so a large corpus has a real cost.
It is cheap compared with generation and expensive enough to notice at millions of documents.
Cache by content hash so unchanged chunks are never re-embedded.
Queries must use the same model as the documents, without exception.
Some models want an instruction prefix, differing for queries and documents.
Changing the model means re-embedding everything, so treat the choice as a migration.