-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy pathenv.example
More file actions
1588 lines (1464 loc) · 82.1 KB
/
Copy pathenv.example
File metadata and controls
1588 lines (1464 loc) · 82.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### All configurable environment variable must show up in this sample file in active or comment out status
### Setup tool `make env-*` uses this file to generate final .env file
### Target environment of this env file: host/compose (compose is for Docker or Kubernetes)
# LIGHTRAG_RUNTIME_TARGET=host
###########################
### Server Configuration
###########################
### HOST binds to all network interfaces (0.0.0.0) by default.
### SECURITY: only expose 0.0.0.0 together with LIGHTRAG_API_KEY or AUTH_ACCOUNTS
### (see "Login and API-Key Configuration" below). Without authentication, a
### server on 0.0.0.0 grants anyone on the network full access to your documents
### and knowledge graph. Bind to 127.0.0.1 for local-only access.
HOST=0.0.0.0
PORT=9621
WEBUI_TITLE='My Graph KB'
WEBUI_DESCRIPTION='Simple and Fast Graph Based RAG System'
# WORKERS=2
### gunicorn worker timeout(as default LLM request timeout if LLM_TIMEOUT is not set)
# TIMEOUT=150
### CORS allowed origins for browser cross-origin requests. Defaults to "*"
### (any origin). The bundled WebUI is served same-origin and does not need
### this; set an explicit allowlist only when a different-origin web app calls
### the API from a browser. Credentialed (cookie) cross-origin requests are
### only enabled for an explicit allowlist, never for the "*" wildcard.
# CORS_ORIGINS=http://localhost:3000,http://localhost:8080
### Interactive API documentation (Swagger UI /docs, ReDoc /redoc and the
### /openapi.json schema). Set to false to disable all of them (each returns
### 404) — recommended for hardened production deployments. The WebUI hides
### its API-docs entry point automatically based on /health.
# ENABLE_API_DOCS=true
### Path Prefix Configuration (Optional)
### Used to host multiple LightRAG instances on one host behind a reverse
### proxy that routes by site prefix. Leave unset (or empty) for a
### single-instance deployment.
###
### - LIGHTRAG_API_PREFIX : reverse-proxy prefix the upstream proxy strips
### before forwarding (passed to FastAPI as root_path).
###
### See docs/MultiSiteDeployment.md for end-to-end examples.
# LIGHTRAG_API_PREFIX=/site01
### Optional SSL Configuration
### Docker note: generated compose files mount staged certs at /app/data/certs/ inside the container
# SSL=true
# SSL_CERTFILE=/path/to/cert.pem
# SSL_KEYFILE=/path/to/key.pem
### Directory Configuration (defaults to current working directory)
### Default value is: ./inputs ./rag_storage
# INPUT_DIR=<absolute_path_for_doc_input_dir>
# WORKING_DIR=<absolute_path_for_working_dir>
### Tiktoken cache directory (Store cached files in this folder for offline deployment)
# TIKTOKEN_CACHE_DIR=/app/data/tiktoken
### Ollama Emulating Model and Tag
# OLLAMA_EMULATING_MODEL_NAME=lightrag
OLLAMA_EMULATING_MODEL_TAG=latest
### Max nodes for graph retrieval (Ensure WebUI local settings are also updated, which is limited to this value)
# MAX_GRAPH_NODES=1000
### Logging level
# LOG_LEVEL=INFO
# VERBOSE=False
# LOG_MAX_BYTES=10485760
# LOG_BACKUP_COUNT=5
### Logfile location (defaults to current working directory)
# LOG_DIR=/path/to/log/directory
# LIGHTRAG_PERFORMANCE_TIMING_LOGS=false
#####################################
### Login and API-Key Configuration
#####################################
### SECURITY: If neither AUTH_ACCOUNTS nor LIGHTRAG_API_KEY is set, the server
### runs with NO authentication and every endpoint is publicly accessible.
### This is only safe on a loopback bind (HOST=127.0.0.1). Before exposing the
### server to a network (HOST=0.0.0.0), configure at least one of the two below.
### NOTE: AUTH_ACCOUNTS additionally requires TOKEN_SECRET to be set to a
### non-default value, otherwise the server refuses to start.
### NOTE: even with authentication enabled, the default WHITELIST_PATHS below
### exempts /api/* so the Ollama-compatible endpoints (/api/chat, /api/generate,
### ...) stay open by default, matching Ollama's own unauthenticated behavior.
### Those routes invoke the LLM and read your knowledge base, so if you expose
### the server to a network and want them protected, set WHITELIST_PATHS=/health
### (and have your Ollama clients send the API key). See WHITELIST_PATHS below.
# AUTH_ACCOUNTS='admin:admin123,user1:{bcrypt}$2b$12$S8Yu.gCbuAbNTJFB.231gegTwr5pgrFxc8H9kXQ4/sduFBHkhM8Ka'
# TOKEN_SECRET=lightrag-jwt-default-secret-key!
# JWT_ALGORITHM=HS256
# TOKEN_EXPIRE_HOURS=48
# GUEST_TOKEN_EXPIRE_HOURS=24
### Login brute-force protection (POST /login).
### After LOGIN_MAX_FAILED_ATTEMPTS failed attempts from the same client IP for
### the same username within LOGIN_LOCKOUT_WINDOW_SECONDS, further attempts are
### rejected with HTTP 429 until the window passes; a successful login resets it.
### Set LOGIN_MAX_FAILED_ATTEMPTS=0 to disable. Counters are per server process
### (in-memory): under gunicorn with N workers the effective limit is N x the
### value below; use a reverse-proxy / WAF rate limit for strict enforcement.
# LOGIN_MAX_FAILED_ATTEMPTS=5
# LOGIN_LOCKOUT_WINDOW_SECONDS=300
### Token Auto-Renewal Configuration (Sliding Window Expiration)
### Enable automatic token renewal to prevent active users from being logged out
### When enabled, tokens will be automatically renewed when remaining time < threshold
# TOKEN_AUTO_RENEW=true
### Token renewal threshold (0.0 - 1.0)
### Renew token when remaining time < (total time * threshold)
### Default: 0.5 (renew when 50% time remaining)
### Examples:
### 0.5 = renew when 24h token has 12h left
### 0.25 = renew when 24h token has 6h left
# TOKEN_RENEW_THRESHOLD=0.5
### Note: Token renewal is automatically skipped for certain endpoints:
### - /health: Health check endpoint (no authentication required)
### - /documents/paginated: Frequently polled by client (5-30s interval)
### - /documents/pipeline_status: Very frequently polled by client (2s interval)
### - Rate limit: Minimum 60 seconds between renewals for same user
### API-Key to access LightRAG Server API
### Use this key in HTTP requests with the 'X-API-Key' header
### Example: curl -H "X-API-Key: your-secure-api-key-here" http://localhost:9621/query
# LIGHTRAG_API_KEY=your-secure-api-key-here
### WHITELIST_PATHS: paths exempt from authentication. A /* suffix matches on
### path-segment boundaries, so /api/* covers /api and everything under /api/
### (it does NOT match a sibling like /apikeys).
### Entries are internal route paths and must NOT include LIGHTRAG_API_PREFIX:
### the mount prefix is removed before matching, so /health here exempts
### /site01/health as the browser sees it (see docs/MultiSiteDeployment.md).
### Default keeps /api/* open for Ollama-client compatibility (Ollama is
### unauthenticated by default). To require auth on the Ollama routes too when
### the server is network-exposed, narrow this to /health.
### NOTE: /health stays whitelisted as a liveness probe, but it no longer leaks
### configuration to unauthenticated callers: anonymous requests get only
### liveness signals (status/versions/auth_mode/pipeline_busy), while the full
### runtime configuration is returned only to authenticated callers (valid JWT
### or X-API-Key).
# WHITELIST_PATHS=/health,/api/*
######################################################################################
### Query Configuration
###
### How to control the context length sent to LLM:
### MAX_ENTITY_TOKENS + MAX_RELATION_TOKENS < MAX_TOTAL_TOKENS
### Chunk_Tokens = MAX_TOTAL_TOKENS - Actual_Entity_Tokens - Actual_Relation_Tokens
######################################################################################
# LLM response cache for query (default=true,permanently disabled for streaming response)
ENABLE_LLM_CACHE=false
# COSINE_THRESHOLD=0.2
### Number of entities or relations retrieved from KG
# TOP_K=40
### Maximum number or chunks for naive vector search
# CHUNK_TOP_K=20
### control the actual entities send to LLM
# MAX_ENTITY_TOKENS=6000
### control the actual relations send to LLM
# MAX_RELATION_TOKENS=8000
### control the maximum tokens send to LLM (include entities, relations and chunks)
# MAX_TOTAL_TOKENS=30000
### chunk selection strategies
### VECTOR: Pick KG chunks by vector similarity, delivered chunks to the LLM aligning more closely with naive retrieval
### WEIGHT: Pick KG chunks by entity and chunk weight, delivered more solely KG related chunks to the LLM
### If reranking is enabled, the impact of chunk selection strategies will be diminished.
# KG_CHUNK_PICK_METHOD=VECTOR
### maximum number of related chunks per source entity or relation
### The chunk picker uses this value to determine the total number of chunks selected from KG(knowledge graph)
### Higher values increase re-ranking time
# RELATED_CHUNK_NUMBER=5
### Append each chunk's heading path (parent headings joined by " → ") as a
### `content_headings` field in the chunk JSON sent to the LLM. Costs extra tokens.
ENABLE_CONTENT_HEADINGS=true
#########################################################
### Reranking configuration
### RERANK_BINDING type: null, cohere, jina, aliyun
### For rerank model deployed by vLLM use cohere binding
### If LightRAG deployed in Docker:
### uses host.docker.internal instead of localhost in RERANK_BINDING_HOST
#########################################################
RERANK_BINDING=null
# RERANK_MODEL=BAAI/bge-reranker-v2-m3
# RERANK_BINDING_HOST=http://localhost:8000/rerank
# RERANK_BINDING_API_KEY=your_rerank_api_key_here
### rerank score chunk filter(set to 0.0 to keep all chunks, 0.6 or above if LLM is not strong enough)
# MIN_RERANK_SCORE=0.0
### Enable rerank by default in query params when RERANK_BINDING is not null
# RERANK_BY_DEFAULT=True
### Rerank concurrency and timeout (independent from base LLM settings)
### MAX_ASYNC_RERANK falls back to MAX_ASYNC_LLM when unset.
### RERANK_TIMEOUT has its own default (30s) since reranker calls are
### typically much shorter than full LLM generation.
# MAX_ASYNC_RERANK=4
# RERANK_TIMEOUT=30
### Cohere AI
# # RERANK_MODEL=rerank-v3.5
# # RERANK_BINDING_HOST=https://api.cohere.com/v2/rerank
# # RERANK_BINDING_API_KEY=your_rerank_api_key_here
### Cohere rerank chunking configuration (useful for models with token limits like ColBERT)
### RERANK_MAX_TOKENS_PER_DOC must be an integer >= 1; the server refuses to start otherwise.
### Defaults to 4096 (Cohere rerank-v3.5) when unset; 480 shown below suits 512-token models.
# RERANK_ENABLE_CHUNKING=true
# RERANK_MAX_TOKENS_PER_DOC=480
### Aliyun Dashscope (gte-rerank-*, qwen3-vl-rerank) — nested input/parameters format
# # RERANK_BINDING=aliyun
# # RERANK_MODEL=gte-rerank-v2
# # RERANK_BINDING_HOST=https://dashscope.aliyuncs.com/api/v1/services/rerank/text-rerank/text-rerank
# # RERANK_BINDING_API_KEY=your_rerank_api_key_here
### Aliyun Dashscope qwen3-rerank series — flat (Cohere-style) payload format
### The qwen3-rerank models expect a flat body {"model", "query", "documents", "top_n", ...}
### and return top-level "results", identical to the standard Cohere format. They are also served
### from a DIFFERENT, Cohere-compatible endpoint (/compatible-api/v1/reranks) — NOT the
### .../text-rerank/text-rerank path used by gte-rerank-*/qwen3-vl-rerank above.
### So use RERANK_BINDING=cohere (NOT aliyun) and point RERANK_BINDING_HOST at that endpoint.
### Replace {WorkspaceId} and the region with your own; see the Aliyun Text Rerank API docs:
### https://help.aliyun.com/zh/model-studio/text-rerank-api
# # RERANK_BINDING=cohere
# # RERANK_MODEL=qwen3-rerank
# # RERANK_BINDING_HOST=https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-api/v1/reranks
# # RERANK_BINDING_API_KEY=your_rerank_api_key_here
### Jina AI
# # RERANK_MODEL=jina-reranker-v2-base-multilingual
# # RERANK_BINDING_HOST=https://api.jina.ai/v1/rerank
# # RERANK_BINDING_API_KEY=your_rerank_api_key_here
### For local deployment Embedding and Reranker with vLLM (OpenAI-compatible API)
### Wizard metadata used to preserve the chosen deployment provider across setup reruns
# LIGHTRAG_SETUP_EMBEDDING_PROVIDER=vllm
# LIGHTRAG_SETUP_RERANK_PROVIDER=vllm
# VLLM_EMBED_MODEL=BAAI/bge-m3
# VLLM_EMBED_PORT=8001
# VLLM_EMBED_DEVICE=cpu
### VLLM_EMBED_API_KEY is passed as --api-key to vLLM; synced to EMBEDDING_BINDING_API_KEY; auto-generated if blank
# VLLM_EMBED_API_KEY=
# VLLM_EMBED_EXTRA_ARGS=
# VLLM_RERANK_MODEL=BAAI/bge-reranker-v2-m3
# VLLM_RERANK_PORT=8000
# VLLM_RERANK_DEVICE=cuda
### VLLM_RERANK_API_KEY is passed as --api-key to vLLM; synced to RERANK_BINDING_API_KEY; auto-generated if blank
# VLLM_RERANK_API_KEY=
### Use float16 for GPU mode. CPU mode uses the official vLLM CPU image.
# VLLM_USE_CPU=1
### Set to 1 for CPU mode, unset for GPU mode
# CUDA_VISIBLE_DEVICES=-1
### Set to -1 to disable CUDA (CPU mode), or specific GPU IDs for GPU mode
# NVIDIA_VISIBLE_DEVICES=0
### Optional Docker runtime equivalent; generated GPU compose honors either variable.
# VLLM_RERANK_EXTRA_ARGS=
########################################
### Document processing configuration
########################################
### Document processing output language: English, Chinese, French, German ...
SUMMARY_LANGUAGE=English
### Enable JSON-structured output for entity extraction
### Default behavior: JSON output is disabled when ENTITY_EXTRACTION_USE_JSON is unset
### JSON output incurs higher latency but delivers improved reliability
ENTITY_EXTRACTION_USE_JSON=true
### Optional external YAML profile for entity type guidance and extraction examples
### Profiles are loaded from PROMPT_DIR/entity_type (PROMPT_DIR defaults to ./prompts).
### A reference template is shipped at prompts/samples/entity_type_prompt.sample.yml;
# ENTITY_TYPE_PROMPT_FILE=entity_type_prompt.yml
# PROMPT_DIR=<absolute_path_for_prompt_dir>
### Multimodal parsing/analyze integration
### Optional parser routing rules. Example for VLM & MinerU enabled configuration:
### LIGHTRAG_PARSER=*:native-iteP(drop_rf),xlsx:legacy-R,*:mineru-iteP(drop_rf),*:legacy-R
### Rules are separated with semicolons ';' or commas ',';
### Rules match file suffixes (pdf) are checked left-to-right.
### If mineru/docling appears in LIGHTRAG_PARSER, the corresponding endpoint
### below must be configured before server startup.
###
### Per-strategy chunk parameters may be attached in parentheses to a chunk
### selector (F/R/V/P/C). Inside the parentheses a comma only separates parameters.
### Supported parameters (alias in brackets):
### chunk_token_size [chunk_ts] F/R/V/P/C e.g. R(chunk_ts=800)
### chunk_overlap_token_size [chunk_ol] F/R/P/C (V has no overlap)
### LIGHTRAG_PARSER=pdf:legacy-R(chunk_ts=800,chunk_ol=80);*:legacy-R
### The same syntax works in a filename hint, e.g. notes.[-R(chunk_ts=800)].md
### Boolean parameters may be written bare as a flag, on a chunk selector as
### well as on an engine token: P(drop_rf) means drop_rf=true, and
### docx:native(smart_heading) means native(smart_heading=true).
### See docs/FileProcessingPipeline.md for detail
LIGHTRAG_PARSER=*:native-teP,*:legacy-R
### Decompression budget for the native DOCX engine (advanced). A .docx is a
### ZIP, so what parsing costs is its UNCOMPRESSED size — MAX_UPLOAD_SIZE
### bounds the compressed file on disk and MAX_REQUEST_BODY_BYTES bounds the
### request body, so neither of them bounds this. Both quantities are read
### from the ZIP central directory before anything is decompressed; a .docx
### over either limit is rejected and the document is recorded FAILED.
### The same budget also bounds the legacy engine's .pptx and .xlsx (both are
### the identical OPC/ZIP bomb class), enforced before those parse locally.
### The ratio gate is applied archive-wide and to the cumulative expansion by
### which individual members exceed their own ratio budgets, so member
### splitting cannot dilute it. That excess receives a fixed
### DOCX_RATIO_FLOOR_BYTES allowance plus a 1:1 allowance for archive bytes
### outside those members. This permits repetitive XML backed by real stored
### media without letting padding buy another ratio-cap multiple. Raise the
### three gates
### (DOCX_MAX_UNCOMPRESSED_BYTES / DOCX_MAX_COMPRESSION_RATIO / DOCX_MAX_ENTRIES)
### only if a legitimate document is being refused; a non-positive value
### disables that gate. DOCX_RATIO_FLOOR_BYTES is the opposite — it is the
### small-file EXEMPTION threshold, so a non-positive value does NOT disable
### the ratio gate, it removes the exemption and makes the ratio gate strictest.
# DOCX_MAX_UNCOMPRESSED_BYTES=536870912
# DOCX_MAX_COMPRESSION_RATIO=100
# DOCX_RATIO_FLOOR_BYTES=16777216
# DOCX_MAX_ENTRIES=10000
### Native DOCX embedded-image export budgets. Images are copied from the
### archive in 1 MiB chunks, with a 25 MiB ceiling for one image and a 64 MiB
### cumulative ceiling for one document. An over-budget image is skipped with
### a parse warning; document text continues. Defaults are sized against the
### five native parse workers so attacker-controlled output remains bounded.
### Raise these only when retaining unusually large embedded images matters
### more than the memory/disk ceiling. A zero or negative value is NOT
### unlimited; it falls back to the safe default.
# NATIVE_DOCX_IMAGE_MAX_BYTES=26214400
# NATIVE_DOCX_IMAGE_MAX_TOTAL_BYTES=67108864
### Zip-bomb budget for the result BUNDLE an external parser engine (docling,
### mineru) returns — a zip fetched from the configured server and extracted
### locally. Defense-in-depth against a compromised/misbehaving endpoint. The
### bundle size scales with your source document and the engine's rendering
### settings, so raise (or disable) these if a legitimate result is refused.
### A non-positive value disables that gate. Both are read live per parse.
# PARSER_RESULT_BUNDLE_MAX_ENTRIES=10000
# PARSER_RESULT_BUNDLE_MAX_TOTAL_BYTES=536870912
### Overall wall-clock budget (seconds) for downloading that result bundle,
### on top of the per-read timeout each client already sets. A per-read
### timeout only bounds a single socket operation, so a peer trickling one
### byte per interval can reset it indefinitely; this bounds the whole
### download regardless of how it stalls. A non-positive value disables the
### deadline. Read live per parse.
# PARSER_RESULT_BUNDLE_DOWNLOAD_TIMEOUT=300
### Cap on the raw response bytes received while streaming that download,
### checked before the bytes ever reach the zip-bomb checks above. Separate
### from PARSER_RESULT_BUNDLE_MAX_TOTAL_BYTES: that one bounds the
### *uncompressed* size a zip declares, this bounds the *compressed* bytes
### actually transferred — tune independently. A non-positive value
### disables this gate. Read live per parse.
# PARSER_RESULT_BUNDLE_DOWNLOAD_MAX_BYTES=536870912
### Global default for the native docx smart_heading engine parameter.
### When true, .docx files routed to the native engine get smart_heading
### enabled without per-file declaration; opt out per file/rule with an
### explicit native(smart_heading=false). Enabling this (or carrying
### native(smart_heading=true) in a LIGHTRAG_PARSER rule) makes the server
### verify the pinned spaCy models at startup and fail fast if missing
### (install: lightrag-download-cache --spacy-install; the main
### Docker image ships them). Applies to new uploads only — already-ingested
### documents keep their persisted engine parameters on re-parse.
# DOCX_SMART_HEADING=true
### smart_heading tuning (advanced). These apply only when smart_heading is
### active (DOCX_SMART_HEADING above, or a per-file/rule opt-in). The defaults
### suit most documents — the values shown ARE the defaults; uncomment to change.
### Skip smart_heading for WHOLE documents shorter than this many tokens; they
### keep the plain outline-based headings. Kept below CHUNK_P_SIZE (2000): a
### document that fits inside one paragraph-chunk needs no heading splitting.
### Lower it to run the extra analysis on short documents (e.g. 红头 notices).
# DOCX_SMART_MIN_TOKENS=1800
### Once a document clears the gate above, a single SUB-document shorter than
### this many tokens falls back to outline-only levels instead of size-based
### leveling. Defaults to min(1000, DOCX_SMART_MIN_TOKENS): lowering the
### whole-document gate to run smart on short documents also pulls this floor
### down, so their sub-documents are not silently left on outline-only. Set it
### explicitly to override (e.g. level only big sections of a long document).
# DOCX_SMART_SUBDOC_MIN_TOKENS=1000
### Heading-detection sensitivity. The engine drops a line from the heading set
### when it looks like body text; these tune how strict that is.
### DENSITY_MAX largest share of paragraphs allowed to be headings
### (0-1) before the engine decides it over-detected
### and recomputes the body font size.
### DENSITY_BASELINE_MARGIN for a document with a rich built-in outline, the
### ceiling rises by this much above the document's own
### outline ratio (percentage points).
### MIN_INTER_HEADING_CHARS fewest body characters expected between two adjacent
### headings (a Chinese char counts as 3); a denser run
### also triggers the recompute.
### HEADING_MAX_CHARS a line longer than this (Chinese char = 3) is body,
### never a heading. Also caps the merged main+sub doc
### title. FATAL if non-integer or < 3 (too small to
### hold the "..." truncation marker): startup and
### parsing both reject it; a value below the title-line
### width (90) is accepted but warns (most headings
### would be demoted to body).
### Raise the ceiling / lower the minimums if real headings are being dropped;
### do the reverse if body text is leaking in as headings.
# DOCX_SMART_DENSITY_MAX=0.40
# DOCX_SMART_DENSITY_BASELINE_MARGIN=0.10
# DOCX_SMART_MIN_INTER_HEADING_CHARS=200
# DOCX_SMART_HEADING_MAX_CHARS=180
### Table of contents (TOC) retention. A detected TOC keeps its first N visible
### lines as body text (so a 目录 heading is not orphaned from its entries) and
### collapses the remainder to a single "……". Counted globally by visible line
### (a soft-break line counts as one). 0 keeps none (one "……" replaces the whole
### TOC); a negative value is treated as 0; a very large value keeps it all.
# DOCX_SMART_TOC_KEEP_LINES=5
### Lines starting with one of these words (followed by a number) are figure /
### table captions, never headings. Comma-separated; localize for your corpus.
# DOCX_SMART_CAPTION_PREFIXES=图,表,公式,Figure,Table,Fig.,Eq.,Chart
### 公文版记 (imprint) ANCHORS — openers like 抄送:/ 主题词:(colon class) start a
### 版记 region: they are body, never headings, and veto title-block membership
### for themselves and the 2 preceding non-blank paragraphs. An anchor may also
### be middle content of another anchor's region (主题词 then 抄送). Comma-
### separated; localize for your corpus.
# DOCX_SMART_IMPRINT_COLON_PREFIXES=抄送,主题词
### 版记 region CLOSERS (印发-family — the issuing-organ / print line that ENDS a
### 版记), recognized ONLY within FORWARD_PARAS non-blank paragraphs after an
### anchor above (so a body line ending in 印发 cannot false-fire alone). Prefix
### form: 印发:XX / 印发 XX / 印发机关 XX (印发机关 is a closer, not an anchor — the
### old DOCX_SMART_IMPRINT_SPACE_PREFIXES knob is gone); trailing form: a line
### ENDING with 印发 (某某办公室 2026年6月30日 印发, the GB/T layout). A found 抄送…印发
### span (middle lines included) is barred from title blocks; when a valid title
### block immediately follows it (a 公文汇编 boundary), the span is force-demoted
### to body. Comma-separated; localize for your corpus.
# DOCX_SMART_IMPRINT_CLOSER_PREFIXES=印发,印发机关
# DOCX_SMART_IMPRINT_CLOSER_TRAILING=印发
# DOCX_SMART_IMPRINT_FORWARD_PARAS=3
### Document-title detection and its LLM cost. Only the first eligible paragraph
### can be a single-line title candidate; it must be at least this many points
### larger than the body font. The LLM input remains bounded by a token window.
# DOCX_SMART_TITLE_BLOCK_MIN_DELTA=2.0
# DOCX_SMART_LLM_WINDOW_TOKENS=1000
### Mid-document title-window gate: a multi/table window may open freely only
### in the document head zone — fewer than this many content records before it
### AND before the first body signal (a sentence-punctuated paragraph, a real
### outline/numbered heading, or a data table that cannot be cover material).
### Past the zone it needs a 版记 tail or 附件 marker as boundary evidence.
# DOCX_SMART_TITLE_HEAD_ZONE_RECORDS=8
### Further DOCX_SMART_* thresholds exist (circuit-breaker ratios, confidence
### ratio, numbering sequence break, TOC detection minimum). They are algorithm
### internals rather than a supported tuning surface: see lightrag/constants.py
### for their names and defaults, and prefer reporting a misclassification over
### tuning them.
### Native Markdown (.md / .textpack) remote image handling
### External http(s) images in markdown are downloaded and embedded into the
### sidecar assets by default (SSRF-guarded: private/loopback/link-local hosts
### are refused; the socket is pinned to the validated IP so a DNS rebind cannot
### redirect it to an internal host, and any ambient HTTP(S)_PROXY is ignored).
### Set ENABLED=false to instead DROP external images (no sidecar entry), in
### which case a doc whose only images are external links produces no drawings.json.
NATIVE_MD_IMAGE_DOWNLOAD_ENABLED=true
### When downloading is enabled, REQUIRED=true fails the document on a download
### error; false (default) keeps the image as an external link and warns.
### (Base64 and .textpack file-reference images are always embedded regardless
### of this switch; SVG images are rasterized to PNG via cairosvg.)
# NATIVE_MD_IMAGE_DOWNLOAD_REQUIRED=false
### Wall-clock deadline for ONE image request, covering connect, TLS, headers,
### body and every redirect hop (DNS resolution is the one phase outside it).
# NATIVE_MD_IMAGE_DOWNLOAD_TIMEOUT=30
### Per-image size ceiling: caps a remote download AND a single bundled
### (.textpack) asset, so one oversized image cannot be read into memory.
# NATIVE_MD_IMAGE_MAX_BYTES=26214400
### SVG render budget: an SVG whose declared canvas (width*height or viewBox)
### exceeds this pixel count is skipped BEFORE rasterization
# NATIVE_MD_IMAGE_MAX_SVG_PIXELS=16000000
### Per-DOCUMENT image ceilings. The three above bound ONE image; these bound
### a whole document, and they are what stops a small upload referencing a
### large number of images from exhausting the host.
### Over-budget images do NOT fail the document: a remote one degrades to an
### external link and a base64 / .textpack one is dropped, both with a parse
### warning. DOWNLOAD_REQUIRED=true turns an over-budget REMOTE image into a
### document failure, matching how it treats any other failed download; base64
### and .textpack images are outside that switch, as they always have been.
### 0 or a negative value is NOT "unlimited" — it falls back to the default.
### For effectively unlimited, set a very large number.
###
### Total image bytes RETAINED for one document, across every source (base64,
### .textpack file, download, and cache reuse). This is the memory bound; the
### default is derived from MAX_PARALLEL_PARSE_NATIVE (5), so all parse workers
### together hold at most ~320 MiB of retained image data.
### Live image data peaks a little higher while one image is in flight, since
### assembling a download into one immutable buffer holds the pieces and the
### result together for a moment. The bound on live image ALLOCATIONS is this
### value plus min(MAX_BYTES, this value) — ~89 MiB at the defaults — plus a
### small constant for the read buffer. Lowering MAX_BYTES lowers it. Process
### RSS follows the allocator's high-water mark and can sit above that.
# NATIVE_MD_IMAGE_MAX_TOTAL_BYTES=67108864
### Remote image fetch ATTEMPTS per document. Counts every redirect hop, and
### counts attempts that fail in DNS or the SSRF guard without a packet leaving
### the host, so it is an upper bound on outbound HTTP requests rather than an
### exact count. A `.native_raw/` cache hit issues no request and is not
### counted. Base64 and .textpack file references are not counted either.
# NATIVE_MD_IMAGE_MAX_REQUESTS=100
### Wall-clock budget for ALL image downloads in one document, in seconds
### (DOWNLOAD_TIMEOUT above is per request). Starts at the first download.
### Once spent, the remaining external images degrade to links with no request
### issued. Successful downloads are cached, so a re-parse resumes where the
### previous one stopped rather than starting over.
# NATIVE_MD_IMAGE_DOWNLOAD_TOTAL_TIMEOUT=120
### Escape hatch for the SSRF guard: only globally-routable IPs are allowed by
### default. To permit specific non-public ranges (e.g. an internal image host),
### list comma-separated CIDRs/IPs. Applies to DNS-resolved IPs and redirects.
# NATIVE_MD_IMAGE_ALLOWED_NON_PUBLIC_CIDRS=10.0.0.0/8,192.168.1.5
### Downloaded external images are cached in a `<file>.native_raw/` sidecar dir
### so a re-parse of an unchanged file reuses them instead of re-downloading.
### Set the following env var true to force a re-download (discard the cache)
# LIGHTRAG_FORCE_REPARSE_NATIVE=false
### Async parser service protocol (optional)
### Configure these when using remote MinerU/Docling async services
### ---- MinerU shared parameters (both local and official modes) ----
### MinerU API protocol. Choose one active mode.
### - official: MinerU precision API v4. Requires MINERU_API_TOKEN.
### - local: self-hosted mineru-api / mineru-router base URL.
MINERU_API_MODE=local
# MINERU_POLL_INTERVAL_SECONDS=2
# MINERU_MAX_POLLS=600
# MINERU_LANGUAGE=ch
# MINERU_ENABLE_TABLE=true
# MINERU_ENABLE_FORMULA=true
# MINERU_PAGE_RANGES=
### MINERU_PAGE_RANGES semantics differ by mode:
### - official: forwarded verbatim, supports e.g. "1-3,5,7-9".
### - local: only a single page ("3") or simple range ("1-10"); comma
### lists are rejected at startup.
### When switching modes, double-check this constraint.
### Per-file override: a hint / rule may set page_range on the engine token,
### e.g. notes.[mineru(page_range=1-3,page_range=5)].pdf — inside the parens a
### comma only separates parameters, so a multi-segment list REPEATS the key
### (and requires MINERU_API_MODE=official). Likewise language / local_parse_method.
# MINERU_ADDITIONAL_SUFFIXES=doc,xls,ppt
### MINERU_ADDITIONAL_SUFFIXES: suffixes your MinerU endpoint can handle on top
### of the baseline set (pdf docx pptx xlsx png jpg jpeg jp2 webp gif bmp).
### MinerU converts legacy Office formats through LibreOffice on its own side,
### so which of them work is a property of your deployment, not of LightRAG.
### Format: bare lowercase suffixes separated by ',' — a leading dot and
### surrounding whitespace are tolerated (" .DOC " = doc); anything else
### ('*.doc' written out of glob habit, or a ';'-separated list) is rejected at
### startup rather than silently ignored.
### Semantics differ by mode: this describes the endpoint of the CURRENTLY
### selected MINERU_API_MODE — official coverage is fixed by the service, local
### coverage depends on your container. When switching modes, re-check it.
### NOTE: this only makes a suffix *routable to mineru*; it does not by itself
### make a bare 'x.doc' uploadable. Pair it with a routing rule
### (LIGHTRAG_PARSER=doc:mineru) or a per-file hint (x.[mineru].doc), otherwise
### such files still fall through to the default legacy engine and are rejected
### as unsupported. Conversely, a 'doc:mineru' rule without this variable fails
### startup validation, since doc is not among mineru's capabilities.
### ---- MinerU local-only (MINERU_API_MODE=local) ----
MINERU_LOCAL_ENDPOINT=http://127.0.0.1:8000
### MINERU_LOCAL_BACKEND: which mineru-api backend handles the parse.
### Accepted values (per mineru-api POST /tasks form parameter `backend`):
### hybrid-auto-engine - pipeline + VLM combo with auto-selected local
### engine (mineru-api's default). GPU required.
### pipeline - CPU-friendly traditional pipeline; no VLM step.
### vlm-auto-engine - VLM with auto-selected local inference engine
### (sglang-engine / vllm-engine if GPU is available);
### requires the matching engine extra preinstalled
### on the mineru-api side, plus model weights.
### We ship `hybrid-auto-engine` -- requires the target mineru-api
### deployment to have a GPU plus the matching inference engine
### (sglang / vllm) and model weights installed. Switch to `pipeline`
### for CPU-only deployments without those dependencies.
MINERU_LOCAL_BACKEND=hybrid-auto-engine
### MINERU_LOCAL_PARSE_METHOD: parsing strategy for the pipeline component.
### Accepted values:
### auto - auto-detect embedded text-layer vs OCR per page (default).
### txt - extract text from the embedded text layer only; fastest,
### but yields empty output on scanned PDFs without a text layer.
### ocr - force OCR on every page regardless of text-layer quality;
### slowest, reliable on scanned or low-quality PDFs.
### Only consumed when MINERU_LOCAL_BACKEND is `pipeline` or
### `hybrid-auto-engine` (the pipeline arm of the hybrid pipeline).
### Pure VLM backends (`vlm-auto-engine`, `vlm-http-client`) ignore this
### parameter -- the VLM model handles layout/OCR natively.
MINERU_LOCAL_PARSE_METHOD=auto
### MINERU_LOCAL_IMAGE_ANALYSIS: enable VLM image/chart analysis pass for
### better caption an footnote recognition.
### Only consumed by `vlm-auto-engine`, `vlm-http-client`,
### `hybrid-auto-engine`, `hybrid-http-client`. The `pipeline` backend
### silently drops this flag -- its `_process_pipeline` does not accept
### the kwarg, so setting `false` under pipeline does NOT speed parsing
### up; pipeline never invokes the VLM image pass to begin with.
### Disable (`false`) on VLM / hybrid backends to skip the extra VLM
### round, trading image / chart semantic descriptions for faster parsing
### and lower GPU cost.
MINERU_LOCAL_IMAGE_ANALYSIS=false
# MINERU_LOCAL_START_PAGE_ID=0
# MINERU_LOCAL_END_PAGE_ID=99999
### ---- MinerU official-only (MINERU_API_MODE=official) ----
# MINERU_API_TOKEN=your-api-key
# MINERU_OFFICIAL_ENDPOINT=https://mineru.net
# MINERU_MODEL_VERSION=vlm
# MINERU_IS_OCR=false
### Force re-upload of file to MinerU on every retry after failure
### Disables caching of result outcomes
# LIGHTRAG_FORCE_REPARSE_MINERU=false
### ---- MinerU raw-bundle cache (<base>.mineru_raw/) ----
### Engine version recorded in the bundle manifest; changing it invalidates the
### cache. Leave empty to skip the version check.
# MINERU_ENGINE_VERSION=
### Default coordinate system for MinerU layout boxes, written into the
### sidecar meta. NOTE the default differs from DOCLING_BBOX_ATTRIBUTES.
# MINERU_BBOX_ATTRIBUTES={"origin":"LEFTTOP","max":1000}
### Docling parser (docling-serve v1 / async API).
###
### Endpoint: base URL only — the client appends /v1/convert/file/async,
### /v1/status/poll/{task_id}?wait=<DOCLING_POLL_INTERVAL_SECONDS>,
### /v1/result/{task_id} itself.
### Pipeline shape (pipeline=standard, target_type=zip,
### to_formats=[json,md], image_export_mode=referenced) is fixed in
### code so the sidecar flow stays self-consistent — flipping any of
### these would break the adapter and is therefore not exposed as env.
###
### Optional formats:
### - DOCLING_ADDITIONAL_SUFFIXES: comma-separated suffixes your
### docling-serve deployment can actually handle on top of the baseline
### set (pdf docx pptx xlsx md html xhtml png jpg jpeg tiff webp bmp).
### Docling's legacy Office support (doc/xls/ppt) needs LibreOffice on
### the docling-serve side, so it is opted in per deployment rather than
### advertised globally. Bare lowercase suffixes only — 'doc,ppt,xls',
### not '*.doc' or 'doc;ppt' (the server refuses to start otherwise).
### NOTE: this only makes the suffix *routable to docling*; it does not
### by itself make bare 'x.doc' uploadable. Pair it with a routing rule
### (LIGHTRAG_PARSER=doc:docling) or a per-file hint (x.[docling].doc),
### otherwise such files still fall through to the default legacy engine
### and are rejected as unsupported.
###
### OCR tunables:
### - DOCLING_DO_OCR: master switch; when false the engine relies only on
### text-layer extraction.
### - DOCLING_FORCE_OCR: when true, OCR every page regardless of text-layer
### quality (slower, useful for scanned PDFs with bad text layers).
### - DOCLING_OCR_ENGINE: explicit engine selection (DEPRECATED in the
### docling-serve OpenAPI but still honored for older deployments).
### - DOCLING_OCR_PRESET: recommended replacement for DOCLING_OCR_ENGINE.
### - DOCLING_OCR_LANG: JSON array (e.g. ["en","zh"]) or comma-separated
### list. Empty (default) lets the OCR engine pick its default.
### - DOCLING_DO_FORMULA_ENRICHMENT: when true, the code-formula model runs
### and `texts[*].label="formula"` items carry LaTeX in `text`. Default
### false because the model may not be present on every deployment;
### adapter falls back to plain-text formulas when disabled.
###
### Polling budget (server-side long-poll; client does NOT add extra sleep):
### - DOCLING_POLL_INTERVAL_SECONDS: ``?wait=N`` value sent to
### /v1/status/poll/{task_id}. Larger N = fewer round trips per parse;
### bound by your reverse-proxy idle timeout. Default 5.
### - DOCLING_MAX_POLLS: max polling rounds before raising TimeoutError.
### Worst-case wall-clock budget ≈
### DOCLING_POLL_INTERVAL_SECONDS × DOCLING_MAX_POLLS. Default 240
### (≈ 20 minutes at wait=5s); raise for very large PDFs.
###
### Bundle cache controls:
### - DOCLING_ENGINE_VERSION: recorded in <base>.docling_raw/_manifest.json.
### Mismatch with the recorded value forces a cache miss → re-download.
### Leave empty to skip this check.
### - LIGHTRAG_FORCE_REPARSE_DOCLING: when truthy ("1"/"true"), bypass the
### docling raw cache and re-upload on every parse_docling call.
### - DOCLING_BBOX_ATTRIBUTES: override the doc-level bbox_attributes
### written into <base>.blocks.jsonl meta. Default
### {"origin":"LEFTBOTTOM"} matches docling's default coordinate system.
DOCLING_ENDPOINT=http://localhost:5001
DOCLING_DO_OCR=true
### DOCLING_FORCE_OCR can be overridden per file via a hint / rule on the engine
### token, e.g. scan.[docling(force_ocr=true)].pdf
DOCLING_FORCE_OCR=true
DOCLING_DO_FORMULA_ENRICHMENT=false
# DOCLING_ADDITIONAL_SUFFIXES=doc,ppt,xls
# DOCLING_OCR_ENGINE=auto
# DOCLING_OCR_PRESET=auto
# DOCLING_OCR_LANG=
# DOCLING_POLL_INTERVAL_SECONDS=5
# DOCLING_MAX_POLLS=240
# DOCLING_BBOX_ATTRIBUTES={"origin":"LEFTBOTTOM"}
# DOCLING_ENGINE_VERSION=
### Force re-upload of file to Docling on every retry after failure
### Disables caching of result outcomes
# LIGHTRAG_FORCE_REPARSE_DOCLING=false
### File upload size limit (in bytes)
### Default: 104857600 (100MB)
### Set to 0 or None for unlimited upload size
### Examples:
### 52428800 = 50MB
### 104857600 = 100MB (default)
### 209715200 = 200MB
### Note: If using Nginx as reverse proxy, also configure client_max_body_size
### Note: /documents/upload derives its raw request-body ceiling from this value
### (plus 1 MiB of multipart overhead), so 0/None leaves that route with no
### body ceiling at all and the server warns about it at startup.
# MAX_UPLOAD_SIZE=104857600
### Global chunk size, 500~1500 is recommended.
### Chunker inherits the global value here only when its own var is unset.
### Exception: P never inherits CHUNK_SIZE — it uses CHUNK_P_SIZE (default 2000).
# CHUNK_SIZE=1200
# CHUNK_OVERLAP_SIZE=100
### Overlap (in tokens) borrowed from the previous chunk's tail when the
### embedding hard fallback still has to token-window-split a chunk that
### remains over the embedding model's context limit after chunking.
### Independent of CHUNK_OVERLAP_SIZE above (which some chunker strategies,
### e.g. V, deliberately zero out for unrelated reasons) — 0 disables this
### fallback's overlap; negative values are rejected at startup.
# EMBEDDING_CHUNK_OVERLAP_TOKEN_SIZE=100
### Fixed-token chunker (process_options=F, default) settings
### CHUNK_F_SIZE: per-strategy chunk_token_size override; falls back to CHUNK_SIZE when unset
### CHUNK_F_OVERLAP_SIZE: token overlap; falls back to CHUNK_OVERLAP_SIZE when unset
### CHUNK_F_SPLIT_BY_CHARACTER: optional separator string; pre-segment before token windowing
### CHUNK_F_SPLIT_BY_CHARACTER_ONLY: when true, raise on oversize segment instead of token re-split
# CHUNK_F_SIZE=1200
# CHUNK_F_OVERLAP_SIZE=100
# CHUNK_F_SPLIT_BY_CHARACTER=
# CHUNK_F_SPLIT_BY_CHARACTER_ONLY=false
### Recursive character chunker (process_options=R) settings
### CHUNK_R_SIZE: per-strategy chunk_token_size override; falls back to CHUNK_SIZE when unset
### CHUNK_R_OVERLAP_SIZE: token overlap between adjacent chunks; falls back to CHUNK_OVERLAP_SIZE when unset
### CHUNK_R_SEPARATORS: JSON array of cascaded separators tried by RecursiveCharacterTextSplitter.
### Default includes CJK sentence-ending punctuation so Chinese / mixed-language
### documents split at semantic boundaries. Order: paragraph (\n\n) > line (\n) >
### Chinese sentence-end (。!?) > Chinese semi-clause (;,) > space > char.
### English ".?!" are intentionally omitted (literal match would split "0.95" /
### "e.g."); the English path falls through space / char as before.
### Bounded at 64 entries of at most 256 characters each. The splitter
### re-scans the whole text once per remaining separator, so an oversized
### cascade costs O(len(separators) x len(text)) for no extra splitting.
### The two limits do NOT behave the same way:
### - an entry longer than 256 characters is DROPPED, not shortened. A
### lone 300-character separator disappears; it does not fall back to
### matching its first 256 characters.
### - a list longer than 64 entries is TRUNCATED to 64, keeping the
### trailing char-level "" sentinel when the original had one.
### If nothing survives, the fallback differs by consumer and is NOT this
### variable's default: the R chunker uses the splitter's own four-entry
### cascade ("\n\n", "\n", " ", ""), while multimodal surrounding-context
### extraction uses the CJK-aware default above minus the sentinel.
### A valid-but-out-of-bounds configured value is corrected and logged once
### when its configuration is loaded/cached, rather than once per document.
### A value that is not a JSON array of strings falls back to the default
### cascade above instead of being bounded, so a bare string can never
### become 64 single-character separators.
# CHUNK_R_SIZE=1200
# CHUNK_R_OVERLAP_SIZE=100
# CHUNK_R_SEPARATORS=["\n\n","\n","。","!","?",";",","," ",""]
### Semantic vector chunker (process_options=V) settings
### CHUNK_V_SIZE: per-strategy chunk_token_size hard cap (oversized pieces are
### re-split via R before being emitted); falls back to CHUNK_SIZE when unset
### CHUNK_V_BREAKPOINT_THRESHOLD_TYPE: percentile | standard_deviation | interquartile | gradient
### CHUNK_V_BREAKPOINT_THRESHOLD_AMOUNT: leave empty to use the LangChain per-type default (e.g. 95 for percentile)
### CHUNK_V_BUFFER_SIZE: number of adjacent sentences combined when computing distances
### CHUNK_V_SENTENCE_SPLIT_REGEX: regex fed to LangChain SemanticChunker for the
### initial sentence split. Default extends the upstream English-only pattern
### with CJK sentence-end punctuation (。?!). Override if you need a
### different language mix. Note: env value is the raw regex string, no JSON
### quoting.
### This env var (or the SDK addon_params) is the ONLY way to set the
### pattern: /documents/text and /documents/texts reject a
### "sentence_split_regex" key in the chunking params with HTTP 422. An
### attacker-supplied pattern is a ReDoS vector — it is applied to the
### request's own text and CPython's regex engine holds the GIL while
### backtracking, so one request can freeze the worker process
### (GHSA-32jh-39m7-8x84). Keep this value under operator control and
### prefer anchored, non-ambiguous patterns.
# CHUNK_V_SIZE=1200
# CHUNK_V_BREAKPOINT_THRESHOLD_TYPE=percentile
# CHUNK_V_BREAKPOINT_THRESHOLD_AMOUNT=
# CHUNK_V_BUFFER_SIZE=1
# CHUNK_V_SENTENCE_SPLIT_REGEX=(?<=[.?!])\s+|(?<=[。?!])
### Paragraph semantic chunker (process_options=P) settings
### CHUNK_P_SIZE: per-strategy chunk_token_size override; defaults to 2000 when unset
### (does NOT fall back to CHUNK_SIZE — paragraph-semantic merging needs more
### headroom than the global default to keep related paragraphs together).
### CHUNK_P_OVERLAP_SIZE: overlap for prose fallback and table-bridge context;
### falls back to CHUNK_OVERLAP_SIZE when unset
### CHUNK_P_DROP_REFERENCES: drop matching reference blocks before chunking.
### Global default switch; overridable per-file via the hint param
### drop_references (alias drop_rf), e.g. paper.[-P(drop_rf=true)].pdf. Frozen
### into the document's chunk_options at enqueue and recorded in
### doc_status.metadata['chunk_opts'].
### CHUNK_P_REFERENCES_TAIL_N: 0 scans all content blocks for reference
### headings (default); a positive value scans only the last N blocks.
### CHUNK_P_REFERENCES_HEADINGS: pipe-separated reference heading prefixes
### (default References|Bibliography|参考文献). English words match
### case-insensitively at a word boundary; 参考文献 matches as a prefix.
### NOTE: TAIL_N / HEADINGS are read live by the chunker at run time (NOT
### snapshotted) — editing them changes the behaviour of re-runs.
# CHUNK_P_SIZE=2000
# CHUNK_P_OVERLAP_SIZE=100
# CHUNK_P_DROP_REFERENCES=false
# CHUNK_P_REFERENCES_TAIL_N=0
# CHUNK_P_REFERENCES_HEADINGS=References|Bibliography|参考文献
### Number of summary segments or tokens to trigger LLM summary on entity/relation merge (at least 3 is recommended)
# FORCE_LLM_SUMMARY_ON_MERGE=8
### Max description token size to trigger LLM summary
# SUMMARY_MAX_TOKENS = 1200
### Recommended LLM summary output length in tokens
# SUMMARY_LENGTH_RECOMMENDED=600
### Maximum context size sent to LLM for description summary
# SUMMARY_CONTEXT_SIZE=12000
### Maximum token size allowed for entity extraction input context
# MAX_EXTRACT_INPUT_TOKENS=20480
### Multimodal surrounding-context budget (per-half token cap for the
### `leading` / `trailing` text injected into VLM and extract prompts).
### Computed at analyze_multimodal entry; the two halves are independent
### so deployments can bias context forward or backward as needed.
# SURROUNDING_LEADING_MAX_TOKENS=2000
# SURROUNDING_TRAILING_MAX_TOKENS=2000
### Floor on the multimodal item's own content budget. If the surrounding
### budgets above leave less than this for the item itself, startup warns and
### names this variable as the knob to raise (or lower SURROUNDING_* instead).
# MM_EXTRACT_CONTENT_MIN_TOKENS=100
### Per-response cap on total entity+relationship rows/records emitted by the LLM
# MAX_EXTRACTION_RECORDS=100
### Per-response cap on entity rows/objects emitted by the LLM
# MAX_EXTRACTION_ENTITIES=40
### Control the maximum chunk_ids stored in vector and graph db
### Addresses the hard-coded 64KB size constraint for Milvus dynamic field ($meta)
# MAX_SOURCE_IDS_PER_ENTITY=200
# MAX_SOURCE_IDS_PER_RELATION=200
### control chunk_ids limitation method: KEEP, FIFO,
### KEEP: Keep oldest (default, less merge action and faster)
### do not change entity/release description after max_source_ids reached
### FIFO: First in first out
# SOURCE_IDS_LIMIT_METHOD=KEEP
### Maximum number of file paths stored in entity/relation file_path field
### For displayed only, does not affect query performance
# MAX_FILE_PATHS=75
### PDF decryption password for protected PDF files
# PDF_DECRYPT_PASSWORD=your_pdf_password_here
########################################
### Pipeline Concurrency Configuration
########################################
### Number of parallel processing documents(between 2~10, MAX_ASYNC_LLM/3 is recommended)
MAX_PARALLEL_INSERT=3
### Optional per-stage document pipeline concurrency
# MAX_PARALLEL_PARSE_NATIVE=5
# MAX_PARALLEL_PARSE_MINERU=2
# MAX_PARALLEL_PARSE_DOCLING=2
# MAX_PARALLEL_ANALYZE=5
### Optional queue sizes for staged pipeline workers
# QUEUE_SIZE_PARSE=20
# QUEUE_SIZE_ANALYZE=100
# QUEUE_SIZE_INSERT=4
### Bounded scheduling page size: the scheduler sweeps the doc_status backlog
### through keyset pages of this many records so memory grows with page-size +
### inflight instead of the whole backlog. 0 disables paging (legacy single
### scan). Default 500.
# PIPELINE_SCHEDULING_PAGE_SIZE=500
### /documents/scan discovery is a single streaming pass; this bounds how many
### newly claimed files one batch holds before it is written to doc_status, so
### scan memory grows with the batch instead of with the input directory. Must be
### positive (there is no "disabled" value — the server refuses to start on 0).
### Default 100.
# SCAN_ENQUEUE_BATCH_SIZE=100
### Directory for /documents/scan's disposable candidate spool — the disk-backed
### index that orders discovered files oldest-first without holding them in RAM.
### One fixed-name database per workspace subdirectory, deleted when the scan
### ends and reclaimed by the next scan after a crash. Default: an empty value
### means WORKING_DIR/scan_spool. Set it when WORKING_DIR is a network volume.
### It must be writable local disk — if it cannot be used the scan FAILS rather
### than relocating to the OS temp dir, which is a RAM-backed tmpfs on many
### hosts and would defeat the memory bound. Never point it at INPUT_DIR.
# SCAN_SPOOL_DIR=
### Refuse to start when the configured doc_status backend is missing a strict
### capability (active count / source-conflict listing / source-conflict repair /
### strict point reads). Default false: the gaps are logged loudly at startup and
### reported by /health under "capabilities", and the affected features fail closed
### (admission 503, conflicts 501). Set true if you would rather not start at all.
# PIPELINE_REQUIRE_STRICT_STORAGE_READS=false
### Admission capacity: refuse new uploads / text inserts with HTTP 429 once this
### many documents are already active (PENDING/PARSING/ANALYZING/PROCESSING) or
### reserved by an in-flight request. Manual retries and /documents/scan may
### exceed it on purpose; the rows they create make ordinary uploads wait.
### 0 disables admission control (default).
# MAX_PENDING_DOCUMENTS=0
### Ceiling on how many texts ONE /documents/texts request may carry, refused
### with 413 before any per-text storage lookup. Bounds the fan-out of a single
### request, unlike MAX_PENDING_DOCUMENTS which bounds the whole backlog and says
### "retry later" — no amount of waiting makes an oversized batch fit.
### 0 disables (default).
# MAX_TEXTS_PER_REQUEST=0
### Per-workspace ceiling on manual retry requests (/documents/reprocess_failed,
### /documents/scan) that have been published but not yet acknowledged by their
### exclusive FAILED->PENDING reset. The channel is sticky, so an over-capacity
### publish is refused with 429 rather than dropped. Default 64.
# MAX_UNACKED_MANUAL_RETRIES=64
### Hard ceiling on the raw request body, counted as it streams through ASGI (so
### a body that lies about or omits Content-Length is still cut off with 413).
### Applies to EVERY route, and is layered because routes differ by orders of
### magnitude in what they legitimately carry:
### - ordinary routes (/query, /api/chat, ...): this value, default 1 MiB
### - /documents/text and /documents/texts: 50 MiB built in, ONLY while
### this variable is left unset
### - /documents/upload: MAX_UPLOAD_SIZE + 1 MiB of
### multipart overhead
### Setting this at all makes it govern every non-upload route, ingestion
### included; there is no separate knob for the ingestion tier. That holds even
### when the value equals the 1 MiB default, so uncommenting the line below as-is
### does change behaviour: it drops /documents/text(s) from 50 MiB to 1 MiB.
### Setting it to 0 turns off every ceiling, including the derived upload one.
### Distinct from MAX_UPLOAD_SIZE, which bounds one uploaded FILE after multipart
### parsing: this bounds the bytes the server agrees to read at all.
# MAX_REQUEST_BODY_BYTES=1048576
###########################################################################
### Gloabal LLM Configuration
### LLM_BINDING type: openai, ollama, lollms, azure_openai, bedrock, gemini
### LLM_BINDING_HOST: Service endpoint (left empty if using the provider SDK default endpoint)
### LLM_BINDING_API_KEY: api key
### If LightRAG deployed in Docker:
### uses host.docker.internal instead of localhost in LLM_BINDING_HOST
###########################################################################
### LLM request timeout setting for all llm (0 means no timeout for Ollma)
# LLM_TIMEOUT=240
LLM_BINDING=openai
LLM_BINDING_HOST=https://api.openai.com/v1
LLM_BINDING_API_KEY=your_api_key
LLM_MODEL=gpt-5.4-mini
### Max concurrency requests of LLM
### MAX_ASYNC is still accepted as a deprecated alias
### NOTE: with gunicorn multi-worker (lightrag-gunicorn --workers N) every
### MAX_ASYNC_* / *_MAX_ASYNC_* setting (LLM roles, embedding, rerank)
### is enforced BOTH per worker process AND as a cross-worker global
### cap. Under normal operation this keeps total in-process provider
### calls clamped to MAX_ASYNC, similar to single-process mode. Slots
### held by crashed workers (kill -9 / OOM) are reclaimed automatically
### via lease heartbeats; if a worker is terminated externally while its
### provider request is still pending, replacement work may briefly make
### provider-side concurrency exceed the cap until the abandoned request
### times out or closes.
### Runtime caveat: changing a role's max_async through the API
### updates only that worker's local limit — the cross-worker cap
### keeps the value read at startup.
MAX_ASYNC_LLM=4
###########################################################################
### Role-specific LLM/VLM overrides
### Available roles: EXTRACT, KEYWORD, QUERY, VLM
### If unset, each role falls back to global LLM configuration above.
### For detail information, refer to:
### docs/RoleSpecificLLMConfiguration.md
### docs/RoleSpecificLLMConfiguration-zh.md
###########################################################################
# EXTRACT_LLM_MODEL=gpt-5.4-mini
# EXTRACT_MAX_ASYNC_LLM=4
# EXTRACT_LLM_TIMEOUT=240
# EXTRACT_LLM_BINDING=openai
# EXTRACT_LLM_BINDING_HOST=https://api.openai.com/v1
# EXTRACT_LLM_BINDING_API_KEY=your_api_key
# KEYWORD_LLM_MODEL=gpt-5.4-nano
KEYWORD_MAX_ASYNC_LLM=4
# KEYWORD_LLM_TIMEOUT=60
# KEYWORD_LLM_BINDING=openai
# KEYWORD_LLM_BINDING_HOST=https://api.openai.com/v1
# KEYWORD_LLM_BINDING_API_KEY=your_api_key
# QUERY_LLM_MODEL=gpt-5.4
QUERY_MAX_ASYNC_LLM=4
# QUERY_LLM_TIMEOUT=240
# QUERY_LLM_BINDING=openai
# QUERY_LLM_BINDING_HOST=https://api.openai.com/v1
# QUERY_LLM_BINDING_API_KEY=your_api_key