LLM fundamentals

Retrieval augmented generation

Also known as RAG, Retrieval-augmented generation

By WeavePublished 1 min read

Definition

Retrieval augmented generation, or RAG, is an architecture that retrieves relevant documents or records and supplies them to a language model as context for generating a response. It can ground answers in a changing or private information source without retraining the model for every update.

Two systems work together

A RAG pipeline first prepares a searchable collection, then retrieves likely relevant pieces for a question. The language model receives those pieces along with the request and generates an answer using the supplied context.

Retrieval and generation can fail independently. The retriever may miss the best document. The model may receive the right document but misunderstand it or claim more than the evidence supports.

An engineering example

Imagine a team asking an assistant why a service's review time increased. A retrieval layer might find recent pull requests, ownership changes, and release records. The answer should identify which records support its explanation and acknowledge when the evidence is incomplete.

The collection needs current data and sensible access controls. A retrieved document is not automatically trustworthy simply because it came from an internal system.

Evaluate the whole chain

Test retrieval recall, ranking, context length, answer accuracy, citation support, latency, and cost. Use cases that include ambiguous questions and missing evidence. A fluent answer based on the wrong records is a quality failure even when a language-only benchmark looks strong.

RAG is a system pattern, not a guarantee of grounded answers. The retrieval query, chunking, permissions, prompt, model, and grader all influence the result.

How this relates to Weave

Wooly is designed to help teams ask questions about engineering data. RAG concepts explain how an AI system can retrieve relevant records before answering. A useful engineering-data experience still needs access controls, source attribution, and evaluations that check whether the retrieved evidence supports the answer.

Explore Wooly

Sources and further reading

  1. Retrieval augmented generation, Google Cloud Architecture Center