[Bug]: TransformersTokenizer vocabulary queries raise NotImplementedError

Abierto
#23,252 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@JunkaiWang-TheoPhy ya está trabajando en esto.

Desde el 2/12/2026.

  • #23254 de @JunkaiWang-TheoPhy — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
15.2k
Forks
3k
Merge medio
2 d 21 h
PR fusionados (30 d)
477

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/TensorRT-LLM

Todos los issues de NVIDIA/TensorRT-LLM

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.