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

Adding evaluation checks to prevent Transformer ValueError #3105

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

stsfaroz
Copy link

@stsfaroz stsfaroz commented Dec 1, 2024

When neither eval_dataset nor evaluator is provided, Transformers raises a ValueError stating that an eval_dataset must be passed or eval_strategy. However, this error does not account for the evaluator parameter.

Error raised by Transformers:

ValueError: You have set `args.eval_strategy` to "steps" but you didn't pass an `eval_dataset` to `Trainer`. 
Either set `args.eval_strategy` to "no" or pass an `eval_dataset`.

Instead, we now raise a more specific error:

ValueError: Either `eval_dataset` or `evaluator` must be provided for evaluation, 
or set `eval_strategy='no'` to skip evaluation.

@tomaarsen
Copy link
Collaborator

Hello!

Thanks for tackling this, I think it's indeed quite smart to "get ahead" of the error that transformers will give and give our own Sentence Transformers-specific error. I updated the phrasing a bit because I quite like how the transformers error flowed ("you did X, but not Y. Please do Y or avoid X").

The edge case of no eval_strategy/no evaluator was already tackled a bit in #3035 to get Transformers v4.46 compatibility, but the "no eval_strategy and no evaluator" case was left as-is:

If evaluator is not set, then the ValueError is acceptable I think

So I also updated the test that I made back then with more details about what the expected ValueError should be.

What do you think? @stsfaroz

  • Tom Aarsen

@tomaarsen
Copy link
Collaborator

Looks like the tests failed for Python 3.9 and 3.10 because Python 3.11 changed how Enums are formatted by default: https://docs.python.org/3/whatsnew/3.11.html#enum

I.e. they now get printed as IntervalStrategy.STEPS instead of "steps" (the string they represent).

  • Tom Aarsen

@tomaarsen tomaarsen requested a review from Copilot December 2, 2024 12:25

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no suggestions.

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.

2 participants