Skip to main content
GraphRAG uses prompts to guide LLMs in extracting entities, relationships, and generating summaries. Customizing these prompts for your specific domain can significantly improve the quality and relevance of your knowledge graph.

Why customize prompts?

Default prompts work well for general use cases, but domain-specific customization offers:
  • Better entity recognition - Identify domain-specific entities
  • Improved relationship extraction - Capture industry-specific connections
  • Domain-aware summaries - Generate contextually relevant reports
  • Reduced hallucinations - Focus on relevant information

Prompt tuning methods

GraphRAG offers two approaches to prompt customization:

Auto tuning

Automatically generates domain-adapted prompts using your data

Manual tuning

Manually edit prompts for fine-grained control

Auto prompt tuning

Auto tuning analyzes your input data and generates optimized prompts automatically.
1

Prepare your data

Place your domain-specific documents in the input/ directory:
2

Run auto tuning

Execute the auto-tuning command:
Auto tuning will make several LLM calls to analyze your data. This may take a few minutes and consume API tokens.
3

Review generated prompts

Check the generated prompts in the ./prompts directory:
You’ll find:
  • entity_extraction.txt - Entity extraction prompt
  • summarize_descriptions.txt - Entity summarization prompt
  • community_report.txt - Community report generation prompt
4

Update configuration

Update settings.yaml to use the custom prompts:
5

Re-index with custom prompts

Run indexing again with your tuned prompts:

Manual prompt tuning

For advanced use cases, you can manually edit prompts to have complete control.

Understanding prompt structure

GraphRAG prompts follow a specific structure:

Example: Customizing for medical domain

1

Create custom entity types

Define domain-specific entities for medical documents:
prompts/medical_entities.txt
2

Customize community reports

Tailor community summaries for medical insights:
prompts/medical_community_report.txt
3

Update configuration

Reference your custom prompts in settings.yaml:

Domain-specific examples

Best practices

Start with auto tuning

Begin with auto-generated prompts and refine manually as needed

Provide examples

Include domain-specific examples in your prompts for better results

Iterate and test

Test prompts on sample data and refine based on output quality

Keep it focused

Define specific entity types relevant to your domain, avoid being too broad

Testing custom prompts

1

Create test dataset

Use a small, representative sample of your data:
2

Run indexing on test data

Configure GraphRAG to use your test directory:
3

Evaluate results

Review the generated entities and relationships:
4

Refine and iterate

Based on the results:
  • Add missing entity types
  • Clarify entity definitions
  • Provide more specific examples
  • Adjust relationship types

Advanced techniques

Few-shot learning

Include examples directly in your prompts:

Chain-of-thought prompting

Guide the LLM through reasoning steps:

Next steps

Prompt tuning guide

Complete guide to prompt tuning

Configuration reference

Full configuration options

Global search notebook

Experiment with search parameters

Use cases

Real-world examples