Skip to main content

Knowledge Compilation Runtime Configuration

Knowledge compilation runtime parameters can be configured with environment variables. In the Docker deployment, set them in docker/.env and restart the RAGFlow service for the changes to take effect.

The values below are the defaults. If an environment variable is not set, its default value is used. Invalid values are replaced with the default value. Values below a configured minimum or above a configured maximum are clamped to the valid range and logged.

Wiki Configuration

Environment variableDefaultDescription
WIKI_MAP_LLM_POOL_SIZE20Maximum number of concurrent LLM calls allowed by the Wiki task's shared LLM pool.
WIKI_MAP_MAX_PENDING25Maximum number of active and waiting calls admitted by the Wiki LLM pool. The effective value is never lower than WIKI_MAP_LLM_POOL_SIZE.
WIKI_REFINE_WORKERS4Number of page-refinement workers. Actual LLM concurrency is still limited by the shared pool.
WIKI_MAP_WORKERS20Default worker count used by direct Wiki MAP calls.
WIKI_MAP_TIMEOUT600 secondsTimeout for one Wiki MAP extraction call.
WIKI_REDUCE_TIMEOUT60 secondsTimeout for one Wiki REDUCE disambiguation call.
WIKI_PLAN_TIMEOUT600 secondsTimeout for Wiki PLAN calls, including page planning and MAYBE resolution.
WIKI_REFINE_TIMEOUT300 secondsTimeout for one Wiki page-writing call.
WIKI_MERGE_TIMEOUT600 secondsTimeout for merging an existing Wiki page with newly generated content.

WIKI_MAP_LLM_POOL_SIZE is a hard ceiling for the task. The pool can reduce the effective concurrency for a model after rate limiting, so setting this value does not force every provider to receive that many concurrent requests.

Structure Compile Configuration

Environment variableDefaultDescription
DOC_STRUCTURE_LLM_POOL_SIZE20Maximum number of concurrent LLM calls for a document Structure Compile task.
DOC_STRUCTURE_COMPILE_MAX_IN_FLIGHT15Maximum number of structure batch/template operations in flight.
DOC_STRUCTURE_COMPILE_BATCH_CHUNKS4Number of source chunks passed to one outer Structure Compile batch.
STRUCTURE_CONTEXT_FRACTION0.5Fraction of the model context window used when packing structure batches, clamped to (0, 1].
STRUCTURE_DEFAULT_CONTEXT100000 tokensFallback model context size when the model does not provide one.
KNOWLEDGE_GRAPH_CONTEXT_FRACTION0.1Fraction of the model context window used for Knowledge Graph batches, clamped to (0, 1].
KNOWLEDGE_GRAPH_MIN_BATCH_TOKENS2048 tokensMinimum Knowledge Graph batch size.
KNOWLEDGE_GRAPH_MAX_BATCH_TOKENS4096 tokensMaximum Knowledge Graph batch size. The effective value is never lower than KNOWLEDGE_GRAPH_MIN_BATCH_TOKENS.
STRUCTURE_CHAIN_CORRECTION_TIMEOUT_S120 secondsTime limit for the Structure Compile chain-correction LLM step.

The regular Structure Compile entity/relation extraction path does not define an independent application-level timeout. Its request timeout is determined by the configured LLM provider/client.

LLM Pool Rate-Limit Handling

These variables apply to the shared adaptive LLM pool:

Environment variableDefaultDescription
LLM_POOL_RATE_LIMIT_RETRIES3Number of retries after a rate-limit response.
LLM_POOL_RATE_LIMIT_RETRY_BASE_DELAY1.0 secondInitial delay used by exponential backoff.
LLM_POOL_RATE_LIMIT_RETRY_MAX_DELAY30.0 secondsMaximum delay between rate-limit retries.

After a rate-limit response, the pool lowers the effective concurrency for the affected model and retries the request. Successful calls gradually restore the model's concurrency up to the configured pool limit.

The pool normalizes max_pending to at least the configured pool size, and normalizes the retry maximum delay to at least the retry base delay.

When all retries are exhausted, the backend records the detailed failure in its service log and the frontend task log receives only the stage, context, and error type. Provider response bodies are not forwarded to the frontend.

Example

The following configuration lowers concurrency for providers with a smaller request limit and shortens the Wiki MAP timeout:

WIKI_MAP_LLM_POOL_SIZE=8
WIKI_MAP_MAX_PENDING=10
DOC_STRUCTURE_LLM_POOL_SIZE=8
LLM_POOL_RATE_LIMIT_RETRIES=5
WIKI_MAP_TIMEOUT=300

Restart the RAGFlow backend after changing docker/.env. The settings are read when the Python modules are loaded and are not changed for already-running tasks.