Retrieval: how an assistant looks things up

Explain to a colleague how retrieval and web search put fresh information into the context window, and check whether each cited source says what an answer claims.

Mei Ling is an admin manager at a small design firm. She asks a search-enabled assistant about the notice period for ending a staff member's contract. The reply is clear, and some of its sentences have small numbered markers after them.

Clicking a marker opens a source page. It might be a Ministry of Manpower page, a law firm's blog, or sometimes an old forum thread. The model behind the answer was trained long before some of those pages were written, so its training can't be where it learned them. Lesson 5.1 showed that a model can only use what is in its context window. The other half of the story is how fresh text gets into that window, and the method that does it is called retrieval.

How retrieval puts pages in front of the model

Retrieval is a separate search step that runs before the model writes anything. You ask your question. The search step takes it, sometimes rewrites it into better search terms, and looks for relevant material. That material can be the web, or it can be a set of documents, such as a company's HR policies or files you uploaded. The search step picks the passages that seem most relevant and pastes them into the context window. It also adds an instruction along the lines of: answer using these sources and say which one each point came from.

The model then writes as usual, predicting one token after another, as described in lesson 3.2. The context now contains passages about your question, so the likeliest next tokens tend to repeat what those passages say. The numbered markers are the model's way of pointing back to the passage it drew on.

The technical name for the whole pattern is retrieval-augmented generation, shortened to RAG. You will see it on product pages and in job ads. Retrieval is the search step. Augmented means the search results are added to the context. Generation is the model writing its reply.

Where you will meet RAG

You will find RAG in these places:

assistants with a web search option, every time they search chat-with-a-PDF tools tools for chatting with a folder of contracts or a company knowledge base, which search your documents instead of the web many customer service chatbots on bank, telco and insurer websites, which search the company's help articles before replying

Document tools usually prepare your files ahead of time by cutting each one into chunks of a few paragraphs. When you ask a question, the tool finds the chunks closest to it in meaning, including ones that don't share your exact words, and passes those chunks to the model. It does not hand over the whole file. So if a chat-with-your-documents tool misses something you know is in the file, the relevant chunk may never have reached the model.

Take Mei Ling's firm, which loads its 30-page staff handbook into a chat-with-your-documents tool. Ahead of time, the tool cuts the handbook into about 90 chunks. One chunk says staff can claim up to S$500 a year for work courses (an example figure). The next chunk, which starts a new page, says each claim needs a manager's approval first.

A designer asks: how much can I claim for a course? The search step compares the question with all 90 chunks and picks the three closest in meaning: the course allowance chunk, a chunk on medical claims and a chunk on travel claims. It pastes those three into the context window with the instruction to answer from them. The approval chunk is not among the three, so the model never sees it. The reply reads: you can claim up to S$500 a year for courses [1]. The figure is right and the citation points to the right page, but the approval condition is missing because it was in a chunk the search step left out.

What retrieval fixes and what it leaves open

Retrieval fixes two problems. First, the model can answer about events after its training cutoff, which lesson 4.4 showed it otherwise gets wrong. Second, it can answer from private material it was never trained on, such as your company's leave policy. The answer is grounded in text the model can see, so it invents facts less often than when it works from memory alone.

Less often is not never. The model can still misread a passage. It can merge details from two sources into one claim that neither source makes. It can drop a condition that changes the meaning. It can put a citation marker next to a sentence that the cited page does not support. A marker shows which passage was nearby when the sentence was written. It does not prove that the passage says it.

The answer can also only be as good as what the search step found, and the model has no way to know what a better search would have turned up. If the search finds an outdated guide, a page about rules in Malaysia, or a forum post from someone guessing, the model writes from it in the same assured tone it would use for an official source.

That is what happened to Mei Ling. The search found a law firm article written before a later change, and a forum thread. The reply cited both sources and read well. Neither source was the current official guidance, and nothing in the wording warned her of that.

Checking the citations before you rely on the answer

Citations are how you check the answer, but only if you open them. Open each citation. Check that the source is official or at least reputable, that it is current, and that it is about Singapore when your question is. Then read the cited passage and check that it really says what the answer claims. Lesson 6.3, "A five-minute routine for checking any answer", turns these checks into a habit.

The quickest way to see why this matters is to run a search-enabled assistant on a local rule you care about and follow every one of its markers back to the page.

Ask a search-enabled assistant about a Singapore rule. Open every source it cites and note whether each one says what the answer claims it says.

Course

Junxiong-WFG Organisation is an authorised representative of AIA Financial Advisers Private Limited (Reg. No. 201715016G).