Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Integrate NanoBeIR datasets #2966

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def __init__(
truncate_dim (int, optional): The dimension to truncate the embeddings to. Defaults to None.
score_functions (Dict[str, Callable[[Tensor, Tensor], Tensor]]): A dictionary mapping score function names to score functions. Defaults to {SimilarityFunction.COSINE.value: cos_sim, SimilarityFunction.DOT_PRODUCT.value: dot_score}.
main_score_function (Union[str, SimilarityFunction], optional): The main score function to use for evaluation. Defaults to None.
query_prompt (str, optional): A prompt to use for the queries. Defaults to None.
query_prompt_name (str, optional): A name for the query prompt. Defaults to None.
corpus_prompt (str, optional): A prompt to use for the corpus. Defaults to None.
corpus_prompt_name (str, optional): A name for the corpus prompt. Defaults to None.
query_prompt (str, optional): The prompt to be used when encoding the corpus. Defaults to None.
query_prompt_name (str, optional): The name of the prompt to be used when encoding the corpus. Defaults to None.
corpus_prompt (str, optional): The prompt to be used when encoding the corpus. Defaults to None.
corpus_prompt_name (str, optional): The name of the prompt to be used when encoding the corpus. Defaults to None.
"""
super().__init__()
self.queries_ids = []
Expand Down Expand Up @@ -290,7 +290,7 @@ def __call__(
return metrics

def compute_metrices(
self, model: SentenceTransformer, corpus_model=None, corpus_embeddings: Tensor = None
self, model: SentenceTransformer, corpus_model=None, corpus_embeddings: Tensor | None = None
) -> dict[str, float]:
if corpus_model is None:
corpus_model = model
Expand All @@ -309,8 +309,8 @@ def compute_metrices(
self.queries,
prompt_name=self.query_prompt_name,
prompt=self.query_prompt,
show_progress_bar=self.show_progress_bar,
batch_size=self.batch_size,
show_progress_bar=self.show_progress_bar,
convert_to_tensor=True,
)

Expand All @@ -333,8 +333,8 @@ def compute_metrices(
self.corpus[corpus_start_idx:corpus_end_idx],
prompt_name=self.corpus_prompt_name,
prompt=self.corpus_prompt,
show_progress_bar=False,
batch_size=self.batch_size,
show_progress_bar=False,
convert_to_tensor=True,
)
else:
Expand Down
Loading