Skip to main content
This guide covers proven strategies for getting the best results from GraphRAG, including configuration optimization, cost management, and workflow recommendations.

Before you start

GraphRAG indexing can be expensive. Always start small, test thoroughly, and understand costs before scaling to production datasets.

Initial testing strategy

1

Start with a small dataset

Begin with 5-10 representative documents:
2

Use affordable models for testing

During development, use cost-effective models:
settings.yaml
3

Enable caching

Always enable caching to avoid redundant API calls:
settings.yaml
4

Run dry-run first

Validate configuration before indexing:

Prompt tuning

Always run prompt tuning before indexing your full dataset. Generic prompts rarely yield optimal results for domain-specific data.

When to tune prompts

  • New domain: Medical, legal, scientific, business data
  • Specialized terminology: Industry-specific jargon or concepts
  • Non-English content: Different language or mixed languages
  • Specific entity types: You know what entities matter for your use case

Tuning workflow

1

Prepare representative data

Select documents that represent your full dataset:
2

Run prompt tuning

For large datasets, use --selection-method auto with k-means clustering.
3

Review generated prompts

Check ./project/prompts/ for:
  • Entity types discovered
  • Example extractions
  • Domain-specific language
4

Customize if needed

Edit prompts to:
  • Add missing entity types
  • Adjust extraction instructions
  • Improve examples
5

Test on sample data

Run indexing on a small sample to validate prompt quality:

Prompt tuning parameters

Random (default):
  • Fast and simple
  • Good for uniform datasets
  • Use with --limit 15-20
Top:
  • Uses first N documents
  • Good when documents are pre-sorted
  • Use with --limit 15-20
Auto (recommended for large datasets):
  • Uses k-means clustering
  • Selects representative documents
  • Use with --n-subset-max 300 and --k 15
Be specific but not overly narrow:✓ Good:
  • “medical research papers”
  • “corporate financial reports”
  • “legal contracts and agreements”
✗ Too broad:
  • “science”
  • “business”
✗ Too narrow:
  • “phase 3 clinical trials for oncology drugs”
Specify the primary language of your content:
For multilingual datasets, choose the dominant language.

Configuration optimization

Model selection

Choose models based on your requirements:
Goal: Fast iteration, low cost
Cost: ~$0.05-0.15 per 1000 documents

Chunking configuration

Optimize chunking for your document structure:
settings.yaml
Guidelines:
Document TypeChunk SizeOverlapRationale
Short articles20050Preserve complete thoughts
Long reports300-400100Balance context and granularity
Technical docs400-500100-150Keep technical concepts together
Transcripts300100Natural conversation flow
Legal documents500150Maintain clause integrity
Larger chunks mean fewer LLM calls (lower cost) but may reduce extraction granularity. Start with 300 and adjust based on results.

Entity extraction settings

settings.yaml
max_gleanings trade-offs:
  • 0: Fastest, cheapest, lower recall
  • 1: Recommended balance (default)
  • 2+: Highest quality, expensive, diminishing returns
Each gleaning pass doubles the cost of entity extraction. Only increase for critical use cases.

Community detection

settings.yaml
Guidelines:
  • 500-1000: Brief summaries, lower cost
  • 1500: Recommended default, balanced detail
  • 2000-3000: Comprehensive reports, higher cost

Rate limiting

Set appropriate rate limits to avoid throttling:
settings.yaml
Free tier:
  • 3 RPM, 40,000 TPM (GPT-4)
  • 5 RPM, 100,000 TPM (GPT-3.5)
Tier 1 ($5+ spent):
  • 500 RPM, 80,000 TPM (GPT-4o)
  • 3,500 RPM, 200,000 TPM (GPT-3.5)
Set to 90% of your limit to be safe.

Cost management

Estimate costs before indexing

Run a test with a small sample and extrapolate:

Cost reduction strategies

Enable caching

Prevents redundant LLM calls during re-indexing

Larger chunks

Fewer chunks = fewer LLM calls

Reduce gleanings

Each pass costs more

Use cheaper models

For development and testing

Cost tracking

Monitor spending:
  • OpenAI: Check usage at platform.openai.com/usage
  • Azure: Monitor costs in Azure Portal → Cost Management
  • Local logs: Track token counts in GraphRAG logs

Query optimization

Choose the right search method

Community level selection

Guidelines:
  • Level 0: Entire dataset (very broad, expensive)
  • Level 1: Major themes (broad summaries)
  • Level 2: Recommended default (balanced granularity)
  • Level 3+: Fine-grained details (more specific)
Start with level 2. Increase for more specific queries, decrease for very broad questions.

Response type optimization

Guide the format of responses:

Data preparation

Document formatting

GraphRAG supports:
  • Plain text (.txt)
  • Markdown (.md)
  • CSV (.csv)
  • Other formats via custom loaders
Recommendation: Convert documents to plain text or markdown for best results.
Well-structured documents yield better results:Good structure:
Poor structure:
  • No headings or sections
  • Mixed formatting
  • Excessive special characters
  • Malformed text from PDF extraction
Include relevant metadata in documents:
GraphRAG can extract entities from metadata.

Data cleaning

Clean your data before indexing:

Storage and scalability

Local vs. cloud storage

Best for:
  • Development
  • Small datasets (<10K documents)
  • Testing

Large dataset handling

For datasets with >10,000 documents:
1

Partition your data

Split into logical groups:
Index separately or together based on use case.
2

Optimize chunking

Use larger chunks to reduce total chunk count:
3

Use cloud storage

Azure Blob + Azure AI Search for scalability.
4

Implement incremental updates

Use graphrag update for new documents:

Workflow best practices

Development workflow

1

Initial setup

2

Small sample test

3

Prompt tuning

4

Validation

5

Iterate

  • Adjust configuration
  • Refine prompts
  • Test again
6

Scale up

Version control

Track your GraphRAG configuration:

Monitoring and debugging

Enable verbose logging during development:
Check logs for:
  • Token usage
  • API errors
  • Extraction quality
  • Processing time

Common pitfalls

Problem: Generic prompts produce poor extractionsSolution: Always run graphrag prompt-tune for domain-specific data
Problem: Expensive mistakes on full datasetSolution: Test with 5-10 documents first, validate results, then scale
Problem: API throttling, failed indexingSolution: Configure rate limits to 90% of your quota
Problem: Redundant API calls cost moneySolution: Always enable caching for development
Problem: Poor query resultsSolution: Match search method to query type (see query optimization)
Problem: Garbage in, garbage outSolution: Clean and structure documents before indexing

Performance benchmarks

Typical indexing performance:
DocumentsModelChunksTimeCost
100GPT-4o~2,00015-30 min$1-3
1,000GPT-4o~20,0002-4 hours$10-30
10,000GPT-4o~200,00020-40 hours$100-300
These are rough estimates. Actual costs depend on document length, chunk size, gleanings, and model pricing.

Next steps

CLI usage

Master the command-line interface

Configuration

Deep dive into settings

Prompt tuning

Optimize prompts for your domain

Migration guide

Upgrade between versions