{
  "id": "huggingface/tokenizer-extra-special-tokens-invalid",
  "signature": "ValueError: Adding special tokens to a tokenizer that already has them; use `add_special_tokens=True` only if you intend to add new tokens. Got extra_ids=0 but tokenizer already has 2 special tokens.",
  "signature_zh": "ValueError：向已有特殊标记的分词器添加特殊标记；只有在打算添加新标记时才使用 `add_special_tokens=True`。收到 extra_ids=0，但分词器已有 2 个特殊标记。",
  "regex": "Adding special tokens to a tokenizer that already has them",
  "domain": "huggingface",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "User called `tokenizer.add_special_tokens()` with an empty or redundant special tokens dictionary, but the tokenizer already has those tokens defined, causing a validation error.",
  "root_cause_type": "generic",
  "root_cause_zh": "用户使用空的或冗余的特殊标记字典调用了 `tokenizer.add_special_tokens()`，但分词器已定义这些标记，导致验证错误。",
  "versions": [
    {
      "version": "tokenizers 0.19.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "transformers 4.44.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The parameter `add_special_tokens` controls whether to add tokens to the vocabulary, not whether to check for duplicates; the error persists.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Deleting built-in special tokens (like [CLS], [SEP]) can break tokenizer functionality; re-adding may still fail if they are already present in the base tokenizer.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check existing special tokens before adding: if `tokenizer.special_tokens_map` already contains the tokens, skip the `add_special_tokens` call entirely.",
      "success_rate": 0.9,
      "how": "Check existing special tokens before adding: if `tokenizer.special_tokens_map` already contains the tokens, skip the `add_special_tokens` call entirely.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `tokenizer.add_special_tokens({'additional_special_tokens': ['<new_token>']})` only for truly new tokens, not duplicates.",
      "success_rate": 0.85,
      "how": "Use `tokenizer.add_special_tokens({'additional_special_tokens': ['<new_token>']})` only for truly new tokens, not duplicates.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Check existing special tokens before adding: if `tokenizer.special_tokens_map` already contains the tokens, skip the `add_special_tokens` call entirely.",
    "Use `tokenizer.add_special_tokens({'additional_special_tokens': ['<new_token>']})` only for truly new tokens, not duplicates."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/tokenizers/en/api/special-tokens",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-05-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}