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

MAP and MRR wrong for multiple gold documents #7758

Closed
ju-gu opened this issue May 29, 2024 · 2 comments · Fixed by #7841
Closed

MAP and MRR wrong for multiple gold documents #7758

ju-gu opened this issue May 29, 2024 · 2 comments · Fixed by #7841
Assignees
Labels
2.x Related to Haystack v2.0 P1 High priority, add to the next sprint type:bug Something isn't working

Comments

@ju-gu
Copy link
Member

ju-gu commented May 29, 2024

Describe the bug
Both the MAP and the MRR show wrong values. It seems we calculate the score for single gold documents and then override it after each instead of calculating it for the whole batch of gold documents.

Expected behavior
correct values

To Reproduce

retrieved_docs = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]
gold_docs = ["one", "two", "three","four","seven"]

from haystack.components.evaluators import DocumentMAPEvaluator, DocumentMRREvaluator
from haystack import Document

mapevaluator = DocumentMAPEvaluator()
mrrevaluator = DocumentMRREvaluator()
mapresult = mapevaluator.run(
    ground_truth_documents=[[Document(content=content) for content in gold_docs]],
    retrieved_documents=[[Document(content=content) for content in retrieved_docs]])

mrrresult = mrrevaluator.run(
    ground_truth_documents=[[Document(content=content) for content in gold_docs]],
    retrieved_documents=[[Document(content=content) for content in retrieved_docs]])

print(mapresult["individual_scores"])
print(mrrresult["individual_scores"])
print(mapresult["score"])
print(mrrresult["score"])
@ju-gu ju-gu added type:bug Something isn't working 2.x Related to Haystack v2.0 labels May 29, 2024
@ju-gu ju-gu changed the title MAP and MRR wrong MAP and MRR wrong for multiple gold documents May 29, 2024
@shadeMe shadeMe added the P1 High priority, add to the next sprint label May 29, 2024
@mrm1001
Copy link
Member

mrm1001 commented Jun 11, 2024

Hi @ju-gu I'm trying to understand the example above. You are providing 10 "retrievals" but have only 5 gold truth docs? In other words, you have:

Actual retrieved True doc
one one
two two
three three
four four
five seven
six ?
seven ?
eight ?
nine ?
ten ?

I don't think this is a typical use case, are you sure this is what you're trying to do?

Or are you trying to do this instead:

Actual retrieved True doc
["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"] ["one", "two", "three","four","seven"]

@ju-gu
Copy link
Member Author

ju-gu commented Jun 11, 2024

I am doing the latter. The two lists retrieved docs and true docs become a list of lists in these lines:

ground_truth_documents=[[Document(content=content) for content in gold_docs]]
retrieved_documents=[[Document(content=content) for content in retrieved_docs]])

So it is just one set of retrieved docs and one set of gold documents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0 P1 High priority, add to the next sprint type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants