llm data_error ai_generated partial

ValueError:在缓存的序列中遇到未知的 token ID 100000。分词器词汇表不匹配。

ValueError: Encountered unknown token ID 100000 in cached sequence. Tokenizer vocabulary mismatch.

ID: llm/tokenizer-mismatch-cache-miss

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
1证据数
2024-03-15首次发现

版本兼容性

版本状态引入弃用备注
transformers 4.35.0 active
tokenizers 0.14.0 active
vLLM 0.3.0 active
Llama 2 70B active
Mistral 7B active

根因分析

缓存的 token 化序列是由不同版本或模型的分词器生成的,当前分词器无法识别缓存中的 token ID。

English

Cached tokenized sequences were generated with a different tokenizer version or model, and the current tokenizer does not recognize token IDs from the cache.

generic

官方文档

https://huggingface.co/docs/tokenizers/main/en/api/reference#tokenizers.Tokenizer.decode

解决方案

  1. 使缓存失效并使用当前分词器重新生成。对于 Hugging Face 数据集,运行:`dataset.cleanup_cache_files()` 并使用 `load_from_disk(new_path)` 重新加载。
  2. 如果使用 vLLM 或类似推理引擎,设置环境变量 `VLLM_USE_PREEMPTIVE_MODE=1` 以禁用 token 缓存,代价是推理速度稍慢。
  3. 在 requirements.txt 中固定分词器版本(例如 `tokenizers==0.14.0`),并使用一致的模型快照(例如 `model_name_or_path='meta-llama/Llama-2-7b-hf'`)。

无效尝试

常见但无效的做法:

  1. 60% 失败

    The cache will be regenerated using the same mismatched tokenizer, and the error will reappear when the tokenizer or model is updated again.

  2. 80% 失败

    Mapping unknown IDs to [UNK] discards semantic meaning and degrades model output quality, and the tokenizer may still reject the IDs during decoding.

  3. 90% 失败

    The error is not related to fast vs slow tokenizer mode; it is a vocabulary mismatch that persists across both modes.