Esc

Retrieval-augmented generation RAG

Fetch the relevant documents first, paste them into the prompt, and the model answers from your data instead of its training.

RAG splits the job in two. Retrieval finds passages that fit the question, usually by comparing embeddings in a vector-database. Generation then gives those passages and the question to the model and asks for an answer based on them.

No training is needed, and that is the draw. Your documents can change every hour while the model stays the same, and answers can quote the passage they used, so you can check them.

When a RAG system fails, retrieval is usually the culprit. If the right passage never gets fetched, no prompt rescues the answer. Chunk size, how you split documents, and whether keyword search runs next to vector search all matter more than which model writes the final text.

Where this comes up

Prompts, configs and tutorials in the library that touch this term.