Buckets:
| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| colab | 1 items | ||
| data | 2 items | ||
| figures | 6 items | ||
| logs | 11 items | ||
| model | 13 items | ||
| notebooks | 2 items | ||
| outputs | 4 items | ||
| prompts | 2 items | ||
| results | 37 items | ||
| src | 24 items | ||
| tests | 10 items | ||
| MODEL_SELECTION.md | 12.6 kB xet | 28df8844 | |
| Mahmoud Zaher_Writeup.pdf | 37.2 kB xet | 5ce0481c | |
| PLAN.md | 12.5 kB xet | 518efcca | |
| README.md | 21.6 kB xet | d3ade306 | |
| WORKLOG.md | 30.2 kB xet | 52dde5dc | |
| config.yaml | 1.12 kB xet | 9fe62d37 | |
| env.txt | 447 Bytes xet | 214942a5 | |
| pytest.ini | 27 Bytes xet | 68808996 | |
| requirements.txt | 14.3 kB xet | 46d37785 |
Eastern Arabic digits: does a small model treat the same number the same way?
This bucket holds my evaluation of Qwen/Qwen3.5-4B on numbers written in Western, Eastern Arabic and Persian digits. It has the evaluation set, the code, every raw model output, the scored outputs, the result tables, the figures and the notebook.
1. The blind spot
In Egypt, many numbers I see every day are written in Eastern Arabic digits (٠١٢٣٤٥٦٧٨٩). They appear on receipts, bills, car plates and official forms, often mixed with Western digits on the same page. At work, I extract data from Arabic financial statements, where an amount looks like ١٢٬٤٥٠٫٧٥. It uses an Arabic thousands separator (٬) and an Arabic decimal separator (٫), and negative values are written in parentheses.
Math and numeric benchmarks are almost always written with Western digits. The Arabic benchmarks I know of mostly test language understanding and rarely vary the numeral system. So a model can score well on both and still misread or miscalculate numbers in the way many Arabic speakers actually write them. In finance, this matters. If the model confuses the two separators, ١٢٫٥٠٠ becomes 12,500 instead of 12.5.
I test whether a small frontier model treats the same number the same way when only its digits change. I also test where it breaks: reading the number, converting it, comparing it or calculating with it.
2. Model and setup
Model. I evaluated Qwen/Qwen3.5-4B at Hub commit 851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a. It has 4,659,865,088 parameters by the count of its safetensors headers (results/model_search/param_count_Qwen__Qwen3.5-4B.json). It is an official instruction-tuned release from February 2026 that takes text and images, and its family goes up to a 397B mixture-of-experts model with the same mix of linear-attention and full-attention layers. MODEL_SELECTION.md explains the choice among 48 candidates and names google/gemma-4-E2B-it as runner-up. model/Qwen3.5-4B/ holds the model files of that commit, copied from the Hub. The file .gitattributes, which only sets git storage rules, was not copied.
Hardware. All model runs ran on a Colab server with one Tesla T4 GPU (15.6 GB), Python 3.13.15, torch 2.11.0 built for CUDA 13.0 and transformers 5.17.0 (env.txt, full package list in requirements.txt). Scoring, statistics and figures need no GPU.
Data. data/eval_set.jsonl has 5 tasks with 100 base items each. Every base item has 6 twins, which are 3 numeral systems (Western, Eastern Arabic and Persian) times 2 prompt languages (English and Modern Standard Arabic). Twins share the same values and differ only in digits and instruction language, so there are 3,000 prompts. Persian digits are a control. Most look like Eastern Arabic digits, but every code point is different. Difficulty factors are crossed over the base items: integer length (1 to 4, 5 to 8 or 9 to 12 digits), with or without 2 decimals, and with or without thousands separators.
| Task | What the model is asked | Subtypes |
|---|---|---|
| Copy | Repeat one amount exactly | none |
| Convert | Write the amount in the other digits, with the separators stated in the prompt | none |
| Compare | Say which of two amounts (A or B) is larger | 50 hard pairs of equal length, 50 easy pairs of different length |
| Compute | Add two amounts, or give the percent change rounded to 2 decimals | 50 sums, 50 percent changes |
| Statement QA | Read a short income statement with negatives in parentheses and answer one question | 50 lookups of one line, 50 sums of two lines |
Decoding. I used greedy decoding in bf16, the model's own chat template with thinking turned off (enable_thinking=False), one system prompt for all conditions (its Arabic translation for Arabic prompts) and at most 128 new tokens (config.yaml). No output reached that limit. Prompts ran one at a time. In the pilot, batched and unbatched outputs differed on 2 of 20 prompts (results/pilot/batch_check.json), and batches would have mixed prompts of different numeral systems. The fast kernels for the linear-attention layers were not installed, so transformers used its reference PyTorch code. The main run generated 0.925 prompts per second (10.3 new tokens per second) with a peak of 9.21 GB of GPU memory (results/run/throughput_full.jsonl).
How the runs were made. The main run and the probe ran from a terminal on the Colab server with the runner colab/fit_colab.py, because a browser session could not stay connected for the 50 minutes of the main run. The runner carries the project code with its SHA-256 hash, saves the results every 5 minutes and resumes after a disconnect. Every output line records the hash of the code that made it. The notebook holds the same code. On a Colab T4 it regenerated 30 of the saved prompts, one for each pair of task and twin type, and all 30 new outputs equaled the saved outputs (the check cell of notebooks/fit_eval.ipynb). It then rebuilt every table and figure from the saved outputs. The runner logs are in logs/.
Scoring. All scoring is rule-based (src/score.py). One parser reads numbers in all three digit systems and both prompt languages in the same way. A test checks that it accepts every gold answer written in every system. Copy and convert need an exact string match after Unicode normalization (NFC). Compare needs the right option. Compute and statement QA need a value within 0.005 of the exact answer. Every wrong answer gets one error type. PLAN.md, written before any model run, fixes the hypotheses, metrics, tests and the rule for what counts as a gap. WORKLOG.md records every change and every look at the data.
Statistics. Accuracy per cell has Wilson 95% intervals. The main test compares Western against Eastern Arabic and Western against Persian within each task and prompt language, on the same 100 base items. That gives 20 comparisons. Each uses an exact McNemar test, with a paired bootstrap interval for the accuracy difference (10,000 resamples), and the 20 p-values get the Holm correction. A comparison shows a gap if its Holm-adjusted p-value is below 0.05 and its 95% interval excludes zero.
3. Results
Main comparisons
8 of the 20 comparisons show a gap. The table gives correct answers out of 100 per cell (results/full/accuracy_by_cell.csv) and the drop from Western with its 95% interval (results/full/paired_tests.csv).
| Task | Prompts | Western | Eastern Arabic | Persian | Drop to Eastern Arabic (points) | Drop to Persian (points) | Gap |
|---|---|---|---|---|---|---|---|
| Copy | English | 100 | 100 | 100 | 0 (0 to 0) | 0 (0 to 0) | none |
| Copy | Arabic | 64 | 5 | 0 | 59 (47 to 70) | 64 (54 to 73) | both |
| Convert | English | 83 | 91 | 90 | -8 (-17 to 1) | -7 (-16 to 2) | none |
| Convert | Arabic | 85 | 79 | 91 | 6 (-4 to 16) | -6 (-14 to 2) | none |
| Compare | English | 100 | 84 | 88 | 16 (9 to 24) | 12 (6 to 19) | both |
| Compare | Arabic | 98 | 91 | 90 | 7 (2 to 13) | 8 (2 to 14) | none |
| Compute | English | 63 | 31 | 37 | 32 (23 to 41) | 26 (17 to 35) | both |
| Compute | Arabic | 51 | 31 | 32 | 20 (12 to 28) | 19 (12 to 27) | both |
| Statement QA | English | 74 | 72 | 72 | 2 (-5 to 9) | 2 (-4 to 8) | none |
| Statement QA | Arabic | 69 | 64 | 62 | 5 (-1 to 11) | 7 (2 to 13) | none |
Three intervals exclude zero without a gap by the rule. On compare with Arabic prompts the Holm-adjusted p-values are 0.43 and 0.26, and for Persian on statement QA with Arabic prompts it is 0.43. I count these as no evidence of a gap. For copy with English prompts both intervals lie within 5 points, so any gap there is smaller than 5 points. Twin consistency, the share of base items where all 6 twins are correct, was 0 of 100 on copy, 62 on convert, 81 on compare, 25 on compute and 56 on statement QA (results/full/twin_consistency.csv).
Compute
On the compute task with English prompts, accuracy dropped from 63 to 31 of 100 when the same numbers were written in Eastern Arabic digits (95% interval for the drop: 23 to 41 points, 100 paired items). With Arabic prompts it dropped from 51 to 31 (12 to 28 points). Persian gave the same picture. The drop comes from the sums. Western sums were right in 49 of 50 items with both prompt languages. Eastern Arabic sums were right in 27 of 50 with English prompts and 30 of 50 with Arabic prompts, and Persian sums in 32 and 31 (results/full/accuracy_by_factor.csv). Percent changes were near the floor in every system, between 1 and 14 correct of 50, so they cannot show a gap.
The drop grows with the length of the numbers. With 9 to 12 integer digits, compute items with English prompts were right in 17 of 32 Western twins, 1 of 32 Eastern Arabic twins and 5 of 32 Persian twins. With 1 to 4 digits they were right in 29, 24 and 22 of 36. Wrong compute answers were also further from the truth in Eastern Arabic. With English prompts the median relative error of a wrong answer was 0.064 for Eastern Arabic (69 wrong answers) against 0.0026 for Western (37 wrong answers) (results/full/relative_errors.csv).
Copy and convert
On the copy task with Arabic prompts, exact copies dropped from 64 to 5 of 100 with Eastern Arabic digits (interval for the drop: 47 to 70 points) and to 0 of 100 with Persian digits (54 to 73 points). This is a change of format, not of value. The value was right in 97 Eastern Arabic and 99 Persian replies, but the model wrote it in Western digits (results/full/secondary_by_cell.csv). With Western digits and Arabic prompts, the model dropped the thousands separators in 25 of 100 replies and wrote the number in Arabic words in 11. With English prompts it copied all 300 items exactly.
On convert I found no gap. The errors sit in the items with thousands separators. Items without separators were right in 48 to 50 of 50 in every cell, and items with separators in 30 to 43 of 50. In 7 conversions into Eastern Arabic digits the model wrote the Arabic decimal separator ٫ in every separator position, for example ٥٥٧٫٧٤٢٫٩٦٥٫١٤٧٫٥٤ for 557,742,965,147.54. PLAN.md says that a number with more than one decimal separator has no value, so these count as parse failures. In substance they are separator confusions of the kind the blind spot section describes.
Compare
On the compare task with English prompts, accuracy dropped from 100 to 84 of 100 with Eastern Arabic digits (9 to 24 points) and to 88 with Persian digits (6 to 19 points). An analysis that I did not plan shows a pattern in these errors. On easy pairs the two amounts differ in length. When the shorter amount starts with the larger digit, the model was right on 42 of 42 Western twins, 27 of 42 Eastern Arabic twins (95% interval 49% to 77%) and 26 of 42 Persian twins (47% to 75%), counting both prompt languages. When the first digits agree with the order, it was right on 56 and 57 of 58 (results/full/compare_first_digit.csv). In Arabic-script digits the model often seems to compare the first digits instead of the length. This result is exploratory.
Statement QA and the digits of the answer
On statement QA I found no gap. All 50 lookups were right in every cell. The two-line sums were right in 12 to 24 of 50, with fewer correct in Arabic-script digits and with Arabic prompts, but the paired tests do not show a gap. Answers to Eastern Arabic and Persian questions came back in Western digits. This happened in 99 or 100 of 100 statement QA replies and in 60 to 66 of 100 compute replies, with both prompt languages (results/full/secondary_by_cell.csv).
Error types
Separator confusion was not the main error in Arabic-script digits. It was the type of 19 of 352 wrong Eastern Arabic answers and 9 of 338 wrong Persian answers, against 40 of 213 wrong Western answers (results/full/error_types_by_system.csv). Most Western ones are separators dropped on copy or misplaced on convert into Eastern Arabic digits. The most common specific type in Arabic-script digits was the switch to Western digits on copy, with 92 Eastern Arabic and 99 Persian answers.
Tokenization and the linear probe
The tokenizer uses one token for each Western digit and two byte tokens for each Eastern Arabic or Persian digit (results/mechanism/tokens_per_digit.csv). The first byte is the same for all ten digits of a system, so only the second token says which digit it is. The number 538 takes 3 tokens in Western digits and 6 in Eastern Arabic or Persian digits (results/mechanism/tokenization_examples.json). Because no Eastern Arabic digit is one token, I did not run the comparison of digit embeddings.
For the probe I wrote the same 2,000 random integers of 1 to 12 digits in each numeral system inside one English and one Arabic carrier sentence (data/probe_set.jsonl). At every layer I fit ridge regression from the hidden state at the last token of the number to log10 of the value. The probe was trained on 80% of the values and tested on the other 20%, with the same split in every system. The reading rules were fixed in PLAN.md before the run. The results are in results/probe_r2.csv and results/mechanism/probe_reading.csv.
| Carrier sentence | Numeral system | Reading | Western probe on this system, best R squared (layer) | Western probe on Western, same layer | Probe within this system, best R squared |
|---|---|---|---|---|---|
| English | Eastern Arabic | mixed | 0.886 (11) | 0.9995 | 0.9986 |
| English | Persian | mixed | 0.893 (11) | 0.9995 | 0.999 |
| Arabic | Eastern Arabic | shared encoding | 0.976 (15) | 0.9998 | 0.9991 |
| Arabic | Persian | shared encoding | 0.974 (16) | 0.9997 | 0.9992 |
With the Arabic carrier, a probe trained on Western numbers reads Eastern Arabic and Persian numbers almost as well as Western ones. With the English carrier it reaches 0.886 and 0.893, which misses the rule for a shared encoding (within 0.1 of the Western value) by about 0.01. Because log10 of these values mostly reflects their length, I also probed the mantissa, which depends only on the leading digits. This part is exploratory. Probes trained within Eastern Arabic or Persian predict it with R squared of 0.97 to 0.98, but the Western probe stays at or below 0.50 on Arabic-script numbers at every layer and is often far below zero. So the size of a number is carried in a form the three systems largely share, and its leading digits are carried in a form that differs between Western and Arabic-script digits. The compare errors follow the first digit, but the probe shows that the length can be read from the hidden state, so those errors do not come from a missing length signal. A probe shows what the hidden state contains, not how the model uses it.
Hypotheses
| Hypothesis in PLAN.md | Result |
|---|---|
| H1. Accuracy drops with Eastern Arabic digits in every task and both prompt languages | Holds for compute, for compare with English prompts and for copy with Arabic prompts, where only the digits of the answer change. Not found for convert or statement QA |
| H2. Persian drops about as much as Eastern Arabic | Holds. The two are close in every task. The largest exploratory difference is convert with Arabic prompts, 79 against 91 of 100 (results/full/exploratory_tests.csv) |
| H3. The drop grows with the number of digits | Holds for compute. Not for compare or statement QA |
| H4. Answers to Arabic-script questions often use Western digits, more often with English prompts | Holds for the first part. Not more often with English prompts |
| H5. Wrong Arabic-script answers are more often separator confusions | Does not hold |
4. Path forward
The easy fix is to convert all digits to Western form before the model sees them. That helps with typed text. It does not help when the model reads a scanned page, and it gives the wrong format to users who need the answer in their own digits. I think the gap should be closed inside the model.
Data curation. I would take existing math, table and finance training data and rewrite the numbers into Eastern Arabic and Persian digits with the correct separators, keeping the answers the same. I would also add real Arabic documents where these digits appear naturally, such as financial statements and government forms, instead of relying only on text translated from English.
Fine-tuning. I would train on twin inputs that differ only in the numeral system. A consistency term would push the model to give the same answer and similar hidden states at the number tokens for both versions. This works well with low-rank adaptation (LoRA) and needs little data.
Tokenizer and embeddings. The Qwen3.5 tokenizer handles Eastern digits differently from Western digits. It splits every Eastern Arabic and Persian digit into two byte pieces, while every Western digit is one token. I would make it treat both digit sets the same way, with one token for each Eastern digit. I would also initialize the embeddings of these new tokens from the matching Western digits, so the model starts from the number knowledge it already has.
Output format. I would train the model to answer in the numeral system the user wrote in, unless the user asks for another one.
5. Limitations
This is one model of 4.7B parameters, on templated synthetic items, with greedy decoding and one prompt wording per task and language. The results describe this model under these conditions and are not a claim about other models. I did not run the second model, so I cannot say whether the gaps come from the tokenizer, from the training data or from both. Each cell has 100 items, so differences below about 10 points are hard to detect, and three comparisons with intervals that exclude zero did not pass the Holm correction. Percent changes and two-line statement sums were near the floor and lookups at the ceiling in every system, which leaves little room to see a gap on those subtypes. The first-digit pattern on compare and the mantissa probe were not planned and need a test on new items. The model ran without its fast kernels and on a T4 without native bf16. The smoke test gave the same replies in bf16 and fp16, but I did not compare the two dtypes on the full set. I did not run the optional extension with statement images.
6. How to reproduce
The tests and all tables and figures need only Python with the packages in requirements.txt. Run these from the bucket root.
python -m pytest
python -m src.score outputs/raw/full.jsonl outputs/scored/full.jsonl
python -m src.report full outputs/scored/full.jsonl results/full
python -m src.probe results/probe_r2.csv results/mechanism/probe_reading.csv
python -m src.figures results/full figures results/probe_r2.csv
To see the model run, open notebooks/fit_eval.ipynb in Colab with a T4 GPU and run all cells. The notebook reads the code and the saved outputs from notebooks/fit_bundle.tar.gz, which it downloads from this bucket and checks against its SHA-256 hash. With RUN_MODEL = True it loads the model, regenerates 30 saved prompts and compares them with the saved outputs. With RERUN = True it generates all 3,000 outputs and the probe again, which takes about 75 minutes on a T4.
For a full rerun that survives disconnects, upload colab/fit_colab.py to a Colab GPU server and run python3 fit_colab.py full, then python3 fit_colab.py probe, in its terminal. Each run writes /content/fit_results_<phase>.tar.gz. python -m src.colab_sync unpack <archive> checks the hashes and writes the results into the project. python -m src.colab_sync runner fit_colab.py writes a new runner from the current code. The attached runner is the version that ran the probe. The main run used two earlier versions that differ from it only in their checkpoint, resume and probe code (WORKLOG.md).
7. Files
README.md, this fileMahmoud Zaher_Writeup.pdf, the write-up of my fellowship applicationmodel/Qwen3.5-4B/, the model files at commit 851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0aPLAN.md, the plan fixed before any model runWORKLOG.md, the log of every run, look at the data and changeMODEL_SELECTION.md, the model search and the choiceconfig.yaml, model id, commit, seeds, decoding settings and pinned packagesenv.txtandrequirements.txt, the environment of the main rundata/eval_set.jsonl, the 3,000 evaluation prompts with gold answers and metadatadata/probe_set.jsonl, the 12,000 probe sentencesprompts/, the English and Arabic templatesoutputs/raw/, raw model outputs with the rendered prompts and settings (full.jsonlfor the main run,pilot.jsonlfor the pilot)outputs/scored/, scored outputsresults/full/, all tables of the main runresults/probe_r2.csvandresults/mechanism/, probe and tokenization resultsresults/pilot/,results/run/andresults/model_search/, pilot tables, throughput and model searchfigures/, the figures in this READMEnotebooks/fit_eval.ipynb, the notebook with its outputs from a Colab T4notebooks/fit_bundle.tar.gz, the code and saved outputs that the notebook unpackscolab/fit_colab.py, the terminal runner used on Colablogs/, the logs and environment files of every Colab runsrc/andtests/, the code and its tests
- Total size
- 9.36 GB
- Files
- 121
- Last updated
- Oct 19
- Pre-warmed CDN
- US EU US EU





