CLI 参考
此页面记录了 graphrag 库的命令行界面。
graphrag
GraphRAG:一种基于图的检索增强生成(RAG)系统。
用法
选项
--install-completion Install completion for the current shell.
--show-completion Show completion for the current shell, to copy it or
customize the installation.
索引
构建知识图谱索引。
用法
选项
-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.
初始化
生成默认配置文件。
用法
选项
-r, --root PATH The project root directory. \[default: .]
-f, --force Force initialization even if the project already exists.
提示词调优
使用您自己的数据生成自定义 graphrag 提示词(即自动模板化)。
用法
选项
-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]
query
查询知识图谱索引。
用法
选项
-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]
更新
更新现有知识图谱索引。
应用默认输出配置(如果配置未提供),将新索引保存到本地文件系统中的 update_output 文件夹。
用法
选项
-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.