File size: 11,858 Bytes
cc7d399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483737b
 
cc7d399
 
 
 
 
483737b
 
 
 
 
 
cc7d399
 
483737b
 
cc7d399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483737b
cc7d399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483737b
 
 
 
 
 
 
 
cc7d399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483737b
 
 
 
 
cc7d399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483737b
 
 
 
 
 
 
cc7d399
 
 
 
483737b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc7d399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483737b
cc7d399
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
---
license: cc-by-4.0
task_categories:
- automatic-speech-recognition
- translation
language:
- ps
- ur
- ar
- fa
- hi
- bn
- ml
- ta
- so
- ka
tags:
- script-fidelity
- multilingual-asr
- fleurs
- evaluation
- neurips-eandd
pretty_name: Script fidelity benchmark
size_categories:
- 1K<n<10K
configs:
- config_name: main_results
  data_files:
  - split: data
    path: analysis/sf_results.csv
- config_name: gemma4_baseline_results
  data_files:
  - split: data
    path: results_gemma4/sf_results.csv
- config_name: gemma4_prompt_mitigation
  data_files:
  - split: data
    path: analysis/gemma4_prompt_mitigation_summary.csv
- config_name: gemma4_downstream_mt_summary
  data_files:
  - split: data
    path: analysis/gemma4_downstream_mt_summary.csv
- config_name: gemma4_downstream_mt_correlations
  data_files:
  - split: data
    path: analysis/gemma4_downstream_mt_correlations.csv
- config_name: gemma4_downstream_mt_utterances
  data_files:
  - split: data
    path: analysis/gemma4_downstream_mt_utterances.csv
- config_name: sfr_lid_hybrid_summary
  data_files:
  - split: data
    path: analysis/sfr_lid_hybrid_summary.csv
- config_name: sfr_lid_hybrid_utterances
  data_files:
  - split: data
    path: analysis/sfr_lid_hybrid_utterances.csv
---

# Script fidelity benchmark

Anonymous supplement for the paper "Script collapse in multilingual ASR:
A reference-free metric and 100-pair benchmark."

Script Fidelity Rate (SFR) measures the fraction of ASR hypothesis characters
that belong to the expected target script. WER measures word edits, while SFR
checks whether the output is written in the target orthography.

Related resources:

- PyPI package: <https://pypi.org/project/script-fidelity/>
- Hugging Face Evaluate metric: <https://huggingface.co/spaces/themechanism/script_fidelity_rate>
- Load with Evaluate: `evaluate.load("themechanism/script_fidelity_rate", module_type="metric")`

## Scope

The paper benchmark contains 100 evaluated model-language pairs on FLEURS test
splits:

| Language | Script | FLEURS code | Role |
|---|---|---|---|
| Pashto | Perso-Arabic | `ps_af` | collapse target |
| Urdu | Perso-Arabic | `ur_pk` | control |
| Arabic | Perso-Arabic | `ar_eg` | control |
| Persian | Perso-Arabic | `fa_ir` | control |
| Hindi | Devanagari | `hi_in` | collapse target |
| Bengali | Bengali | `bn_in` | collapse target |
| Malayalam | Malayalam | `ml_in` | collapse target |
| Tamil | Tamil | `ta_in` | extension |
| Somali | Latin | `so_so` | collapse target |
| Georgian | Georgian | `ka_ge` | collapse target |

Evaluated models:

| Family | Model identifiers |
|---|---|
| Whisper | `openai/whisper-tiny`, `openai/whisper-base`, `openai/whisper-small`, `openai/whisper-medium`, `openai/whisper-large-v2`, `openai/whisper-large-v3`, `openai/whisper-large-v3-turbo` |
| MMS-1B | `facebook/mms-1b-all` |
| SeamlessM4T-v2 | `facebook/seamless-m4t-v2-large` |
| Gemma 4 | `unsloth/gemma-4-E2B-it` |

All ten languages, including Pashto, are evaluated directly on FLEURS.

## Repository layout

