{
  "id": "llm/tokenizer-mismatch-cache-miss",
  "signature": "ValueError: Encountered unknown token ID 100000 in cached sequence. Tokenizer vocabulary mismatch.",
  "signature_zh": "ValueError：在缓存的序列中遇到未知的 token ID 100000。分词器词汇表不匹配。",
  "regex": "ValueError: Encountered unknown token ID \\d+ in cached sequence\\. Tokenizer vocabulary mismatch\\.",
  "domain": "llm",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Cached tokenized sequences were generated with a different tokenizer version or model, and the current tokenizer does not recognize token IDs from the cache.",
  "root_cause_type": "generic",
  "root_cause_zh": "缓存的 token 化序列是由不同版本或模型的分词器生成的，当前分词器无法识别缓存中的 token ID。",
  "versions": [
    {
      "version": "transformers 4.35.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tokenizers 0.14.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "vLLM 0.3.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Llama 2 70B",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Mistral 7B",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The cache will be regenerated using the same mismatched tokenizer, and the error will reappear when the tokenizer or model is updated again.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Mapping unknown IDs to [UNK] discards semantic meaning and degrades model output quality, and the tokenizer may still reject the IDs during decoding.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The error is not related to fast vs slow tokenizer mode; it is a vocabulary mismatch that persists across both modes.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Invalidate the cache and regenerate it with the current tokenizer. For Hugging Face datasets, run: `dataset.cleanup_cache_files()` and reload with `load_from_disk(new_path)`.",
      "success_rate": 0.9,
      "how": "Invalidate the cache and regenerate it with the current tokenizer. For Hugging Face datasets, run: `dataset.cleanup_cache_files()` and reload with `load_from_disk(new_path)`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using vLLM or similar inference engines, set environment variable `VLLM_USE_PREEMPTIVE_MODE=1` to disable token caching at the cost of slightly slower inference.",
      "success_rate": 0.75,
      "how": "If using vLLM or similar inference engines, set environment variable `VLLM_USE_PREEMPTIVE_MODE=1` to disable token caching at the cost of slightly slower inference.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Pin the tokenizer version in your environment by specifying `tokenizers==0.14.0` in requirements.txt and using a consistent model snapshot (e.g., `model_name_or_path='meta-llama/Llama-2-7b-hf'`).",
      "success_rate": 0.85,
      "how": "Pin the tokenizer version in your environment by specifying `tokenizers==0.14.0` in requirements.txt and using a consistent model snapshot (e.g., `model_name_or_path='meta-llama/Llama-2-7b-hf'`).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使缓存失效并使用当前分词器重新生成。对于 Hugging Face 数据集，运行：`dataset.cleanup_cache_files()` 并使用 `load_from_disk(new_path)` 重新加载。",
    "如果使用 vLLM 或类似推理引擎，设置环境变量 `VLLM_USE_PREEMPTIVE_MODE=1` 以禁用 token 缓存，代价是推理速度稍慢。",
    "在 requirements.txt 中固定分词器版本（例如 `tokenizers==0.14.0`），并使用一致的模型快照（例如 `model_name_or_path='meta-llama/Llama-2-7b-hf'`）。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/tokenizers/main/en/api/reference#tokenizers.Tokenizer.decode",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}