This page references the drift_search.ipynb notebook from the GraphRAG repository.
What is DRIFT search?
DRIFT search uses an iterative approach that:- Starts with entity-level retrieval like local search
- Dynamically expands to related communities
- Performs multi-hop reasoning across the knowledge graph
- Adapts context based on query complexity
When to use DRIFT search
DRIFT search is ideal for:- Complex multi-hop queries - “How do organizations influence events?”
- Exploratory questions - “What patterns emerge from X?”
- Adaptive reasoning - Questions requiring both broad and specific context
- Relationship traversal - Following chains of connections
How DRIFT search works
Iterative expansion
The search expands through relationships and communities in multiple iterations (“drift” steps).
Context aggregation
Information from entities, relationships, text units, and community reports is combined.
Setting up the notebook
Import required libraries
Configure paths
Load data tables
Configure language models
Configure DRIFT parameters
- primer_folds
- drift_k_followups
- n_depth
Number of initial retrieval rounds to seed the search.
1= Single retrieval (faster)2-3= Multiple perspectives (more comprehensive)
Create search engine
Perform DRIFT search
Inspect search results
Example queries
Entity exploration
Entity exploration
Multi-hop reasoning
Multi-hop reasoning
Pattern discovery
Pattern discovery
Causal reasoning
Causal reasoning
Understanding DRIFT behavior
Search progression
Initial retrieval (Primer)
DRIFT starts by retrieving entities most relevant to your query using semantic search.
First drift iteration
From initial entities, DRIFT expands to:
- Connected entities via relationships
- Associated text units
- Containing communities
Subsequent iterations
DRIFT continues expanding up to
n_depth hops, gathering increasingly distant but potentially relevant context.Tuning DRIFT parameters
For different query types
- Simple entity queries
- Complex analysis
- Balanced approach
Performance considerations
Cost control
DRIFT can be expensive due to iterative LLM calls. Control costs with:
- Lower
n_depthvalues - Fewer
drift_k_followups - Reduce
primer_folds
Response time
Each drift iteration adds latency. For faster responses:
- Set
n_depth=2 - Use
primer_folds=1 - Consider local search for simple queries
Quality vs. speed
Higher parameters = better coverage but slower and more expensive:
- Test with low values first
- Increase gradually as needed
- Monitor token usage
Query complexity
Match parameters to query complexity:
- Simple: Low parameters
- Complex: High parameters
- Adaptive: Start low, increase if needed
Comparing search methods
| Feature | DRIFT Search | Local Search | Global Search |
|---|---|---|---|
| Approach | Iterative graph traversal | Single-step retrieval | Map-reduce over reports |
| Context | Dynamic, adaptive | Fixed entity-centric | Community-level |
| Best for | Complex, multi-hop | Specific entities | Dataset summaries |
| Cost | Medium-High | Low-Medium | High |
| Flexibility | High | Medium | Low |
| Response time | Medium | Fast | Slow |
Advanced usage
Custom traversal strategies
You can influence how DRIFT explores the graph:Analyzing traversal paths
Use cases
Investigative analysis
Investigative analysis
Query: “How are different suspects connected to the crime scene?”DRIFT excels here by:
- Starting with suspect entities
- Traversing relationship chains
- Discovering indirect connections
- Including relevant evidence from text
Supply chain analysis
Supply chain analysis
Query: “How does disruption at supplier X affect our products?”DRIFT can:
- Map supplier relationships
- Follow dependencies through tiers
- Identify affected products
- Include contextual details
Research synthesis
Research synthesis
Query: “What research links concept A to outcome B?”DRIFT helps by:
- Finding relevant research entities
- Tracing citation and influence chains
- Bridging concepts through intermediates
- Synthesizing findings
Social network analysis
Social network analysis
Troubleshooting
Incomplete or shallow answers
Incomplete or shallow answers
Solutions:
- Increase
n_depthto explore further - Increase
drift_k_followupsfor broader exploration - Add more
primer_foldsfor better initial retrieval - Check if relevant entities exist in knowledge graph
Too slow or expensive
Too slow or expensive
Solutions:
- Reduce
n_depthto 2 - Lower
drift_k_followupsto 2 - Set
primer_foldsto 1 - Consider local search for simpler queries
Irrelevant information included
Irrelevant information included
Solutions:
- Reduce
n_depthto avoid distant connections - Lower
drift_k_followupsfor more focused exploration - Improve entity extraction during indexing
- Refine your query to be more specific
Best practices
Start conservative
Begin with low parameter values and increase as needed
Match complexity
Use higher parameters only for genuinely complex queries
Monitor costs
Track token usage and adjust parameters accordingly
Compare methods
Try local/global search first; use DRIFT when they fall short
Next steps
Search comparison
Compare all search methods side-by-side
Local search
Learn about local search for entity-specific queries
Global search
Understand global search for dataset-wide questions
DRIFT documentation
Complete DRIFT search reference