How to apply the Retrieval Mean Reciprocal Rank (MRR)? #989
Replies: 4 comments 6 replies
-
cc: @lucadiliello |
Beta Was this translation helpful? Give feedback.
-
At the moment, you cannot because you don’t have scores. Your retrieval system is just embedding queries and documents but is not classifying document as relevant or not relevant. I don’t know whether you encoded the queries and the documents together or separately, but something you can do is to use the cosine similarity between the embeddings to retrieve the scores: scores = torch.nn.functional.cosine_similarity(output['query_rpr'], output['doc_rpr'], dim=1) and to compute a vector of relevant documents as: labels = torch.tensor([relevance_map[q_idx.item()] == d_idx for q_idx, d_idx in zip(output['query_idx'], output['doc_idx'])]) Finally, you can compute the MRR with: mrr = RetrievalMRR()
result = mrr(scores, labels, output['query_idx']) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Is there an example where this MRR metric works in a large number of queries? |
Beta Was this translation helpful? Give feedback.
-
Suppose that after a forward pass, the model outputs a prediction as shown below:
where:
query_idx
: is the query index;query_rpr
: is the query embedding;doc_idx
: is the document idx;doc_rpr
: is the document representation.and the relevance map contains:
Therefore, how can the MRR metric be applied in this scenario?
Beta Was this translation helpful? Give feedback.
All reactions