Skip to content

Commit

Permalink
fix: Rerank test
Browse files Browse the repository at this point in the history
  • Loading branch information
undo76 committed Dec 12, 2024
1 parent 6002da1 commit 501063b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/test_rerank.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
"""Test RAGLite's reranking functionality."""

import random
from functools import partial
from typing import TypeVar

import pytest
from rerankers.models.flashrank_ranker import FlashRankRanker
from rerankers.models.ranker import BaseRanker
from scipy.stats import kendalltau

from raglite import RAGLiteConfig, rerank_chunks, retrieve_chunks, vector_search
from raglite import (
RAGLiteConfig,
hybrid_search,
keyword_search,
rerank_chunks,
retrieve_chunks,
vector_search,
)
from raglite._database import Chunk

T = TypeVar("T")
Expand Down Expand Up @@ -54,7 +62,15 @@ def test_reranker(
)
# Search for a query.
query = "What does it mean for two events to be simultaneous?"
chunk_ids, _ = vector_search(query, config=raglite_test_config, max_chunks=20)
chunk_ids, _ = hybrid_search(
query,
config=raglite_test_config,
subsearches=[
partial(vector_search, max_chunks=40, config=raglite_test_config),
partial(keyword_search, max_chunks=40, config=raglite_test_config),
],
max_chunks=20,
)
# Retrieve the chunks.
chunks = retrieve_chunks(chunk_ids, config=raglite_test_config)
assert all(isinstance(chunk, Chunk) for chunk in chunks)
Expand Down

0 comments on commit 501063b

Please sign in to comment.