Skip to content

CLI Reference

This page documents the command-line interface of the graphrag library.

graphrag

GraphRAG: A graph-based retrieval-augmented generation (RAG) system.

Usage:

 [OPTIONS] COMMAND [ARGS]...

Options:

  --install-completion  Install completion for the
                        current shell.
  --show-completion     Show completion for the current
                        shell, to copy it or customize
                        the installation.

index

Build a knowledge graph index.

Usage:

 index [OPTIONS]

Options:

  -c, --config PATH               The configuration to
                                  use.
  -r, --root PATH                 The project root
                                  directory.  \[default:
                                  .]
  -m, --method [standard|fast|standard-update|fast-update]
                                  The indexing method to
                                  use.  \[default:
                                  standard]
  -v, --verbose                   Run the indexing
                                  pipeline with verbose
                                  logging
  --memprofile                    Run the indexing
                                  pipeline with memory
                                  profiling
  --dry-run                       Run the indexing
                                  pipeline without
                                  executing any steps to
                                  inspect and validate
                                  the configuration.
  --cache / --no-cache            Use LLM cache.
                                  \[default: cache]
  --skip-validation               Skip any preflight
                                  validation. Useful when
                                  running no LLM steps.
  -o, --output PATH               Indexing pipeline
                                  output directory.
                                  Overrides
                                  output.base_dir in the
                                  configuration file.
  --help                          Show this message and

init

Generate a default configuration file.

Usage:

 init [OPTIONS]

Options:

  -r, --root PATH  The project root directory.
                   \[default: .]
  -f, --force      Force initialization even if the
                   project already exists.

prompt-tune

Generate custom graphrag prompts with your own data (i.e. auto templating).

Usage:

 prompt-tune [OPTIONS]

Options:

  -r, --root PATH                 The project root
                                  directory.  \[default:
                                  .]
  -c, --config PATH               The configuration to
                                  use.
  -v, --verbose                   Run the prompt tuning
                                  pipeline with verbose
                                  logging.
  --domain TEXT                   The domain your input
                                  data is related to. For
                                  example 'space
                                  science',
                                  'microbiology',
                                  'environmental news'.
                                  If not defined, a
                                  domain will be inferred
                                  from the input data.
  --selection-method [all|random|top|auto]
                                  The text chunk
                                  selection method.
                                  \[default: random]
  --n-subset-max INTEGER          The number of text
                                  chunks to embed when
                                  --selection-
                                  method=auto.
                                  \[default: 300]
  --k INTEGER                     The maximum number of
                                  documents to select
                                  from each centroid when
                                  --selection-
                                  method=auto.
                                  \[default: 15]
  --limit INTEGER                 The number of documents
                                  to load when
                                  --selection-
                                  method={random,top}.
                                  \[default: 15]
  --max-tokens INTEGER            The max token count for
                                  prompt generation.
                                  \[default: 2000]
  --min-examples-required INTEGER
                                  The minimum number of
                                  examples to
                                  generate/include in the
                                  entity extraction
                                  prompt.  \[default: 2]
  --chunk-size INTEGER            The size of each
                                  example text chunk.
                                  Overrides chunks.size
                                  in the configuration
                                  file.  \[default: 1200]
  --overlap INTEGER               The overlap size for
                                  chunking documents.
                                  Overrides
                                  chunks.overlap in the
                                  configuration file.
                                  \[default: 100]
  --language TEXT                 The primary language
                                  used for inputs and
                                  outputs in graphrag
                                  prompts.
  --discover-entity-types / --no-discover-entity-types
                                  Discover and extract
                                  unspecified entity
                                  types.  \[default:
                                  discover-entity-types]
  -o, --output PATH               The directory to save
                                  prompts to, relative to
                                  the project root
                                  directory.  \[default:
                                  prompts]
  --help                          Show this message and

query

Query a knowledge graph index.

Usage:

 query [OPTIONS]

Options:

  -m, --method [local|global|drift|basic]
                                  The query algorithm to
                                  use.  \[required]
  -q, --query TEXT                The query to execute.
                                  \[required]
  -c, --config PATH               The configuration to
                                  use.
  -v, --verbose                   Run the query with
                                  verbose logging.
  -d, --data PATH                 Index output directory
                                  (contains the parquet
                                  files).
  -r, --root PATH                 The project root
                                  directory.  \[default:
                                  .]
  --community-level INTEGER       Leiden hierarchy level
                                  from which to load
                                  community reports.
                                  Higher values represent
                                  smaller communities.
                                  \[default: 2]
  --dynamic-community-selection / --no-dynamic-selection
                                  Use global search with
                                  dynamic community
                                  selection.  \[default:
                                  no-dynamic-selection]
  --response-type TEXT            Free-form description
                                  of the desired response
                                  format (e.g. 'Single
                                  Sentence', 'List of 3-7
                                  Points', etc.).
                                  \[default: Multiple
                                  Paragraphs]
  --streaming / --no-streaming    Print the response in a
                                  streaming manner.
                                  \[default: no-
                                  streaming]
  --help                          Show this message and

update

Update an existing knowledge graph index.

Applies a default output configuration (if not provided by config), saving the new index to the local file system in the update_output folder.

Usage:

 update [OPTIONS]

Options:

  -c, --config PATH               The configuration to
                                  use.
  -r, --root PATH                 The project root
                                  directory.  \[default:
                                  .]
  -m, --method [standard|fast|standard-update|fast-update]
                                  The indexing method to
                                  use.  \[default:
                                  standard]
  -v, --verbose                   Run the indexing
                                  pipeline with verbose
                                  logging.
  --memprofile                    Run the indexing
                                  pipeline with memory
                                  profiling.
  --cache / --no-cache            Use LLM cache.
                                  \[default: cache]
  --skip-validation               Skip any preflight
                                  validation. Useful when
                                  running no LLM steps.
  -o, --output PATH               Indexing pipeline
                                  output directory.
                                  Overrides
                                  output.base_dir in the
                                  configuration file.
  --help                          Show this message and