Skip to main content
DRIFT (Dynamic Reasoning and Inference with Flexible Traversal) search combines aspects of both global and local search methods to provide flexible, context-aware query responses.
This page references the drift_search.ipynb notebook from the GraphRAG repository.
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
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

1

Primer phase

Initial entities are retrieved based on semantic similarity to the query.
2

Iterative expansion

The search expands through relationships and communities in multiple iterations (“drift” steps).
3

Context aggregation

Information from entities, relationships, text units, and community reports is combined.
4

Response synthesis

The LLM generates a comprehensive answer using the dynamically assembled context.

Setting up the notebook

Import required libraries

Configure paths

Load data tables

Configure language models

Configure DRIFT parameters

Number of initial retrieval rounds to seed the search.
  • 1 = Single retrieval (faster)
  • 2-3 = Multiple perspectives (more comprehensive)

Create search engine

Inspect search results

Example queries

Understanding DRIFT behavior

Search progression

1

Initial retrieval (Primer)

DRIFT starts by retrieving entities most relevant to your query using semantic search.
2

First drift iteration

From initial entities, DRIFT expands to:
  • Connected entities via relationships
  • Associated text units
  • Containing communities
3

Subsequent iterations

DRIFT continues expanding up to n_depth hops, gathering increasingly distant but potentially relevant context.
4

Response generation

All gathered context is synthesized into a comprehensive answer.

Tuning DRIFT parameters

For different query types

Performance considerations

Cost control

DRIFT can be expensive due to iterative LLM calls. Control costs with:
  • Lower n_depth values
  • 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

FeatureDRIFT SearchLocal SearchGlobal Search
ApproachIterative graph traversalSingle-step retrievalMap-reduce over reports
ContextDynamic, adaptiveFixed entity-centricCommunity-level
Best forComplex, multi-hopSpecific entitiesDataset summaries
CostMedium-HighLow-MediumHigh
FlexibilityHighMediumLow
Response timeMediumFastSlow

Advanced usage

Custom traversal strategies

You can influence how DRIFT explores the graph:

Analyzing traversal paths

Use cases

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
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
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
Query: “How are these individuals connected through mutual contacts?”DRIFT navigates:
  • Direct relationships
  • Mutual connections (2+ hops)
  • Shared group memberships
  • Interaction contexts

Troubleshooting

Solutions:
  • Increase n_depth to explore further
  • Increase drift_k_followups for broader exploration
  • Add more primer_folds for better initial retrieval
  • Check if relevant entities exist in knowledge graph
Solutions:
  • Reduce n_depth to 2
  • Lower drift_k_followups to 2
  • Set primer_folds to 1
  • Consider local search for simpler queries
Solutions:
  • Reduce n_depth to avoid distant connections
  • Lower drift_k_followups for 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