From 5a40ff654e622e29db36e4180ed1ff096bb152de Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 13 Aug 2025 23:10:42 +0800 Subject: [PATCH] Change KG chunk selection default to VECTOR - Set KG_CHUNK_PICK_METHOD default to VECTOR - Update env.example with new config option --- env.example | 2 ++ lightrag/constants.py | 2 +- lightrag/operate.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/env.example b/env.example index be054576..43739d10 100644 --- a/env.example +++ b/env.example @@ -71,6 +71,8 @@ ENABLE_LLM_CACHE=true # MAX_RELATION_TOKENS=10000 ### control the maximum tokens send to LLM (include entities, raltions and chunks) # MAX_TOTAL_TOKENS=30000 +### chunk selection strategies for KG: WEIGHT or VECTOR +KG_CHUNK_PICK_METHOD=VECTOR ### maximum number of related chunks per source entity or relation (higher values increase re-ranking time) # RELATED_CHUNK_NUMBER=5 diff --git a/lightrag/constants.py b/lightrag/constants.py index 895852bd..1c7917c1 100644 --- a/lightrag/constants.py +++ b/lightrag/constants.py @@ -27,7 +27,7 @@ DEFAULT_MAX_RELATION_TOKENS = 10000 DEFAULT_MAX_TOTAL_TOKENS = 30000 DEFAULT_COSINE_THRESHOLD = 0.2 DEFAULT_RELATED_CHUNK_NUMBER = 5 -DEFAULT_KG_CHUNK_PICK_METHOD = "WEIGHT" +DEFAULT_KG_CHUNK_PICK_METHOD = "VECTOR" # Deprated: history message have negtive effect on query performance DEFAULT_HISTORY_TURNS = 0 diff --git a/lightrag/operate.py b/lightrag/operate.py index 60f5bc6c..1f94bd01 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -2803,7 +2803,7 @@ async def _find_related_text_unit_from_entities( entities_with_chunks, max_related_chunks, min_related_chunks=1 ) - logger.debug( + logger.info( f"Selecting {len(selected_chunk_ids)} from {total_entity_chunks} entity-related chunks by weighted polling" )