RAG (Retrieval-Augmented Generation)

Last updated March 25, 2026

RAG combines AI generation with information retrieval from specific data sources to provide accurate grounded responses.

Retrieval-Augmented Generation is a technique where an AI model first retrieves relevant information from a knowledge base or database before generating a response. In coding tools, RAG enables AI to provide answers grounded in your specific codebase, documentation, or company knowledge rather than generic training data.

Frequently Asked Questions

How does RAG improve AI coding?

RAG lets AI tools reference your actual codebase and documentation when generating code, reducing hallucinations and improving accuracy.

Which coding tools use RAG?

Sourcegraph Cody indexes your codebase for RAG. Cursor uses codebase context. AI documentation tools like GitBook use RAG for Q&A.

Is RAG better than fine-tuning?

For most coding applications yes. RAG provides current accurate context without the cost and complexity of model fine-tuning.