class_docstr: This class evaluates an Information Retrieval (IR) setting.
  
  Given a set of queries and a large corpus set. It will retrieve for each query the top-k most similar document. It measures
  Mean Reciprocal Rank (MRR), Recall@k, and Normalized Discounted Cumulative Gain (NDCG)
class_docstr_tok: ["This","class","evaluates","an","Information","Retrieval","(","IR",")","setting",".","Given","a","set","of","queries","and","a","large","corpus","set",".","It","will","retrieve","for","each","query","the","top-k","most","similar","document",".","It","measures","Mean","Reciprocal","Rank","(","MRR",")",",","Recall","@","k",",","and","Normalized","Discounted","Cumulative","Gain","(","NDCG",")"]
code: def __init__(
      self,
      queries: Dict[str, str],  # qid => query
      corpus: Dict[str, str],  # cid => doc
      relevant_docs: Dict[str, Set[str]],  # qid => Set[cid]
      corpus_chunk_size: int = 50000,
      mrr_at_k: List[int] = [10],
      ndcg_at_k: List[int] = [10],
      accuracy_at_k: List[int] = [1, 3, 5, 10],
      precision_recall_at_k: List[int] = [1, 3, 5, 10],
      map_at_k: List[int] = [100],
      show_progress_bar: bool = False,
      batch_size: int = 32,
      name: str = "",
      write_csv: bool = True,
      score_functions: List[Callable[[Tensor, Tensor], Tensor]] = {
          "cos_sim": cos_sim,
          "dot_score": dot_score,
      },  # Score function, higher=more similar
      main_score_function: str = None,
  ):
      self.queries_ids = []
      for qid in queries:
          if qid in relevant_docs and len(relevant_docs[qid]) > 0:
              self.queries_ids.append(qid)
  
      self.queries = [queries[qid] for qid in self.queries_ids]
  
      self.corpus_ids = list(corpus.keys())
      self.corpus = [corpus[cid] for cid in self.corpus_ids]
  
      self.relevant_docs = relevant_docs
      self.corpus_chunk_size = corpus_chunk_size
      self.mrr_at_k = mrr_at_k
      self.ndcg_at_k = ndcg_at_k
      self.accuracy_at_k = accuracy_at_k
      self.precision_recall_at_k = precision_recall_at_k
      self.map_at_k = map_at_k
  
      self.show_progress_bar = show_progress_bar
      self.batch_size = batch_size
      self.name = name
      self.write_csv = write_csv
      self.score_functions = score_functions
      self.score_function_names = sorted(
          list(self.score_functions.keys())
      )
      self.main_score_function = main_score_function
  
      if name:
          name = "_" + name
  
      self.csv_file: str = (
          "Information-Retrieval_evaluation" + name + "_results.csv"
      )
      self.csv_headers = ["epoch", "steps"]
  
      for score_name in self.score_function_names:
          for k in accuracy_at_k:
              self.csv_headers.append(
                  "{}-Accuracy@{}".format(score_name, k)
              )
  
          for k in precision_recall_at_k:
              self.csv_headers.append(
                  "{}-Precision@{}".format(score_name, k)
              )
              self.csv_headers.append(
                  "{}-Recall@{}".format(score_name, k)
              )
  
          for k in mrr_at_k:
              self.csv_headers.append("{}-MRR@{}".format(score_name, k))
  
          for k in ndcg_at_k:
              self.csv_headers.append(
                  "{}-NDCG@{}".format(score_name, k)
              )
  
          for k in map_at_k:
              self.csv_headers.append("{}-MAP@{}".format(score_name, k))
  
file_path: sentence-transformers/sentence_transformers/evaluation/InformationRetrievalEvaluator.py
imports: from .None import SentenceEvaluator
  import torch
  from torch import Tensor
  import logging
  from tqdm import trange
  from ..util import cos_sim, dot_score
  import os
  import numpy
  from typing import List, Dict, Set, Callable
  import heapq
label_desc: Use image node_id 1 to create a new InformationRetrievalEvaluator object from inherited base classes: SentenceEvaluator with example: obj = InformationRetrievalEvaluator(queries, corpus, relevant_docs, corpus_chunk_size, mrr_at_k, ndcg_at_k, accuracy_at_k, precision_recall_at_k, map_at_k, show_progress_bar, batch_size, name, write_csv, score_functions, main_score_function)