RAG
RAG stands for retrieval-augmented generation.
What Is RAG
RAG retrieves relevant information from external sources and gives it to a language model before generating an answer.
It helps models answer with project-specific or up-to-date context.
How To Use RAG
Split documents into chunks, create embeddings, store them, retrieve relevant chunks, and pass them into the model prompt.
Basic Example
const docs = await retriever.search("How do agents use memory?");
const answer = await model.generate({
question: "How do agents use memory?",
context: docs,
});
Common Concepts
- Chunking controls document size.
- Embeddings support semantic search.
- Retrieval finds relevant context.
- Evaluation checks whether answers are grounded.
What To Learn Next
Learn chunking strategies, vector search, reranking, citations, retrieval evaluation, and hybrid search.