← Table of Contents · Page 494 of 868
RETRIEVAL-AUGMENTED GENERATION (RAG)
Part 5 of 9
EXAMPLES
Example 1: RAG in action.
An employee asks the company assistant, "What is our vacation policy?"
Without RAG, the model might guess from general knowledge and invent a number of days.
With RAG, the harness searches the handbook, finds the current vacation policy section, places it in context, and instructs the model to answer only from it.
The model replies with the real policy and cites the handbook section.
If the policy was updated last month, the answer reflects the update, because the handbook was re-indexed, while the model's training data could never have known.
Example 2: Embeddings.
A developer embeds three sentences: "The cat sat on the mat," "A feline rested on the rug," and "Quarterly profits rose by eight percent."
The similarity score between the first two is high, and between either of those and the third is low.
This demonstrates that embeddings capture meaning rather than just matching words.
The developer notes that for part numbers like "AX-4417," the embedding is less reliable, so she adds keyword search for such identifiers.
Example 3: Vector search.
A help center has an article titled "Account access recovery steps."
A user types, "how do I reset my password."
A keyword search finds nothing, since none of the words match.
A vector search embeds the question, finds the article embedding is the closest match, and returns it.
The user gets the right help even though the titles and questions share no words.
Example 4: Chunking quality.
A company indexes a fifty-page equipment manual.
In the first attempt, the text is cut every one thousand characters regardless of structure.
Many chunks start or end mid-sentence, and a table of safety limits is sliced in half.
Searching "maximum operating temperature" returns half a table and an unrelated paragraph.
In the second attempt, the team splits along section headings, keeps each table whole, and adds a sentence of overlap.
The same question now retrieves the single section that states the limit, and the chunk makes complete sense on its own when placed in the context.
Advertisement
Read Aloud:
0:00 / 0:00