The problem
A large language model (LLM) learned from public text up to a cutoff date. It never read this shop's rules, so for "Can I return an item after 20 days?" it can only guess. A fluent answer with no source is a hallucination.
Retrieval-augmented generation (RAG) adds a lookup step. Retrieve: find the few passages of your own documents that match the question. Augment: paste them into the prompt. Generate: the model answers from them. No retraining needed.
Indexing
First the documents are split into chunks: short passages that can be found and pasted on their own. Ours are four one-line chunks. The original RAG paper split Wikipedia into 21 million chunks of 100 words.
An embedding model turns each chunk into a vector, a list of numbers, so that texts about the same thing get similar vectors. Ours counts topic words, giving four numbers. Real ones are trained networks giving hundreds, such as 384.
Answering
When a question comes in, the same embedding model turns it into a vector too. "return" and "days" give [1, 1, 0, 0]. It must be the same model, or the two kinds of vector could not be compared.
Search scores every chunk by cosine similarity with the question: 1 means the vectors point the same way, 0 means no topic in common. Refunds scores 0.89, shipping 0.71, the other two 0. We keep the top k = 2.
Augment: the two retrieved chunks and the question are pasted into one prompt, with an instruction to answer only from that context. The model itself does not change at all; only what it reads does.
The LLM reads the prompt and answers from it: yes, returns are accepted within 30 days, so 20 days is fine. It can name its source, the refunds chunk. The shipping chunk was retrieved too, but it is not needed.
If the refund rule changes, edit that chunk and embed it again; the next answer follows. No retraining. The weak spot is search: if it fetches the wrong chunks, the model answers from the wrong facts.
What happens
;; step 1/9 · direct question Can I return an item after 20 days? the LLM knows only what was in its training text: public pages, up to a cutoff date not this shop's policy, not last week's changes answer "Most shops allow 14 days. Maybe?" (a guess)
The embedding here is a toy: four numbers, each counting words that start with a topic stem. Real embedding models are trained neural networks; all-MiniLM-L6-v2, for example, gives 384 numbers, and no single number means one named topic. The answers in the figure are illustrations of what a model typically does, not the output of a real model.