GraphRAG is Microsoft's pipeline that turns a folder of text into a knowledge graph with community summaries, then answers questions over it. Use it for corpus-wide questions that plain vector RAG misses, such as "what are the main themes across these 500 documents". Trigger phrases - "graphrag index", "graphrag query", "global search vs local search", "build a knowledge graph from documents with an LLM", "Microsoft GraphRAG", "prompt tuning for GraphRAG".
155 stars
0 votes
0 copies
4 views
Added November 8, 2026
devopspythongobashazuregitapidatabase
Works with
terminal
api
Security analysis
A96/100
mediumInstalls packages at runtime which could introduce malicious dependencies
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Graphrag?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/terminalskills-graphrag)
---
name: graphrag
description: >-
GraphRAG is Microsoft's pipeline that turns a folder of text into a knowledge graph with community summaries, then answers questions over it. Use it for corpus-wide questions that plain vector RAG misses, such as "what are the main themes across these 500 documents". Trigger phrases - "graphrag index", "graphrag query", "global search vs local search", "build a knowledge graph from documents with an LLM", "Microsoft GraphRAG", "prompt tuning for GraphRAG".
license: Apache-2.0
compatibility: "Python 3.11-3.13, an OpenAI or Azure OpenAI account (chat and embedding models) for indexing and querying"
metadata:
author: terminal-skills
version: "1.0.0"
category: data-ai
tags: "graphrag, knowledge-graph, rag, microsoft, llm"
repository: https://github.com/microsoft/graphrag
---
# GraphRAG — knowledge-graph RAG for whole-corpus questions
## Overview
GraphRAG is a command-line pipeline from Microsoft Research. `graphrag index` reads text files, uses an LLM to extract entities and relationships, groups the graph into hierarchical communities (Leiden clustering), writes an LLM summary for every community, and embeds text units, entities and reports. `graphrag query` then answers questions with one of four strategies over those outputs.
Everything is configured from a project folder holding `settings.yaml`, `.env`, `input/` and `prompts/`. Results are parquet tables in `output/` and a LanceDB vector store in `output/lancedb`.
Two things to know before starting:
- Indexing calls the LLM for every chunk, then again for summaries and community reports. On a large corpus that is thousands of calls and real money. Always try a handful of files first.
- The README states the project is largely in maintenance mode: bug fixes and dependency updates, no new features. Treat it as a research-grade tool and pin the version.
This skill was checked against `graphrag` 3.3.0 on PyPI (`--help` output and the files generated by `graphrag init`); the indexing and query runs themselves need an LLM key and are described from the official docs.
## Instructions
### Install in a virtual environment
```bash
python3 -m venv .venv
.venv/bin/pip install "graphrag==3.3.0"
.venv/bin/graphrag --help
```
The commands are `init`, `index`, `update`, `prompt-tune` and `query`.
### Initialise a project
```bash
mkdir -p ~/research/support-tickets
.venv/bin/graphrag init --root ~/research/support-tickets
```
`init` asks for the default chat model (default `gpt-4.1`) and embedding model (default `text-embedding-3-large`); you can pass them as `--model` and `--embedding`. It creates `.env`, `settings.yaml`, `input/` and `prompts/` (extraction, summarisation, community-report and search prompts). `--force` re-creates the config in an existing project and overwrites the default files, so commit your edited prompts first.
In `.env` replace the `<API_KEY>` placeholder that `init` writes with your key (created at platform.openai.com) and keep the file out of version control:
```text
GRAPHRAG_API_KEY=<API_KEY>
```
The generated `settings.yaml` references it as `${GRAPHRAG_API_KEY}`. Key sections of the 3.x format:
```yaml
completion_models:
default_completion_model:
model_provider: openai
model: gpt-4.1
auth_method: api_key # or azure_managed_identity
api_key: ${GRAPHRAG_API_KEY}
embedding_models:
default_embedding_model:
model_provider: openai
model: text-embedding-3-large
auth_method: api_key
api_key: ${GRAPHRAG_API_KEY}
input:
type: text # csv, text, json, jsonl
chunking:
type: tokens
size: 1200
overlap: 100
extract_graph:
entity_types: [organization,person,geo,event]
max_gleanings: 1
cluster_graph:
max_cluster_size: 10
extract_claims:
enabled: false
```
For Azure OpenAI set `model_provider: azure`, `azure_deployment_name`, `api_base` and `api_version` on the model entries. Older tutorials show a top-level `models:` key and a `config.yaml`; with 3.x the keys above and `settings.yaml` apply, so re-run `init` in a scratch folder after an upgrade and diff it against your file.
### Add data and index
Put plain-text files in `input/` (`input.type: text`; csv, json and jsonl are also available).
```bash
.venv/bin/graphrag index --root ~/research/support-tickets --dry-run --skip-validation # config check, no LLM calls
.venv/bin/graphrag index --root ~/research/support-tickets
```
Index options: `--method standard|fast` (default `standard`; `--help` also lists `standard-update` and `fast-update`, which belong to `graphrag update`), `--verbose`, `--no-cache` (the LLM cache in `cache/` makes re-runs after a failure cheap, so leave it on), and `--skip-validation`.
- `standard` uses the LLM to extract entities, relationships and descriptions. Highest quality, highest cost; the docs estimate graph extraction at about 75 percent of indexing cost.
- `fast` extracts noun phrases with NLP libraries and builds a co-occurrence graph; the LLM is used only for community reports. Much cheaper, noisier graph. The docs suggest smaller chunks (50-100 tokens) for it. Use it when your questions are mostly summary-style global ones.
When it finishes, `output/` holds parquet tables such as `entities`, `relationships`, `communities`, `community_reports`, `text_units` and `documents`; read them with pandas for your own analysis.
### Query
```bash
.venv/bin/graphrag query "What are the recurring causes of failed deliveries?" --root ~/research/support-tickets --method global
.venv/bin/graphrag query "What did customer Northwind Freight complain about?" --root ~/research/support-tickets --method local
```
`--method` selects the strategy (default `global`):
- `global`: map-reduce over community reports; for questions about the dataset as a whole. The most expensive at query time; `--community-level` (default 2) picks the hierarchy level and `--dynamic-community-selection` prunes irrelevant communities.
- `local`: starts from entities matching the question and pulls related entities, relationships and source text; for specific questions about people, products or events.
- `drift`: local search enriched with community information for broader starting points.
- `basic`: plain top-k vector search over text chunks, useful as a baseline to compare against.
Useful flags: `--response-type "List of 3-7 Points"`, `--streaming`, `--data output`, `--verbose`.
### Tune prompts for your domain
The default extraction prompt targets general news-like text. Generate domain-adapted prompts before a large index run (this also calls the LLM):
```bash
.venv/bin/graphrag prompt-tune --root ~/research/support-tickets --domain "logistics customer support" --selection-method random --limit 15 --language English --output ~/research/support-tickets/prompts
```
Options include `--selection-method all|random|top|auto`, `--limit`, `--chunk-size`, `--max-tokens`, `--min-examples-required`, and `--discover-entity-types` / `--no-discover-entity-types`. Review the generated prompt files, then index.
### Add new documents later
Drop new files into `input/` and run `graphrag update --root ~/research/support-tickets`; it takes the same `--method` option as `index`, so pass the one that matches how you built the index (see `graphrag update --help`). The refreshed index is written to an `update_output` folder. Verify the result on a copy before replacing `output/`.
## Examples
### Example 1: cheap first run on a sample
**Request:** "Try GraphRAG on our 20 support tickets before we index the whole archive."
```bash
python3 -m venv .venv && .venv/bin/pip install "graphrag==3.3.0"
.venv/bin/graphrag init --root ~/research/support-tickets --model gpt-4.1-mini --embedding text-embedding-3-small
cp ~/exports/tickets-2026-10/ticket-00*.txt ~/research/support-tickets/input/
# put the key into ~/research/support-tickets/.env first
.venv/bin/graphrag index --root ~/research/support-tickets --method fast
.venv/bin/graphrag query "Which carriers are mentioned most often in complaints?" --root ~/research/support-tickets --method global
```
**Result:** a progress display for each workflow, then `output/` with parquet files; the query prints a multi-paragraph answer built from community reports. Check the model usage in the provider dashboard before scaling to the archive.
### Example 2: compare graph search with the vector baseline
**Request:** "Does GraphRAG actually beat our normal RAG on this corpus?"
```bash
for m in basic local global; do
echo "== $m"
.venv/bin/graphrag query "How did the Rotterdam depot closure affect delivery times?" --root ~/research/support-tickets --method $m --response-type "Single Paragraph"
done
```
**Result:** three answers to compare. Expect `basic` and `local` to do well on this specific question and `global` to win on "what are the main themes" questions; keep a fixed question set and judge each method on both kinds.
## Guidelines
- Cost first: start with a small `input/`, use cheaper models and `--method fast`, and look at provider usage after the first run. Do not point it at an archive until the sample looks right.
- Never commit `.env`, and do not paste keys into `settings.yaml`; keep `${GRAPHRAG_API_KEY}`.
- `graphrag init --force` overwrites prompts and settings. Edit prompts in version control.
- Pin the version and re-run `init` in a scratch folder after an upgrade: config keys have changed between major versions.
- Text sent to indexing and queries goes to your configured LLM provider. Use Azure OpenAI or another approved endpoint for sensitive data.
- Global search is slow and costly per question; for narrow factual lookups use `local` or `basic`.
- Outputs are plain parquet and LanceDB files. If you want to query the graph with Cypher, load `entities` and `relationships` into a graph database (see the falkordb and neo4j skills) instead of expecting a built-in graph server.
- For a lighter library or server that lets you insert documents incrementally, consider the lightrag skill.