```text
scripts/
  eval_multilang.py      Main evaluation driver
  script_fidelity.py     SFR metric implementation
  merge_gemma4.py        Merges Gemma 4 results and regenerates figures
  eval_downstream_mt.py  Downstream MT validation for Gemma 4 outputs
  eval_sfr_lid_hybrid.py SFR+LID audit for saved Gemma 4 outputs
  run_gemma4.sh          Convenience wrapper for the Gemma 4 baseline run
analysis/
  sf_results.csv         Main result table plus six supplemental Pashto rows
  gemma4_downstream_mt_summary.csv        MT validation summary
  gemma4_downstream_mt_correlations.csv   MT validation correlations
  sfr_lid_hybrid_summary.csv              SFR+LID audit summary
results_gemma4/
  sf_results.csv         Gemma 4 result table
results_gemma4_prompt_mitigation/
  sf_results.csv         Gemma 4 script-aware prompt result table
results_gemma4_downstream_mt/
  translations/          NLLB translations for gold, baseline, and script-hint text
figures/
  sfr_heatmap.pdf        SFR matrix figure
  wer_vs_sfr_scatter.pdf WER-vs-SFR figure
croissant_metadata.json  Artifact metadata with Responsible AI fields
LICENSE                 CC-BY-4.0 license notice
requirements.txt         Python package requirements
```

The general SFR library is published separately as `script-fidelity` on PyPI:
<https://pypi.org/project/script-fidelity/>. The import name is
`script_fidelity`. This artifact keeps a bundled `scripts/script_fidelity.py`
for exact reproduction of the submitted benchmark.

The same metric is available as a Hugging Face Evaluate community metric:
<https://huggingface.co/spaces/themechanism/script_fidelity_rate>.

## Setup

Python 3.10 or newer is recommended. Use `uv` for all environment and package
management.

```bash
uv venv
uv pip install torch --index-url https://download.pytorch.org/whl/cu121
uv pip install -r requirements.txt
```

`datasets==2.21.0` is pinned because `google/fleurs` still uses a dataset script.
Install CUDA-compatible `torch` from the cu121 index on common cloud GPU images.
The scripts route Hugging Face, evaluate, and temporary files to a writable cache
root. Set `SFR_CACHE_ROOT=/path/to/cache` to override the default.

## Running the evaluation

Full ASR inference is expensive and was already completed for the submitted
results. The commands below reproduce the run configuration.

```bash
uv run python scripts/eval_multilang.py \
    --hf-token "$HF_TOKEN" \
    --results-dir ./analysis \
    --hub-repo "$ANONYMIZED_OUTPUT_REPO" \
    --languages pashto hindi bengali malayalam somali georgian urdu arabic persian tamil \
    --whisper-sizes tiny base small medium large-v2 large-v3 turbo \
    --run-mms --run-seamless
```

To refresh an existing model-language row in `sf_results.csv`, add `--force`.

Gemma 4 was run separately with instruction-following transcription:

```bash
uv run python scripts/eval_multilang.py \
    --results-dir ./results_gemma4 \
    --languages pashto urdu arabic persian hindi bengali malayalam tamil somali georgian \
    --run-gemma4 \
    --whisper-sizes
```

Gemma 4 uses the prompt:

```text
Transcribe the following speech segment in its original language. Follow these specific instructions for formatting the answer:
* Only output the transcription, with no newlines.
* When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, and write 3 instead of three.
```

Whisper uses forced language tokens and greedy decoding (`num_beams=1`).
Whisper, MMS-1B, and SeamlessM4T use `float16` on CUDA. Gemma 4 uses
`bfloat16` on Apple MPS.

## Gemma 4 script-aware prompting

The mitigation experiment compares the baseline Gemma 4 prompt above against a
script-aware prompt on the same ten FLEURS test splits.
The script-aware arm uses:

```text
Transcribe the following speech segment in {language_name}. Use {script_name} script only. Do not translate, romanize, or add explanations.
Only output the transcription, with no newlines.
When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, and write 3 instead of three.
```

Run the experiment after `results_gemma4/sf_results.csv` contains all ten Gemma
baseline rows:

```bash
uv run python scripts/eval_gemma4_prompt_mitigation.py
```

The script writes:

```text
results_gemma4_prompt_mitigation/sf_results.csv
results_gemma4_prompt_mitigation/predictions/gemma4_script_hint_{language}_predictions.json
analysis/gemma4_prompt_mitigation_summary.csv
```

## Downstream MT validation

