Skip to content

Commit

Permalink
use 1-indexed rank (instead of 0-based index)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivo-1 committed Apr 8, 2024
1 parent 033d8f1 commit f909f9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/intelligence_layer/use_cases/search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def overlaps(a: tuple[int, int], b: tuple[int, int]) -> bool:
b_start, b_end = b
return a_start < b_end and b_start < a_end

index, score = next(
rank, score = next(
(
(index, result.score)
(index + 1, result.score)
for index, result in enumerate(results)
if overlaps(
(result.document_chunk.start, result.document_chunk.end),
Expand All @@ -122,7 +122,7 @@ def overlaps(a: tuple[int, int], b: tuple[int, int]) -> bool:
(None, None),
)

return SearchEvaluation(rank=index, similarity_score=score)
return SearchEvaluation(rank=rank, similarity_score=score)


class MeanTopK(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion tests/use_cases/search/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_search(
def test_search_evaluation_logic_works_for_overlapping_output(
example: Example[SearchInput, ExpectedSearchOutput],
) -> None:
logic = SearchEvaluationLogic[SearchResult[str]]()
logic = SearchEvaluationLogic()
output = SuccessfulExampleOutput(
run_id="1",
example_id="1",
Expand Down

0 comments on commit f909f9a

Please sign in to comment.