graphrag command.
Installation
Ensure GraphRAG is installed before using the CLI:Available commands
The GraphRAG CLI includes five main commands:init
Generate a default configuration file
index
Build a knowledge graph index
update
Update an existing index
prompt-tune
Generate custom prompts from your data
query
Query a knowledge graph index
Initialize a project
Theinit command creates a new GraphRAG project with default configuration files.
Run initialization
settings.yaml- Configuration file.env- Environment variables for API keysprompts/- Directory with default prompt templatesinput/- Directory for source documents
Init command options
| Option | Short | Description | Default |
|---|---|---|---|
--root | -r | Project root directory | Current directory |
--model | -m | Default chat model to use | gpt-4-turbo-preview |
--embedding | -e | Default embedding model | text-embedding-3-small |
--force | -f | Force initialization even if project exists | false |
Build an index
Theindex command processes your documents and builds a knowledge graph.
Indexing methods
Index command options
| Option | Short | Description | Default |
|---|---|---|---|
--root | -r | Project root directory | Current directory |
--method | -m | Indexing method to use | standard |
--verbose | -v | Enable verbose logging | false |
--dry-run | Validate config without executing | false | |
--cache/--no-cache | Enable/disable LLM cache | true | |
--skip-validation | Skip preflight validation | false |
Update an existing index
Theupdate command incrementally updates an existing index with new documents.
- Detects new or modified documents in the input directory
- Processes only the changed documents
- Merges results with the existing index
- Outputs to
update_output/folder by default
Update command options
| Option | Short | Description | Default |
|---|---|---|---|
--root | -r | Project root directory | Current directory |
--method | -m | Indexing method to use | standard |
--verbose | -v | Enable verbose logging | false |
--cache/--no-cache | Enable/disable LLM cache | true | |
--skip-validation | Skip preflight validation | false |
Prompt tuning
Theprompt-tune command generates custom prompts tailored to your data domain.
Advanced prompt tuning
Prompt-tune command options
| Option | Description | Default |
|---|---|---|
--root | Project root directory | Current directory |
--domain | Domain of your input data | Auto-detected |
--selection-method | Text chunk selection method (random, top, auto) | random |
--n-subset-max | Number of chunks to embed (auto mode) | 300 |
--k | Max documents per centroid (auto mode) | 15 |
--limit | Number of documents to load (random/top) | 15 |
--max-tokens | Max token count for prompt generation | 2000 |
--chunk-size | Size of each text chunk | 200 |
--language | Primary language for prompts | Auto-detected |
--output | Directory to save prompts | prompts |
Query your index
Thequery command searches your knowledge graph index.
Query methods
GraphRAG supports four search methods:- Global
- Local
- DRIFT
- Basic
Global search uses the entire knowledge graph to answer questions about the dataset as a whole.Best for: High-level questions, dataset summaries, theme identification
Query command options
| Option | Short | Description | Default |
|---|---|---|---|
query | The query string (required) | - | |
--root | -r | Project root directory | Current directory |
--method | -m | Query algorithm (global, local, drift, basic) | global |
--data | -d | Index output directory | Auto-detected |
--community-level | Leiden hierarchy level | 2 | |
--dynamic-community-selection | Use dynamic community selection | false | |
--response-type | Desired response format | Multiple Paragraphs | |
--streaming | Stream the response | false | |
--verbose | -v | Enable verbose logging | false |
Custom response types
You can specify different response formats:Streaming responses
Enable streaming for real-time output:Common workflows
Complete project setup
Incremental updates
Troubleshooting
Check configuration without indexing
Skip validation for non-LLM steps
Specify custom data directory
Next steps
Python API
Learn how to use GraphRAG programmatically
Configuration
Customize your GraphRAG settings
Prompt tuning
Optimize prompts for your domain
Azure setup
Configure Azure OpenAI integration