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

Make evaluator invariant of input request type order #215

Conversation

sadra-barikbin
Copy link
Contributor

@sadra-barikbin sadra-barikbin commented Jul 5, 2024

Hi there!

To make evaluator.py::evaluate(...,request_dicts,...) invariant of request type order in request_dicts.

As task.process_results() expects the responses to be in a specific order, evaluate() must prepare them in that very order, but currently it depends on the order in its request_dicts args. This PR proposes to use RequestType as the ordering reference to which both task.process_results() and evaluate() submit.

Fixes #193

# ===== Unpack the request =====
prediction_list.sort(
key=lambda x: x.request_index
) # When we use Loglikelihood for several tokens we have all the options here
Copy link
Contributor Author

@sadra-barikbin sadra-barikbin Jul 5, 2024

Choose a reason for hiding this comment

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

This seems to be unnecessary as the lm responses are reordered back to their original order in lm's methods. I removed it in this PR because for example when the responses for a document is like [LoglikelihoodReturn(index=0), LoglikelihoodReturn(index=1), GreedyUntilReturn(index=0)] (which occurs now because RequestType.LOGLIKELIHOOD resides before RequestType.GREEDY_UNTIL in RequestType), this statement wrongly changes it to [LoglikelihoodReturn(index=0), GreedyUntilReturn(index=0)], LoglikelihoodReturn(index=1). If you think we should keep it, we could add the request type to the sort key.

Copy link
Member

Choose a reason for hiding this comment

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

The list sorted here will only contain request of the same type. It is used for loglikelihood requests. For example, for one loglikelihood request with 4 choices we would have 4 different request. We sort them here so that we have the same ordering from the task doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But by looking at the upper for loop, we find that all responses of of all types associated with a single task and single example go to this list.

Copy link
Member

Choose a reason for hiding this comment

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

oh yeah i forgot that we could have both greedy and multichoice returns for one task.
THis could be an issue when computing results. Did you check that removing the sorting was indeed fixing this issue ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I did. It could be verified by the example I put in #193

Copy link
Member

@NathanHB NathanHB left a comment

Choose a reason for hiding this comment

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

lgtm ! Thanks for the fix :)

@clefourrier clefourrier merged commit 951cd5b into huggingface:main Jul 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LightevalTask.process_results() is not aligned with LightevalTask.get_request_type()
3 participants