Skip to content

Commit 213fe89

Browse files
author
Zhe Yu
committed
logger for reranker.
1 parent 579332d commit 213fe89

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/vectorcode/subcommands/query/reranker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import heapq
2+
import logging
23
from abc import abstractmethod
34
from collections import defaultdict
45
from typing import Any, DefaultDict
@@ -8,6 +9,8 @@
89

910
from vectorcode.cli_utils import Config, QueryInclude
1011

12+
logger = logging.getLogger(name=__name__)
13+
1114

1215
class RerankerBase:
1316
def __init__(self, configs: Config, **kwargs: Any):
@@ -42,7 +45,7 @@ def rerank(self, results: QueryResult) -> list[str]:
4245
# so that vectorcode doesn't break on old collections.
4346
continue
4447
documents[identifier].append(distance)
45-
48+
logger.debug("Document scores: %s", documents)
4649
top_k = int(numpy.mean(tuple(len(i) for i in documents.values())))
4750
for key in documents.keys():
4851
documents[key] = heapq.nsmallest(top_k, documents[key])
@@ -80,7 +83,7 @@ def rerank(self, results: QueryResult) -> list[str]:
8083
documents[chunk_metas[rank["corpus_id"]]["path"]].append(
8184
float(rank["score"])
8285
)
83-
86+
logger.debug("Document scores: %s", documents)
8487
top_k = int(numpy.mean(tuple(len(i) for i in documents.values())))
8588
for key in documents.keys():
8689
documents[key] = heapq.nlargest(top_k, documents[key])

0 commit comments

Comments
 (0)