Query Mode Comparison
This guide demonstrates all 5 query modes using real examples, helping you choose the right mode for your use case.
Test Dataset
For these examples, we'll use a Slack workspace with the following data:
Channels: #engineering, #product, #general
Team Members: Alice (backend), Bob (frontend), Carol (product)
Recent Discussions:
API refactor planning
Performance issues
New feature launch
Example 1: Simple Keyword Search
Question: "API refactor"
Naive Mode ⚡
curl http://localhost:3000/api/query \
-H "Content-Type: application/json" \
-d '{
"query": "API refactor",
"mode": "naive",
"top_k": 5
}'Results:
Analysis: Fast and simple. Returns documents with matching keywords. Good for quick lookups when you know the exact terms.
Example 2: Entity-Focused Question
Question: "What is Alice working on?"
Naive Mode
Results: Returns documents mentioning "Alice" and "working", but may miss context.
Local Mode 🎯 (Better)
Results:
Analysis: Local mode identifies "Alice" as an entity and finds all documents connected to her, including indirect mentions. Much better for "What is X?" questions.
Why Local > Naive:
✅ Understands "Alice" is an entity, not just a keyword
✅ Finds all Alice's activities, not just exact keyword matches
✅ Includes documents where others mention Alice
Example 3: Relationship Question
Question: "How does the API refactor connect to performance issues?"
Local Mode
Results: Finds documents about "API refactor" and documents about "performance issues", but doesn't explain the connection.
Global Mode 🔗 (Better)
Results:
Analysis: Global mode understands you're asking about relationships, not just entities. It finds documents that explain how things connect.
Why Global > Local:
✅ Focuses on relationships between concepts
✅ Explains connections, not just mentions
✅ Reveals indirect connections through the graph
Example 4: Complex Multi-Part Question
Question: "What blockers does the frontend team have with the API changes?"
This question needs:
Identify "frontend team" entity (Local)
Find "blockers" relationships (Global)
Connect to "API changes" (Global)
Hybrid Mode ⚖️ (Best for this)
Results:
Analysis: Hybrid mode combines Local (find frontend team) + Global (find blocker relationships) for comprehensive results.
Example 5: Production Query Requiring Maximum Accuracy
Question: "What did we discuss about the API refactor last week?"
This is a complex question requiring:
Time-based filtering ("last week")
Topic identification ("API refactor")
Discussion context (multiple people, threads)
Mix Mode 🌟 (Best)
Results:
Analysis: Mix mode retrieves ~60 candidates using Hybrid, then uses an LLM reranker to select the most relevant results. Most accurate but slowest.
Side-by-Side Comparison
Using the same query across all modes:
Query: "What performance issues did the team discuss?"
Naive
5
⭐⭐
67ms
Keyword matches "performance" + "issues"
Local
8
⭐⭐⭐
123ms
Found "team" entity + related discussions
Global
6
⭐⭐⭐
145ms
Found "performance" relationships + root causes
Hybrid
12
⭐⭐⭐⭐
298ms
Combined entity + relationships
Mix
10
⭐⭐⭐⭐⭐
512ms
Best relevance after reranking (LLM scored each)
Decision Tree: Which Mode to Use?
Performance vs Accuracy Trade-offs
Development / Testing
Recommended: Hybrid mode
Good balance of accuracy and speed
Comprehensive results
Fast enough for iteration
Production / User-Facing
Recommended: Mix mode
Best accuracy
Worth the extra latency for user satisfaction
Can cache common queries
High-Volume / Cost-Sensitive
Recommended: Local or Global (depending on query type)
Faster than Hybrid/Mix
Lower cost (fewer LLM calls for reranking)
Still much better than Naive
Real-Time / Low-Latency Requirements
Recommended: Naive mode
<100ms response time
Good enough for autocomplete, suggestions
Can always re-query with better mode
Advanced: Tuning Parameters
Each mode accepts parameters to fine-tune behavior:
Top K (Candidate Retrieval)
Higher = More comprehensive but slower
Chunk Top K (Final Results)
Higher = More results to review
Score Threshold
Higher = More precision, lower recall
Entity Limit
Higher = More entity connections explored
Real-World Examples
Customer Support Bot
Internal Search Tool
Autocomplete Suggestions
Next Steps
Query API Reference - Full API documentation
Best Practices - Optimization tips
LightRAG Deep Dive - How it works under the hood
Last updated
Was this helpful?