RAG Patterns
7 intelligent retrieval-augmented generation patterns for knowledge management.
Overview
isA Data supports multiple RAG patterns optimized for different use cases:
| Pattern | Description | Latency | Best For |
|---|---|---|---|
| Simple | Basic vector search + LLM | Fast | General Q&A |
| CRAG | Corrective with validation | Medium | Fact-checking |
| HyDE | Hypothetical document embeddings | Medium | Sparse data |
| Graph RAG | Knowledge graph enhanced | Medium | Entity relationships |
| RAG Fusion | Multi-query fusion | Medium | Complex questions |
| Self-RAG | Self-reflective generation | Slow | High accuracy |
| RAPTOR | Recursive summarization | Slow | Long documents |
Simple RAG
Basic vector similarity search with LLM generation.
How It Works
Query → Embed → Vector Search → Top-K Chunks → LLM → ResponseUsage
# Store
response = await client.post(
"/api/v1/digital/store",
json={
"user_id": "user123",
"content": "Your content here",
"content_type": "text"
}
)
# Search
response = await client.post(
"/api/v1/digital/search",
json={
"user_id": "user123",
"query": "Your question",
"search_options": {
"rag_mode": "simple",
"top_k": 5
}
}
)
# Response
response = await client.post(
"/api/v1/digital/response",
json={
"user_id": "user123",
"query": "Your question",
"response_options": {
"rag_mode": "simple"
}
}
)CRAG (Corrective RAG)
Adds self-correction through relevance validation.
How It Works
Query → Retrieve → Relevance Check ─┬─▶ Relevant → Generate
└─▶ Not Relevant → Web Search → GenerateFeatures
- Relevance scoring for retrieved chunks
- Automatic fallback to web search
- Self-correction loop
Usage
response = await client.post(
"/api/v1/digital/response",
json={
"user_id": "user123",
"query": "What is the capital of France?",
"response_options": {
"rag_mode": "crag",
"relevance_threshold": 0.7,
"use_web_search": True
}
}
)HyDE (Hypothetical Document Embeddings)
Generates hypothetical documents to improve retrieval.
How It Works
Query → LLM → Hypothetical Doc → Embed → Search → Real Docs → GenerateWhen to Use
- Vague or abstract queries
- Sparse knowledge bases
- Concept-based search
Usage
response = await client.post(
"/api/v1/digital/response",
json={
"user_id": "user123",
"query": "How do neural networks learn?",
"response_options": {
"rag_mode": "hyde",
"num_hypothetical_docs": 1
}
}
)Graph RAG
Knowledge graph-enhanced retrieval for entity relationships.
How It Works
Query → Extract Entities → Graph Traversal → Context Enrichment → Generate
│ │
▼ ▼
Neo4j Store Related EntitiesFeatures
- Entity extraction from documents
- Relationship mapping
- Multi-hop traversal
- Context enrichment
Usage
# Store with graph indexing
response = await client.post(
"/api/v1/digital/store",
json={
"user_id": "user123",
"content": "Apple Inc. was founded by Steve Jobs in Cupertino.",
"content_type": "text"
}
)
# Query with graph context
response = await client.post(
"/api/v1/digital/response",
json={
"user_id": "user123",
"query": "Who founded Apple?",
"response_options": {
"rag_mode": "graph_rag",
"use_neo4j": True,
"max_hops": 2
}
}
)Graph Components
| Component | Purpose |
|---|---|
| Entity Extractor | Extract entities from text |
| Relation Extractor | Identify relationships |
| Graph Constructor | Build Neo4j graph |
| Knowledge Retriever | Traverse and retrieve |
RAG Fusion
Multi-query fusion with Reciprocal Rank Fusion (RRF).
How It Works
Original Query → Query Variants (3-5) → Parallel Search → RRF Fusion → Generate
│ │
▼ ▼
Rephrase/Expand Dedupe + RankFeatures
- Multiple query variations
- Parallel retrieval
- RRF score combination
- Improved recall
Usage
response = await client.post(
"/api/v1/digital/response",
json={
"user_id": "user123",
"query": "Best practices for microservices",
"response_options": {
"rag_mode": "rag_fusion",
"num_queries": 3,
"fusion_weight": "equal"
}
}
)Self-RAG
Self-reflective generation with quality checks.
How It Works
Query → Retrieve → Generate Draft → Self-Critique ─┬─▶ Good → Return
└─▶ Bad → RegenerateFeatures
- Response quality assessment
- Automatic regeneration
- Hallucination detection
- Confidence scoring
Usage
response = await client.post(
"/api/v1/digital/response",
json={
"user_id": "user123",
"query": "Explain quantum computing",
"response_options": {
"rag_mode": "self_rag",
"reflection_enabled": True,
"max_iterations": 3
}
}
)RAPTOR
Recursive Abstractive Processing for Tree-Organized Retrieval.
How It Works
Documents → Chunk → Cluster → Summarize → Build Tree → Search Tree → Generate
│
▼
Hierarchical Index
/\
/ \
Summaries
/ \
Chunks ChunksFeatures
- Hierarchical summarization
- Multi-level retrieval
- Long document support
- Context compression
Usage
# Store with RAPTOR indexing
response = await client.post(
"/api/v1/digital/store",
json={
"user_id": "user123",
"content": "https://example.com/long-document.pdf",
"content_type": "pdf"
}
)
# Query with tree traversal
response = await client.post(
"/api/v1/digital/response",
json={
"user_id": "user123",
"query": "Summarize the main findings",
"response_options": {
"rag_mode": "raptor",
"tree_depth": 2
}
}
)Pattern Selection Guide
| Scenario | Recommended Pattern |
|---|---|
| Quick Q&A | Simple RAG |
| Fact verification | CRAG |
| Abstract concepts | HyDE |
| Entity relationships | Graph RAG |
| Improve recall | RAG Fusion |
| High accuracy required | Self-RAG |
| Long documents | RAPTOR |
Evaluation
All patterns support DeepEval quality metrics:
| Metric | Description | Target |
|---|---|---|
| Faithfulness | Grounded in context | > 0.8 |
| Relevancy | Answers the question | > 0.75 |
| Context Precision | Right chunks retrieved | > 0.7 |
| Context Recall | All info retrieved | > 0.7 |
# Get evaluation metrics
response = await client.post(
"/api/v1/digital/response",
json={
"user_id": "user123",
"query": "Your question",
"response_options": {
"rag_mode": "simple",
"include_evaluation": True
}
}
)
# Response includes:
# {
# "response": "...",
# "evaluation": {
# "faithfulness": 0.85,
# "relevancy": 0.82
# }
# }Hybrid GraphRAG with RRF Fusion
Combines graph-based retrieval (Neo4j) with vector similarity search (Qdrant) and merges results using Reciprocal Rank Fusion for higher recall than either source alone.
How It Works
Query
│
├──▶ Graph retrieval (Neo4j) → ranked results A
├──▶ Vector retrieval (Qdrant) → ranked results B
│
▼
Reciprocal Rank Fusion (k=60)
│
▼
Merged & re-ranked results → LLM → ResponseRRF score formula: score = Σ 1/(k + rank_i) where k=60 is a smoothing constant. Results that appear highly ranked in both sources receive the highest fused score.
Usage
response = await client.post(
"/api/v1/digital/search",
json={
"user_id": "user123",
"query": "How do agent checkpoints relate to session state?",
"search_options": {
"rag_mode": "hybrid_graph",
"top_k": 10
}
}
)When to Use
| Scenario | Recommended pattern |
|---|---|
| Entity-relationship questions | Hybrid GraphRAG |
| Semantic similarity only | Simple RAG or RAG Fusion |
| Graph traversal only | Graph RAG |
| Best recall on complex questions | Hybrid GraphRAG |
Vector DB Backends
isA Data supports multiple vector database backends implementing the BaseVectorDB interface:
| Backend | VectorDBType | Best for |
|---|---|---|
| Qdrant (default) | QDRANT | Production, full-featured, hosted |
| Milvus | MILVUS | High-scale, distributed deployments |
Milvus Backend
Configure Milvus via environment variables:
VECTOR_DB_TYPE=MILVUS
MILVUS_HOST=localhost
MILVUS_PORT=19530
MILVUS_COLLECTION=isa_docs # Collection name (default: isa_data)The Milvus backend implements the same BaseVectorDB API — no code changes needed to switch from Qdrant:
# Works identically regardless of backend
response = await client.post(
"/api/v1/digital/store",
json={"user_id": "user123", "content": "...", "content_type": "text"}
)Next Steps
- Quick Start - Get started
- Data Lake - Zone management
- File Processing - Multi-modal content
- AI Data Copilot - Generate data artifacts from natural language