Fix AttributeError: remove removed batch_encode_plus fallback in FiD tokenizer#71
Fix AttributeError: remove removed batch_encode_plus fallback in FiD tokenizer#71cmacdonald with Copilot wants to merge 2 commits into
batch_encode_plus fallback in FiD tokenizer#71Conversation
…r_encode batch_encode_plus was removed from the public API of HuggingFace tokenizers. Modern tokenizers (transformers>=4.44.2) support being called directly, so the try/except fallback is no longer needed.
batch_encode_plus fallback in FiD tokenizer
|
@copilot I don't get it -- why wasn't the fallback working before? |
The try/except in the interim fix ( In short: the fallback tried to call a method that no longer exists, and the wrong exception type was caught. Since modern transformers (≥4.44.2, as already required) support calling the tokenizer directly without |
|
@copilot I still don't get it. Previously, Now |
Correct — that's the key point. The CI ran with transformers 5.12.1, and in that version, |
|
@copilot so does this PR just act as a tidy up? Not fixing a problem? |
Looking at the CI logs on So yes, in practice this is a tidy-up: in modern transformers the direct Given that, I'd like to check: should this PR be kept as-is (removing dead/confusing code), or would you prefer to close it and revert the change since there's no active breakage? |
transformersremovedbatch_encode_plusfrom the public tokenizer API, causingtest_BARTandtest_T5to fail withAttributeError: RobertaTokenizer/T5Tokenizer has no attribute batch_encode_plus.Changes
pyterrier_rag/readers/_fid_models.py: Remove thetry/except TypeErrorfallback intokenizer_encodethat calledself.tokenizer.batch_encode_plus(...). Replace with a direct tokenizer call, which has been the canonical API since well before the project'stransformers>=4.44.2minimum.