File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 7
7
from llama_index .postprocessor .types import BaseNodePostprocessor
8
8
from private_gpt .settings .settings import Settings
9
9
10
+
10
11
@singleton
11
12
class RerankerComponent (BaseNodePostprocessor ):
12
13
"""
@@ -17,6 +18,7 @@ class RerankerComponent(BaseNodePostprocessor):
17
18
If the number of nodes with score > cut_off is <= top_n, then return top_n nodes.
18
19
Otherwise, return all nodes with score > cut_off.
19
20
"""
21
+
20
22
reranker : FlagReranker = Field (description = "Reranker class." )
21
23
top_n : int = Field (description = "Top N nodes to return." )
22
24
cut_off : float = Field (description = "Cut off score for nodes." )
@@ -66,6 +68,4 @@ def _postprocess_nodes(
66
68
if len (res ) > self .top_n :
67
69
return res
68
70
69
- return sorted (nodes , key = lambda x : x .score or 0.0 , reverse = True )[
70
- : self .top_n
71
- ]
71
+ return sorted (nodes , key = lambda x : x .score or 0.0 , reverse = True )[: self .top_n ]
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ class RerankerSettings(BaseModel):
111
111
)
112
112
hf_model_name : str = Field (
113
113
"BAAI/bge-reranker-large" ,
114
- description = "Name of the HuggingFace model to use for reranking"
114
+ description = "Name of the HuggingFace model to use for reranking" ,
115
115
)
116
116
top_n : int = Field (
117
117
5 ,
You can’t perform that action at this time.
0 commit comments