| from transformers import AutoTokenizer |
| import os |
|
|
| |
| MODEL_PATH = "/home/at0842/ycl466704.ai13/.cache/huggingface/hub/models--openai--gpt-oss-20b/snapshots/6cee5e81ee83917806bbde320786a8fb61efebee" |
|
|
| if not os.path.exists(MODEL_PATH): |
| print(f"❌ 錯誤:找不到模型路徑 {MODEL_PATH}") |
| exit() |
|
|
| print(f"⏳ 正在初始化 Tokenizer...") |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True) |
|
|
| |
| |
| special_ids = tokenizer.all_special_ids |
|
|
| print("\n" + "="*50) |
| print(f"📊 官方定義的特殊 ID 列表 (共 {len(special_ids)} 個):") |
| print(special_ids) |
| print("="*50) |
|
|
| |
| print("\n🔍 特殊 ID 與對應文字明細:") |
| for tid in sorted(special_ids): |
| t_text = tokenizer.decode([tid]) |
| |
| print(f"ID: {tid:7} | Text: {repr(t_text):15}") |
|
|
| |
| |
| print("\n" + "="*50) |
| print("💡 額外檢查:Added Tokens (自定義標籤)") |
| added_tokens = tokenizer.get_added_vocab() |
| for token_str, token_id in sorted(added_tokens.items(), key=lambda x: x[1]): |
| if token_id not in special_ids: |
| print(f"ID: {token_id:7} | Text: {repr(token_str):15} (不在官方 special_ids 內)") |