The downstream check asks whether script errors damage a later text pipeline. It
translates gold FLEURS transcripts, baseline Gemma 4 ASR outputs, and
script-aware Gemma 4 ASR outputs into English, then scores chrF and BLEU against
the aligned English FLEURS reference. The default MT model is
`facebook/nllb-200-distilled-600M`, which supports FLORES-style language codes
for the ten paper languages.

Run the deadline-friendly diagnostic subset:

```bash
uv run python scripts/eval_downstream_mt.py \
    --max-examples-per-language 100 \
    --sample-mode stratified_sfr
```

Run the full aligned set when time permits:

```bash
uv run python scripts/eval_downstream_mt.py \
    --max-examples-per-language 0 \
    --sample-mode random
```

The script writes:

```text
results_gemma4_downstream_mt/translations/{mt_model}_{language}_{variant}_translations.json
analysis/gemma4_downstream_mt_summary.csv
analysis/gemma4_downstream_mt_utterances.csv
analysis/gemma4_downstream_mt_correlations.csv
```

Use NLLB as the primary MT model. Gemma can be used as a secondary sensitivity
check, but it should not be the main downstream evaluator because Gemma also
produces the ASR outputs in this experiment.

## SFR+LID hybrid audit

The hybrid audit runs language identification over saved Gemma 4 outputs only.
It does not rerun ASR.

```bash
uv run python scripts/eval_sfr_lid_hybrid.py
```

The script writes:

```text
analysis/sfr_lid_hybrid_summary.csv
analysis/sfr_lid_hybrid_utterances.csv
```

## Regenerating figures

```bash
uv run python scripts/merge_gemma4.py
```

This command merges Gemma 4 rows into `analysis/sf_results.csv` and regenerates
the heatmap and scatter figures in `figures/`. The plotting code filters the
main figures to the 100 model-language pairs reported in the paper.

## Result fields

`analysis/sf_results.csv` has one row per evaluated model-language pair. The
paper's 100-pair matrix is the subset with `family` in `Whisper`, `MMS`,
`SeamlessM4T`, or `Gemma4`. The six rows with `family=unknown` are supplemental
Pashto-only comparisons and are not used in the paper denominator, family
summaries, heatmap, or collapse counts.

| Column | Meaning |
|---|---|
| `model` | Hugging Face model identifier |
| `family` | Model family used for paper grouping |
| `language` | Target language |
| `wer_pct` | Word error rate after language-specific normalisation |
| `cer_pct` | Character error rate after language-specific normalisation |
| `sfr_mean` | Mean utterance-level Script Fidelity Rate, in percent |
| `sfr_full_pct` | Percent of utterances with SFR = 100% |
| `sfr_zero_pct` | Percent of utterances with SFR = 0% |
| `dom_*` | Dominant-script utterance counts |

## SFR library

For standalone use outside this artifact, install the published package:

```bash
uv add script-fidelity
```

Then import it as `script_fidelity`:

```python
from script_fidelity import compute_sfr

compute_sfr("کابل کې ښه هوا ده", language="ps_af")
compute_sfr("kabul ke sha hawa da", language="pashto")
compute_sfr("नमस्ते", language="hindi")
```

One-off CLI use:

```bash
uvx --from script-fidelity sfr score --language ps_af --text "کابل کې ښه هوا ده"
```

Hugging Face Evaluate use:

```python
import evaluate

sfr = evaluate.load("themechanism/script_fidelity_rate", module_type="metric")
sfr.compute(
    predictions=["کابل کې ښه هوا ده", "romanized output"],
    language="ps_af",
)
```

The validation script has already been run for the submitted artifact. It checks
known positive and negative examples for Pashto, Hindi, and Somali.

## Licenses and responsible release

FLEURS is CC BY 4.0. Whisper is MIT licensed. MMS-1B and SeamlessM4T-v2 are
released under Meta's research licenses. Gemma 4 E2B is Apache-2.0 through the
evaluated checkpoint. This supplement releases code, metadata, and evaluation
outputs only; it releases no model weights and no new speech recordings.

See `croissant_metadata.json` for artifact metadata, intended use, limitations,
PII status, and Responsible AI fields.

## Anonymous citation

```bibtex
@misc{Anonymous2026ScriptFidelity,
  author = {Anonymous},
  title = {Script collapse in multilingual ASR: A reference-free metric and 100-pair benchmark},
  year = {2026},
  note = {Anonymous submission}
}
```