Skip to content

Keep evaluator pipeline dispatch compatible with Transformers 5 - #906

Open
snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:fix/evaluator-transformers5-pipeline-dispatch
Open

snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:fix/evaluator-transformers5-pipeline-dispatch

Conversation

@snygginghani

Copy link
Copy Markdown

A supplied pipeline or default model falls through the early isinstance checks and looks up transformers.TFPreTrainedModel even when it will not use TensorFlow. Transformers 5 removed that class, so normal Evaluate calls raise AttributeError. Check for the optional legacy class without requiring it to exist.

I reproduced the failure on Transformers 5.24.1 with a text-generation pipeline built from the published hf-internal-testing/tiny-random-gpt2 checkpoint and passed to evaluate.evaluator("text-generation").compute. With the fix, the pipeline produced output and the local word_count evaluator reported 8 total words and 7 unique words.

The supplied/default dispatch tests failed on main and now pass. The third test preserves dispatch for a legacy TensorFlow model class. Black, isort, flake8 and git diff --check passed.

Prepared with AI assistance.

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.

1 participant