File size: 826 Bytes
9936912
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Inspect how the Qwen tokenizer represents control-engineering terms."""

from transformers import AutoTokenizer


MODEL_ID = "Qwen/Qwen3-4B-Instruct-2507"

EXAMPLES = [
    "the",
    "of",
    "atakan",
    "nonlinear dynamic inversion",
]


tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)

print(f"Tokenizer class: {type(tokenizer).__name__}")
print(f"Vocabulary size: {len(tokenizer):,}")

for text in EXAMPLES:
    token_ids = tokenizer.encode(text, add_special_tokens=False)
    raw_tokens = tokenizer.convert_ids_to_tokens(token_ids)
    readable_pieces = [tokenizer.decode([token_id]) for token_id in token_ids]

    print(f"\nText: {text!r}")
    print(f"Token count: {len(token_ids)}")
    print(f"Token IDs: {token_ids}")
    print(f"Raw tokens: {raw_tokens}")
    print(f"Decoded pieces: {readable_pieces}")