tensorflow/models · error · ValueError
EOS token not in tokenizer vocab.Please make sure the tokeni
Error message
EOS token not in tokenizer vocab.Please make sure the tokenizer generates a single token for an empty string.
What it means
Error "EOS token not in tokenizer vocab.Please make sure the tokenizer generates a single token for an empty string." thrown in tensorflow/models.
Source
Thrown at official/nlp/tasks/translation.py:193
class TranslationTask(base_task.Task):
"""A single-replica view of training procedure.
Tasks provide artifacts for training/evalution procedures, including
loading/iterating over Datasets, initializing the model, calculating the loss
and customized metrics with reduction.
"""
def __init__(self, params: cfg.TaskConfig, logging_dir=None, name=None):
super().__init__(params, logging_dir, name=name)
self._sentencepiece_model_path = params.sentencepiece_model_path
if params.sentencepiece_model_path:
self._sp_tokenizer = tftxt.SentencepieceTokenizer(
model=tf.io.gfile.GFile(params.sentencepiece_model_path, "rb").read(),
add_eos=True)
try:
empty_str_tokenized = self._sp_tokenizer.tokenize("").numpy()
except tf.errors.InternalError:
raise ValueError(
"EOS token not in tokenizer vocab."
"Please make sure the tokenizer generates a single token for an "
"empty string.")
self._eos_id = empty_str_tokenized.item()
self._vocab_size = self._sp_tokenizer.vocab_size().numpy()
else:
raise ValueError("Setencepiece model path not provided.")
if (params.validation_data.input_path or
params.validation_data.tfds_name) and self._logging_dir:
self._references, self._tf_record_input_path = write_test_record(
params.validation_data, self.logging_dir)
def build_model(self) -> tf_keras.Model:
"""Creates model architecture.
Returns:
A model instance.
"""View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/nlp/tasks/translation.py:193 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/52a6d516b81ae68f.
Report an issue: GitHub.