Update reranker/rankllm.py
Browse files- reranker/rankllm.py +10 -4
reranker/rankllm.py
CHANGED
@@ -283,18 +283,24 @@ class RankLLM(ABC):
|
|
283 |
the permuted items.
|
284 |
"""
|
285 |
response = self._clean_response(permutation)
|
|
|
286 |
response = [int(x) - 1 for x in response.split()]
|
|
|
287 |
response = self._remove_duplicate(response)
|
|
|
288 |
cut_range = copy.deepcopy(result.hits[rank_start:rank_end])
|
289 |
original_rank = [tt for tt in range(len(cut_range))]
|
290 |
response = [ss for ss in response if ss in original_rank]
|
|
|
291 |
response = response + [tt for tt in original_rank if tt not in response]
|
|
|
292 |
for j, x in enumerate(response):
|
293 |
result.hits[j + rank_start] = copy.deepcopy(cut_range[x])
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
298 |
return result
|
299 |
|
300 |
def parse_reasoning_permutation(self, response: str) -> Tuple[str, bool]:
|
|
|
283 |
the permuted items.
|
284 |
"""
|
285 |
response = self._clean_response(permutation)
|
286 |
+
print(f"response after cleaning: {response}")
|
287 |
response = [int(x) - 1 for x in response.split()]
|
288 |
+
print(f"response after splitting: {response}")
|
289 |
response = self._remove_duplicate(response)
|
290 |
+
print(f"response after deduplication: {response}")
|
291 |
cut_range = copy.deepcopy(result.hits[rank_start:rank_end])
|
292 |
original_rank = [tt for tt in range(len(cut_range))]
|
293 |
response = [ss for ss in response if ss in original_rank]
|
294 |
+
print(f"response after selection: {response}")
|
295 |
response = response + [tt for tt in original_rank if tt not in response]
|
296 |
+
print(f"response after appending all original: {response}")
|
297 |
for j, x in enumerate(response):
|
298 |
result.hits[j + rank_start] = copy.deepcopy(cut_range[x])
|
299 |
+
|
300 |
+
# if "rank" in result.hits[j + rank_start]:
|
301 |
+
# result.hits[j + rank_start]["rank"] = cut_range[j]["rank"]
|
302 |
+
# if "score" in result.hits[j + rank_start]:
|
303 |
+
# result.hits[j + rank_start]["score"] = cut_range[j]["score"]
|
304 |
return result
|
305 |
|
306 |
def parse_reasoning_permutation(self, response: str) -> Tuple[str, bool]:
|