RAG System Design: Empowering Large Models with Real-time Knowledge Capabilities

Β·1 min readΒ·194 views
RAG System Design: Empowering Large Models with Real-time Knowledge Capabilities

What is RAG

RAG (Retrieval-Augmented Generation) enables large models to access the latest and accurate external knowledge by retrieving relevant documents before generation, effectively addressing issues of hallucination and outdated knowledge.

Core Architecture

User Query β†’ Query Rewriting β†’ Retrieval β†’ Re-ranking β†’ Prompt Assembly β†’ LLM Generation

Hybrid Retrieval

Combines vector retrieval and keyword retrieval, merging results using Reciprocal Rank Fusion.

Re-ranking

Uses Cross-Encoder to fine-rank retrieval results, significantly improving the relevance of the top N results.

Advanced Optimization

  • HyDE: First let LLM generate a hypothetical answer, then use the answer for retrieval
  • Multi-Query: Generate multiple retrieval queries, merge results
  • Adaptive Retrieval: Decide whether to retrieve based on confidence

Evaluation Metrics

Metric Target Value
Recall > 90%
Faithfulness > 85%
Relevance > 90%

RAG is not simply "retrieval + generation", but a system that requires careful design. Hybrid retrieval, re-ranking, and query rewriting are key to improving effectiveness.

Comments are not yet available, stay tuned