From a8b7890470991bcdbd71d6ef4e1978e94d178b12 Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 14 Aug 2025 16:01:13 +0800 Subject: [PATCH] Rename chunk selection functions for better clarity --- lightrag/operate.py | 12 ++++++------ lightrag/utils.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lightrag/operate.py b/lightrag/operate.py index 3f1d31b6..dafc9e84 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -27,8 +27,8 @@ from .utils import ( use_llm_func_with_cache, update_chunk_cache_list, remove_think_tags, - linear_gradient_weighted_polling, - vector_similarity_sorting, + pick_by_weighted_polling, + pick_by_vector_similarity, process_chunks_unified, build_file_path, ) @@ -2757,7 +2757,7 @@ async def _find_related_text_unit_from_entities( selected_chunk_ids = None if actual_embedding_func: - selected_chunk_ids = await vector_similarity_sorting( + selected_chunk_ids = await pick_by_vector_similarity( query=query, text_chunks_storage=text_chunks_db, chunks_vdb=chunks_vdb, @@ -2784,7 +2784,7 @@ async def _find_related_text_unit_from_entities( if kg_chunk_pick_method == "WEIGHT": # Apply linear gradient weighted polling algorithm - selected_chunk_ids = linear_gradient_weighted_polling( + selected_chunk_ids = pick_by_weighted_polling( entities_with_chunks, max_related_chunks, min_related_chunks=1 ) @@ -3039,7 +3039,7 @@ async def _find_related_text_unit_from_relations( actual_embedding_func = embedding_func_config.func if actual_embedding_func: - selected_chunk_ids = await vector_similarity_sorting( + selected_chunk_ids = await pick_by_vector_similarity( query=query, text_chunks_storage=text_chunks_db, chunks_vdb=chunks_vdb, @@ -3066,7 +3066,7 @@ async def _find_related_text_unit_from_relations( if kg_chunk_pick_method == "WEIGHT": # Apply linear gradient weighted polling algorithm - selected_chunk_ids = linear_gradient_weighted_polling( + selected_chunk_ids = pick_by_weighted_polling( relations_with_chunks, max_related_chunks, min_related_chunks=1 ) diff --git a/lightrag/utils.py b/lightrag/utils.py index 249c1a38..4d2a5289 100644 --- a/lightrag/utils.py +++ b/lightrag/utils.py @@ -1570,7 +1570,7 @@ def check_storage_env_vars(storage_name: str) -> None: ) -def linear_gradient_weighted_polling( +def pick_by_weighted_polling( entities_or_relations: list[dict], max_related_chunks: int, min_related_chunks: int = 1, @@ -1650,7 +1650,7 @@ def linear_gradient_weighted_polling( return selected_chunks -async def vector_similarity_sorting( +async def pick_by_vector_similarity( query: str, text_chunks_storage: "BaseKVStorage", chunks_vdb: "BaseVectorStorage",