Retrieval-Augmented Generation
Retrieval-Augmented Generation (RAG) is a technique that grounds an LLM's response by retrieving relevant documents from an external knowledge base and inserting them into the prompt at inference time.
What is Retrieval-Augmented Generation?
Retrieval-Augmented Generation (RAG) is a technique that grounds an LLM's response by retrieving relevant documents from an external knowledge base and inserting them into the prompt at inference time.
Retrieval-Augmented Generation (RAG) is a technique that grounds an LLM's response by retrieving relevant documents from an external knowledge base and inserting them into the prompt at inference time.
Where is it used?
ChatGPT's file search, Perplexity, and enterprise LLM apps built on LangChain/LlamaIndex all use RAG to answer questions over private documents without fine-tuning the model.
How to build it
Use `langchain` with a `FAISS` vector store and `OpenAIEmbeddings`, create a `RetrievalQA` chain over your documents, and call `chain.run(query)` to retrieve and generate an answer.
Code
A practical example:
Further reading
Want to go deeper? These resources cover Retrieval-Augmented Generation in more detail: