Skip to main content
GraphRAG can consume significant LLM resources. Start with the tutorial dataset until you understand the system, and experiment with fast/inexpensive models before committing to large indexing jobs.
Get GraphRAG running in 5 steps: install, initialize, configure, index, and query.

Prerequisites

  • Python 3.11-3.13
  • OpenAI API key or Azure OpenAI credentials

Step 1: Install GraphRAG

1

Create a project directory

2

Activate your virtual environment

3

Install the package

Step 2: Initialize your workspace

Initialize GraphRAG to create the necessary configuration files:
When prompted, specify your preferred models:
  • Chat model: gpt-4.1 (default) or gpt-4-turbo
  • Embedding model: text-embedding-3-large (default)
This creates:
  • settings.yaml - Main configuration file
  • .env - Environment variables (API keys)
  • input/ - Directory for source documents
  • prompts/ - Customizable extraction prompts

Step 3: Configure your API key

Edit .env and add your OpenAI API key:

Step 4: Add your data

Download the sample dataset (A Christmas Carol):
Or add your own documents to the input/ directory. Supported formats:
  • .txt files
  • .csv files (with text column)
  • .json files (with text field)

Step 5: Run the indexing pipeline

Build your knowledge graph index:
This process:
  1. Chunks your documents into text units
  2. Extracts entities, relationships, and claims
  3. Builds a knowledge graph
  4. Detects hierarchical communities
  5. Generates community summaries
  6. Creates vector embeddings
Indexing typically takes 5-15 minutes for the sample dataset with GPT-4. Cost: approximately 0.500.50-2.00 depending on the model and dataset size.
The output is saved to output/ as parquet files.

Step 6: Query your knowledge graph

Now you can ask questions about your data using different search methods:

Understanding the search methods

Global search

Best for: Holistic dataset understandingUses all community summaries in a map-reduce process. Ideal for “what are the main themes” type questions.

Local search

Best for: Entity-specific questionsRetrieves entities and their neighbors. Ideal for “who is X” or “what does Y do” questions.

DRIFT search

Best for: Multi-level reasoningCombines local entity retrieval with community context. Ideal for complex questions requiring both depth and breadth.

Next steps

Configuration

Customize indexing, chunking, and model settings

Prompt tuning

Generate domain-specific prompts for better extraction

Query engine

Learn about all four search methods in depth

Python API

Use GraphRAG programmatically in your applications

Troubleshooting

If you hit rate limits:
  1. Reduce parallelization in settings.yaml:
  2. Add delays between requests:
To reduce indexing costs:
  1. Use gpt-3.5-turbo for initial testing
  2. Enable caching to avoid re-processing:
  3. Use the “fast” indexing method:
For large datasets:
  1. Increase chunk overlap to reduce total chunks
  2. Reduce max_cluster_size in settings
  3. Process documents in batches
Improve extraction with prompt tuning:
This auto-generates prompts optimized for your domain and data.