Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41645 +/- ##
=========================================
Coverage 58.72% 58.73%
Complexity 2314 2314
=========================================
Files 1135 1135
Lines 170486 170488 +2
Branches 1499 1499
=========================================
+ Hits 100124 100137 +13
+ Misses 67818 67807 -11
Partials 2544 2544
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
stop reviewer notifications |
There was a problem hiding this comment.
📋 Review Summary
This PR cleanly resolves two issues blocking direct:py313:transformersInferenceTest: it handles single-element batches where Hugging Face pipelines (such as QuestionAnsweringPipeline) return a bare dict instead of a list[dict], and it updates the masked language modeling example and integration tests to use FacebookAI/roberta-base and tokenizer(...) for transformers>=5 compatibility.
🔍 General Feedback
- Wrapping bare
dictpredictions inside_default_pipeline_inference_fnwhenlen(batch) == 1is well-scoped, as it fixes built-in Hugging Face pipeline behavior without breaking custominference_fnimplementations that rely onutils._convert_to_resulttransposing columnar dicts. - Inlining
_EXPECTED_MASKED_LM_OUTPUTSinhuggingface_inference_it_test.pypreserves backwards compatibility for release branches referencing the existing GCS golden file. - Unit and integration test coverage is thorough and well-structured.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
…ng and MLM IT - huggingface_inference.py & huggingface_inference_test.py: wrap single-dict predictions returned by Hugging Face pipelines (e.g. QuestionAnsweringPipeline on batch size 1) in a list inside _default_pipeline_inference_fn before utils._convert_to_result, fixing the regression from #36593 while preserving custom inference_fn implementations that return columnar dicts (e.g. Beam YAML). - huggingface_inference_it_test.py, huggingface_language_modeling.py, README.md: replace the deleted/private stevhliu/my_awesome_eli5_mlm_model Hub checkpoint with FacebookAI/roberta-base (inlining expected outputs so the shared GCS golden file is unchanged) and replace removed tokenizer.encode_plus with tokenizer(...) for transformers 5.x compatibility.
6d17cd5 to
c92f42e
Compare
jrmccluskey
left a comment
There was a problem hiding this comment.
LGTM, big fan of inlining the expected output in tests for clarity
|
Stopping reviewer notifications for this pull request: requested by reviewer. If you'd like to restart, comment |
Part of #41652 (stack: https://github.com/apache/beam/stack/41650).
Stack 2/6 — Fixes two issues blocking
direct:py313:transformersInferenceTest:HuggingFacePipelineModelHandlersingle-element batch regression (huggingface_inference.py,huggingface_inference_test.py):HuggingFacePipelineModelHandler.run_inferencetoutils._convert_to_result, Hugging Face pipelines that return a singledict(instead of alist[dict]) for batch size 1 — such asQuestionAnsweringPipeline— crashed withTypeError: 'float' object is not iterablebecauseutils._convert_to_resulttreats a baredictas a columnar dict of batch-length iterables.isinstance(predictions, dict) and len(batch) == 1into[predictions]inside_default_pipeline_inference_fnso built-in HF pipelines work for batch size 1 while custominference_fnimplementations that intentionally return columnar dicts (such as Beam YAML'sruninference_huggingface.yaml) remain untouched.inference_fns.Unavailable third-party Hub model &
transformers>=5tokenizer call (huggingface_inference_it_test.py,huggingface_language_modeling.py,examples/inference/README.md):stevhliu/my_awesome_eli5_mlm_modelwithFacebookAI/roberta-base, inlining_EXPECTED_MASKED_LM_OUTPUTSinhuggingface_inference_it_test.pyso the shared GCS golden file is left unchanged for older release branches.tokenizer.encode_plus(...)withtokenizer(...)inhuggingface_language_modeling.pyfortransformers>=5compatibility.Verification
direct:py313:transformersInferenceTest(3/3 passed) locally and in PostCommit Python (3.13) run 45406881889.