scripts/language_probe.py probes how a model's tokenizer and input-embedding table represent different languages — without downloading full model weights or needing a GPU.
It downloads only tokenizer.json (+ config.json) and, with --embeddings, fetches just the needed rows of embed_tokens.weight (or wte/word_embeddings) using HTTP Range requests against the Hub CDN.
Run it from this skill's folder:
# Probe tokenizer efficiency on the bundled 8-language parallel sample (en, sv, de, fr, fi, ko, zh, ar) uv run -q scripts/language_probe.py probe Qwen/Qwen3-8B utter-project/EuroLLM-9B-Instruct --out probe.json # Also probe input-embedding rows via HTTP range requests (no full checkpoint download) uv run -q scripts/language_probe.py probe Qwen/Qwen3-8B utter-project/EuroLLM-9B-Instruct \ --embeddings --langs en,sv,fi,ko,ar --out probe_emb.json # Fetch a larger parallel corpus from FLORES+ (requires HF_TOKEN with dataset access) python3 scripts/language_probe.py fetch-flores --langs en,sv,da,nb,fi,de,fr,ko,zh,ar --n 200 --out ./flores200 # Correlate structural probe metrics against your own benchmark scores CSV (columns: model,lang,score) python3 scripts/language_probe.py correlate probe_emb.json --scores bench_scores.csv # Render Markdown from any probe receipt python3 scripts/language_probe.py report probe_emb.json
What it measures
| Metric | Scope | What it tells you |
|---|---|---|
tokens_per_word / tokens_per_char | Tokenizer | Fertility — how many tokens are spent per word (space-delimited languages) or per character (zh, ja, th, ...) |
bytes_per_token | Tokenizer | Compression efficiency in UTF-8 bytes per token |
parity_vs_en | Tokenizer (parallel) | Ratio of target-language tokens to English tokens on the exact same parallel sentences (1.0 = parity with English; 2.0 = twice the context cost and latency) |
multi_token_word_rate / heavy_fragment_word_rate | Tokenizer | Share of words split into >= 2 or >= 3 tokens |
sub_char_token_rate | Tokenizer | Share of tokens that split a single Unicode character into byte pieces (strong signal of poor script coverage) |
weighted_norm_ratio | Embeddings (--embeddings) | Occurrence-weighted L2 norm of the language's top tokens divided by the median norm of a random vocabulary baseline |
low_norm_occurrence_rate | Embeddings (--embeddings) | Share of corpus token occurrences whose embedding norm falls below the 2nd percentile of the random baseline (catches undertrained / collapsed token rows) |
mean_centered_cos | Embeddings (--embeddings) | Mean pairwise cosine similarity after subtracting the baseline mean (checks whether a language's tokens collapse into a tight cone) |
Reading results honestly
- Structure != benchmark accuracy: tokenizer efficiency and embedding norms measure *representation overhead and training coverage*, not reasoning quality or factual knowledge. Always use
correlateagainst real benchmark scores before treating a metric as predictive. - Bundled sample vs. full parallel corpus: the bundled corpus in
corpus/sample/has 12 everyday parallel sentences per language — great for fast smoke checks and relative ranking, too small for fine-grained tail-token estimates. Usefetch-flores(or your own parallel<lang>.txtdirectory) for serious studies. - Tokenizer-only repos: requires
tokenizer.json(fast tokenizer format). Legacy SentencePiece-only repos withouttokenizer.jsonare skipped withstatus: missing_tokenizer. - Gated models: set
HF_TOKEN(or log in withhuggingface-cli login) after accepting the model's license; auth headers are stripped automatically on CDN redirects.