An employee types "can dads carry it forward?" into the company assistant. It is colloquial, it leans on a pronoun, and it is phrased nothing like the leave policy that answers it. The course follows this one constructed request through every stage of a retrieval pipeline. The rankings and the policy text are illustrative; the mechanism at each step is the real one.
Before the question: the policy, ingested once
Offline, Leave Policy.pdf was parsed into typed elements and split along its headings, so Annual Leave, Sick Leave, Parental Leave and a cross-cutting Carry-Forward Policy each became a chunk. Every chunk carries metadata (document, section, version, department), an embedding, and an entry in a parallel BM25 keyword index. Two of the records matter here, shown abridged:
{ "id": 105, "text": "Fathers receive 30 days of parental leave.", "section": "Parental Leave" }
{ "id": 106, "text": "Unused parental leave may carry forward up to 10 days into the next year.", "section": "Carry-Forward Policy" }
Four steps, one pass
- Rewrite the query. Query transformation resolves "dads" to fathers and parental leave, and "it" to unused leave, giving
parental leave carry-forward policy. That works only because the previous turn of the conversation established what "it" means. Without that history, the right move is to ask which leave the employee means, not to invent a referent. - Retrieve by keyword and by meaning. BM25 catches the exact words "carry" and "forward"; vector search catches "parental leave" by meaning. Reciprocal rank fusion merges the two lists into a top four: Carry-Forward, Parental, Annual and Sick.
- Rerank. A cross-encoder reads each candidate against the query and confirms that the two truly relevant chunks, #105 and #106, belong at the top.
- Generate, with sources. Both chunks go into the prompt with their sources, and the answer cites each fact: fathers receive 30 days of parental leave, and unused parental leave may carry forward up to 10 days into the next year.
Where an agent would come in
This query needed no agent. Hybrid retrieval plus reranking found both facts in a single pass, so a plain pipeline was enough. The loop earns its place when the system cannot know in advance how many facts it needs. In the course's earlier worked example, an agent searched for parental leave, read the result, noticed that the carry-forward rule was still missing, and searched again. That decision is the loop's value: knowing when one retrieval is not enough, instead of hard-coding "always fetch two chunks" and hoping both facts land in them.
Engineering Insight
Individual stages in this pipeline are optional when the workload does not need them. Keep the simpler pipeline as a baseline, and add an adaptive loop only when evaluation shows that choosing another source, or reformulating after an observation, improves the task.


