diff --git a/README-zh.md b/README-zh.md index 10b2dc38..f53351b1 100644 --- a/README-zh.md +++ b/README-zh.md @@ -308,15 +308,15 @@ class QueryParam: top_k: int = int(os.getenv("TOP_K", "60")) """Number of top items to retrieve. Represents entities in 'local' mode and relationships in 'global' mode.""" - chunk_top_k: int = int(os.getenv("CHUNK_TOP_K", "10")) + chunk_top_k: int = int(os.getenv("CHUNK_TOP_K", "20")) """Number of text chunks to retrieve initially from vector search and keep after reranking. If None, defaults to top_k value. """ - max_entity_tokens: int = int(os.getenv("MAX_ENTITY_TOKENS", "10000")) + max_entity_tokens: int = int(os.getenv("MAX_ENTITY_TOKENS", "6000")) """Maximum number of tokens allocated for entity context in unified token control system.""" - max_relation_tokens: int = int(os.getenv("MAX_RELATION_TOKENS", "10000")) + max_relation_tokens: int = int(os.getenv("MAX_RELATION_TOKENS", "8000")) """Maximum number of tokens allocated for relationship context in unified token control system.""" max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000")) diff --git a/README.md b/README.md index fa44019f..4299896c 100644 --- a/README.md +++ b/README.md @@ -315,15 +315,15 @@ class QueryParam: top_k: int = int(os.getenv("TOP_K", "60")) """Number of top items to retrieve. Represents entities in 'local' mode and relationships in 'global' mode.""" - chunk_top_k: int = int(os.getenv("CHUNK_TOP_K", "10")) + chunk_top_k: int = int(os.getenv("CHUNK_TOP_K", "20")) """Number of text chunks to retrieve initially from vector search and keep after reranking. If None, defaults to top_k value. """ - max_entity_tokens: int = int(os.getenv("MAX_ENTITY_TOKENS", "10000")) + max_entity_tokens: int = int(os.getenv("MAX_ENTITY_TOKENS", "6000")) """Maximum number of tokens allocated for entity context in unified token control system.""" - max_relation_tokens: int = int(os.getenv("MAX_RELATION_TOKENS", "10000")) + max_relation_tokens: int = int(os.getenv("MAX_RELATION_TOKENS", "8000")) """Maximum number of tokens allocated for relationship context in unified token control system.""" max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000")) diff --git a/env.example b/env.example index e16a17fb..5d71b9b6 100644 --- a/env.example +++ b/env.example @@ -64,11 +64,11 @@ ENABLE_LLM_CACHE=true ### Number of entities or relations retrieved from KG # TOP_K=40 ### Maxmium number or chunks for naive vactor search -# CHUNK_TOP_K=10 +# CHUNK_TOP_K=20 ### control the actual enties send to LLM -# MAX_ENTITY_TOKENS=10000 +# MAX_ENTITY_TOKENS=6000 ### control the actual relations send to LLM -# MAX_RELATION_TOKENS=10000 +# MAX_RELATION_TOKENS=8000 ### control the maximum tokens send to LLM (include entities, raltions and chunks) # MAX_TOTAL_TOKENS=30000 diff --git a/lightrag/constants.py b/lightrag/constants.py index ff74365d..e3ed9d7f 100644 --- a/lightrag/constants.py +++ b/lightrag/constants.py @@ -21,9 +21,9 @@ GRAPH_FIELD_SEP = "" # Query and retrieval configuration defaults DEFAULT_TOP_K = 40 -DEFAULT_CHUNK_TOP_K = 10 -DEFAULT_MAX_ENTITY_TOKENS = 10000 -DEFAULT_MAX_RELATION_TOKENS = 10000 +DEFAULT_CHUNK_TOP_K = 20 +DEFAULT_MAX_ENTITY_TOKENS = 6000 +DEFAULT_MAX_RELATION_TOKENS = 8000 DEFAULT_MAX_TOTAL_TOKENS = 30000 DEFAULT_COSINE_THRESHOLD = 0.2 DEFAULT_RELATED_CHUNK_NUMBER = 5 diff --git a/lightrag_webui/src/components/retrieval/QuerySettings.tsx b/lightrag_webui/src/components/retrieval/QuerySettings.tsx index 0a37fcab..958f0b6e 100644 --- a/lightrag_webui/src/components/retrieval/QuerySettings.tsx +++ b/lightrag_webui/src/components/retrieval/QuerySettings.tsx @@ -30,9 +30,9 @@ export default function QuerySettings() { mode: 'mix' as QueryMode, response_type: 'Multiple Paragraphs', top_k: 40, - chunk_top_k: 10, - max_entity_tokens: 10000, - max_relation_tokens: 10000, + chunk_top_k: 20, + max_entity_tokens: 6000, + max_relation_tokens: 8000, max_total_tokens: 30000 }), []) @@ -179,7 +179,7 @@ export default function QuerySettings() { onBlur={(e) => { const value = e.target.value if (value === '' || isNaN(parseInt(value))) { - handleChange('top_k', 1) + handleChange('top_k', 40) } }} min={1} @@ -219,7 +219,7 @@ export default function QuerySettings() { onBlur={(e) => { const value = e.target.value if (value === '' || isNaN(parseInt(value))) { - handleChange('chunk_top_k', 1) + handleChange('chunk_top_k', 20) } }} min={1} @@ -259,7 +259,7 @@ export default function QuerySettings() { onBlur={(e) => { const value = e.target.value if (value === '' || isNaN(parseInt(value))) { - handleChange('max_entity_tokens', 1000) + handleChange('max_entity_tokens', 6000) } }} min={1} @@ -299,7 +299,7 @@ export default function QuerySettings() { onBlur={(e) => { const value = e.target.value if (value === '' || isNaN(parseInt(value))) { - handleChange('max_relation_tokens', 1000) + handleChange('max_relation_tokens', 8000) } }} min={1} @@ -339,7 +339,7 @@ export default function QuerySettings() { onBlur={(e) => { const value = e.target.value if (value === '' || isNaN(parseInt(value))) { - handleChange('max_total_tokens', 32000) + handleChange('max_total_tokens', 30000) } }} min={1} diff --git a/lightrag_webui/src/stores/settings.ts b/lightrag_webui/src/stores/settings.ts index 6f616a08..866504d0 100644 --- a/lightrag_webui/src/stores/settings.ts +++ b/lightrag_webui/src/stores/settings.ts @@ -115,10 +115,10 @@ const useSettingsStoreBase = create()( mode: 'global', response_type: 'Multiple Paragraphs', top_k: 40, - chunk_top_k: 10, - max_entity_tokens: 10000, - max_relation_tokens: 10000, - max_total_tokens: 32000, + chunk_top_k: 20, + max_entity_tokens: 6000, + max_relation_tokens: 8000, + max_total_tokens: 30000, only_need_context: false, only_need_prompt: false, stream: true,