[Bug]: TransformersTokenizer vocabulary queries raise NotImplementedError

Đang mở
#23,252 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@JunkaiWang-TheoPhy đang làm issue này rồi.

Từ ngày 2/12/2026.

  • #23254 của @JunkaiWang-TheoPhy — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Find the TransformersTokenizer implementation and its tests in the TensorRT-LLM repository; the issue does not name their paths. Read how the wrapper delegates encoding and get_added_vocab(), then compare its vocabulary methods with the underlying Transformers tokenizer. Done when the three reproduction assertions pass; linked pull request #23254 is already open.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Frontend
System Info

TensorRT-LLM main ef375f87565b89a5818e705c735ec59a182efb86. Reproduced on Python 3.12/macOS ARM64 with Hugging Face Transformers and an in-memory Rust-backed WordLevel tokenizer. No GPU, model weights, or network is needed for the example. Native TensorRT startup was bypassed in the local CPU harness.

Reproduction
from tokenizers import Tokenizer
from tokenizers.models import WordLevel
from transformers import PreTrainedTokenizerFast

from tensorrt_llm.tokenizer import TransformersTokenizer

raw = PreTrainedTokenizerFast(
    tokenizer_object=Tokenizer(WordLevel({"<unk>": 0, "fox": 1}, unk_token="<unk>")),
    unk_token="<unk>",
)
raw.add_tokens(["whale"])
wrapped = TransformersTokenizer(raw)

assert wrapped.get_vocab() == raw.get_vocab()
assert len(wrapped) == len(raw) == 3
assert wrapped.vocab_size == raw.vocab_size == 2
Expected behavior

The wrapper should expose the underlying tokenizer's vocabulary map and distinguish the full length including added tokens from its base vocabulary size.

Actual behavior

All three wrapper operations raise NotImplementedError from PreTrainedTokenizerBase. The underlying tokenizer supports all three operations.

Additional notes

The wrapper already delegates encoding, decoding, token conversion, and get_added_vocab(); vocabulary introspection uses inherited base stubs instead. See the Transformers tokenizer interface. Searches for TransformersTokenizer get_vocab, TokenizerBase get_vocab, and vocabulary-related NotImplementedError did not identify an equivalent fix.

OpenAI Codex assisted with the reproduction.

Ngôn ngữ chính
Python
Star
15.2k
Fork
3k
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
477

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/TensorRT-LLM

Tất cả issue của NVIDIA/TensorRT-LLM

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.