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

fix: document retrieval metrics for non-document_id document_relevance_criteria #3885

Merged
merged 15 commits into from
Feb 2, 2023

Conversation

tstadel
Copy link
Member

@tstadel tstadel commented Jan 18, 2023

Related Issues

Proposed Changes:

  • fix metrics calculation for document retrieval metrics if document_relevance_criteria does not contain document_id
  • fix metrics calculation for document retrieval metrics if document_relevance_criteria does not contain document_id and there are multiple labels
  • streamline and make more explicit metrics values in case of no_answer queries

How did you test it?

  • unit tests to be implemented

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added tests that demonstrate the correct behavior of the change
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test:.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@ZanSara
Copy link
Contributor

ZanSara commented Jan 19, 2023

@tstadel please rebase to main to sort out the mypy issues. Sorry for the mess!

@tstadel tstadel marked this pull request as ready for review February 1, 2023 13:18
@tstadel tstadel requested a review from a team as a code owner February 1, 2023 13:18
@tstadel tstadel requested review from sjrl and removed request for a team February 1, 2023 13:18
@@ -1690,6 +1690,7 @@ def _build_eval_dataframe(
df_docs.map_rows = partial(df_docs.apply, axis=1)
df_docs.rename(columns={"id": "document_id", "content": "context"}, inplace=True)
df_docs["gold_document_ids"] = [gold_document_ids] * len(df_docs)
df_docs["gold_answers"] = [gold_answers] * len(df_docs)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added for easier analysis, e.g. if document_relevance_criterion="answer"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify this won't be a problem if there are no gold_answers in the eval set? For example in the case we use context for the relevance criteria gold_answers may not be available.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. I've added tests for this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tstadel this looks good to me! I don't fully understand how the code is structured, but I appreciate that the tests for the metrics look correct now.

I agree, the current code can be better structured. As there are no other using parts besides calculate metrics, refactoring it, wouldn't bring too much value. Let's refactor in another PR, probably connecting it to a feature to support custom metrics.

Copy link
Contributor

@sjrl sjrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tstadel this looks good to me! I don't fully understand how the code is structured, but I appreciate that the tests for the metrics look correct now.

@ZanSara ZanSara added this to the 1.13.1 milestone Feb 2, 2023
@sjrl sjrl merged commit 9611b64 into main Feb 2, 2023
@sjrl sjrl deleted the fix/doc_retrieval_metrics branch February 2, 2023 14:00
ZanSara pushed a commit that referenced this pull request Feb 2, 2023
…e_criteria (#3885)

* fix document retrieval metrics for all document_relevance_criteria

* fix tests

* fix eval_batch metrics

* small refactorings

* evaluate metrics on label level

* document retrieval tests added

* fix pylint

* fix test

* support file retrieval

* add comment about threshold

* rename test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants