What is RAG
Retrieval-Augmented Generation — augmenting LLM with external data
RAG (Retrieval-Augmented Generation) — an architecture that augments LLM responses with relevant information from an external knowledge base.
How RAG Works
- Query — user asks a question
- Retrieval — system finds relevant documents in knowledge base
- Context — found documents are added to the prompt
- Generation — LLM generates response considering context
RAG System Components
- Embedding model — converts text to vectors
- Vector DB — stores and searches embeddings
- Chunking — splitting documents into fragments
- Ranking — sorting results by relevance
- LLM — generates final response
Advanced Techniques
- Hybrid search — combination of vector and keyword search
- Re-ranking — re-ordering results
- Query expansion — expanding query with synonyms
- Multi-hop RAG — chain of searches for complex questions
Business Applications
- Corporate assistants — answers from internal documentation
- Tech support — knowledge base for support bots
- Legal systems — searching laws and precedents
- Healthcare — information on symptoms and protocols