zrguo
commited on
Commit
·
141cb64
1
Parent(s):
b9eabd5
fix process_chunks_unified()
Browse files- lightrag/operate.py +9 -9
lightrag/operate.py
CHANGED
@@ -2879,15 +2879,7 @@ async def process_chunks_unified(
|
|
2879 |
f"Deduplication: {len(unique_chunks)} chunks (original: {len(chunks)})"
|
2880 |
)
|
2881 |
|
2882 |
-
# 2. Apply
|
2883 |
-
if query_param.chunk_top_k is not None and query_param.chunk_top_k > 0:
|
2884 |
-
if len(unique_chunks) > query_param.chunk_top_k:
|
2885 |
-
unique_chunks = unique_chunks[: query_param.chunk_top_k]
|
2886 |
-
logger.debug(
|
2887 |
-
f"Chunk top-k limiting: kept {len(unique_chunks)} chunks (chunk_top_k={query_param.chunk_top_k})"
|
2888 |
-
)
|
2889 |
-
|
2890 |
-
# 3. Apply reranking if enabled and query is provided
|
2891 |
if global_config.get("enable_rerank", False) and query and unique_chunks:
|
2892 |
rerank_top_k = query_param.chunk_rerank_top_k or len(unique_chunks)
|
2893 |
unique_chunks = await apply_rerank_if_enabled(
|
@@ -2898,6 +2890,14 @@ async def process_chunks_unified(
|
|
2898 |
)
|
2899 |
logger.debug(f"Rerank: {len(unique_chunks)} chunks (source: {source_type})")
|
2900 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2901 |
# 4. Token-based final truncation
|
2902 |
tokenizer = global_config.get("tokenizer")
|
2903 |
if tokenizer and unique_chunks:
|
|
|
2879 |
f"Deduplication: {len(unique_chunks)} chunks (original: {len(chunks)})"
|
2880 |
)
|
2881 |
|
2882 |
+
# 2. Apply reranking if enabled and query is provided
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2883 |
if global_config.get("enable_rerank", False) and query and unique_chunks:
|
2884 |
rerank_top_k = query_param.chunk_rerank_top_k or len(unique_chunks)
|
2885 |
unique_chunks = await apply_rerank_if_enabled(
|
|
|
2890 |
)
|
2891 |
logger.debug(f"Rerank: {len(unique_chunks)} chunks (source: {source_type})")
|
2892 |
|
2893 |
+
# 3. Apply chunk_top_k limiting if specified
|
2894 |
+
if query_param.chunk_top_k is not None and query_param.chunk_top_k > 0:
|
2895 |
+
if len(unique_chunks) > query_param.chunk_top_k:
|
2896 |
+
unique_chunks = unique_chunks[: query_param.chunk_top_k]
|
2897 |
+
logger.debug(
|
2898 |
+
f"Chunk top-k limiting: kept {len(unique_chunks)} chunks (chunk_top_k={query_param.chunk_top_k})"
|
2899 |
+
)
|
2900 |
+
|
2901 |
# 4. Token-based final truncation
|
2902 |
tokenizer = global_config.get("tokenizer")
|
2903 |
if tokenizer and unique_chunks:
|