Skip to content

Replace removed tokenizer.encode_plus in DatasetEncoder - #2636

Open
rrrxxx0510 wants to merge 1 commit into
open-compass:mainfrom
rrrxxx0510:fix/topk-retriever-encode-plus
Open

Replace removed tokenizer.encode_plus in DatasetEncoder#2636
rrrxxx0510 wants to merge 1 commit into
open-compass:mainfrom
rrrxxx0510:fix/topk-retriever-encode-plus

Conversation

@rrrxxx0510

Copy link
Copy Markdown

Fixes #2635

encode_plus was removed in transformers 5.x, so any run using TopkRetriever (which encodes few-shot examples through DatasetEncoder) crashes:

AttributeError: Qwen2Tokenizer has no attribute encode_plus

Same class of breakage as #2573. The tokenizer call API is a drop-in replacement here — for a single string it returns the same [1, L] input_ids / attention_mask tensors, and verbose is still accepted.

Verified with a real Qwen2Tokenizer on transformers 5.16: the old call raises the AttributeError above, the direct call produces the same per-sample [L] tensors DatasetEncoder stores.

encode_plus was removed in transformers 5.x, so any run using
TopkRetriever (which encodes few-shot examples via DatasetEncoder)
crashes on import-time call:

    AttributeError: Qwen2Tokenizer has no attribute encode_plus

The tokenizer call API is a drop-in replacement here: for a single
string it returns the same [1, L] input_ids / attention_mask tensors,
and verbose is still accepted.

Verified with a real Qwen2Tokenizer on transformers 5.16: the old call
raises the AttributeError above, the direct call produces the same
per-sample [L] tensors DatasetEncoder stores.
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.

TopkRetriever crashes on transformers 5.x: tokenizer.encode_plus was removed

2 participants