docs(readme): align with canonical source-of-truth (cond-5 adapters, source-file control, refined extractor)

#10
Files changed (1) hide show
  1. README.md +78 -50
README.md CHANGED
@@ -25,40 +25,50 @@ pipeline_tag: text-generation
25
 
26
  QLoRA adapters fine-tuned on multilingual code conditions for the **Language Decoded** project (part of [Cohere's Tiny Aya Expedition](https://aya.for.ai)).
27
 
 
 
28
  ## ⚠️ Phase 3 eval numbers β€” read the experiments repo before citing
29
 
30
  Original Phase 3 `_summary_*.json` files on [`legesher/language-decoded-experiments`](https://huggingface.co/datasets/legesher/language-decoded-experiments) **under-report cond-5 SIB-200 accuracy by 20–35pp** because the strict inference-time extractor refused native-script answers. Cite the `_summary_reparsed_*.json` siblings (refined extractor) instead. **Five** Phase 3 SIB-200 conclusions also flip winβ†’loss against baseline once the extractor is corrected (`cond-2-es-5k`, `cond-2-es-20k`, `cond-2-ur-20k`, `cond-2-zh-20k`, `cond-3-zh-5k`), and `cond-2-ur-5k`'s gain deflates 4.4Γ—. See the [banner on the experiments repo](https://huggingface.co/datasets/legesher/language-decoded-experiments) (top of the README) for the full picture.
31
 
32
  ## Research Question
33
 
34
- > Does fine-tuning on non-English code improve multilingual reasoning β€” and is the benefit language-dependent or structure-dependent?
 
 
35
 
36
  ## Base Model
37
 
38
- All adapters are trained on [CohereLabs/tiny-aya-base](https://huggingface.co/CohereLabs/tiny-aya-base) (3.35B parameters).
 
 
 
 
39
 
40
- ## Model Structure
 
 
 
 
 
 
 
41
 
42
- This repo is the canonical hub for the trained-from-scratch LoRA adapters, organized by experimental condition:
43
 
44
- | Subdirectory | Condition | Training Data |
45
- | --------------------- | ----------- | ----------------------------------------------------- |
46
- | `condition-1-en-32k/` | Condition 1 | English Python from The Stack Dedup (full 32k corpus) |
47
- | `condition-1-en-5k/` | Condition 1 | English Python from The Stack Dedup (5k subset) |
48
- | `condition-2-zh-5k/` | Condition 2 | Chinese keyword-swapped Python (Legesher-transpiled) |
49
- | `condition-2-es-5k/` | Condition 2 | Spanish keyword-swapped Python (Legesher-transpiled) |
50
- | `condition-2-ur-5k/` | Condition 2 | Urdu keyword-swapped Python (Legesher-transpiled) |
51
- | `condition-3-zh-5k/` | Condition 3 | Transpiled + native Chinese code (blended) |
52
 
53
- **Cond-5 (cross-lingual transfer)** is an evaluation pattern that re-uses condition-2 adapters with cross-language prompting β€” see [`phase3/conditions/condition-5-{zh,es,ur}-5k/`](https://huggingface.co/datasets/legesher/language-decoded-experiments/tree/main/phase3/conditions) on the experiments repo for the cross-lingual eval results.
54
 
55
- ### The Experimental Ladder
56
 
57
- - **Baseline --> 1**: Does code help at all?
58
- - **1 --> 2**: Does the language of keywords matter?
59
- - **2 --> 3**: Does diversity of native-language sources add value beyond keyword swap?
60
- - **3 --> 4**: Does code written in the cultural context of a language carry unique signal?
61
- - **--> 5**: Does shared script or language family create transfer effects when an adapter trained on one language is prompted in another?
 
 
62
 
63
  ## Usage
64
 
@@ -70,25 +80,41 @@ from peft import PeftModel
70
  base_model = AutoModelForCausalLM.from_pretrained("CohereLabs/tiny-aya-base")
71
  tokenizer = AutoTokenizer.from_pretrained("CohereLabs/tiny-aya-base")
72
 
73
- # Load a LoRA adapter (e.g., Condition 1 β€” English code)
74
- model = PeftModel.from_pretrained(base_model, "legesher/language-decoded-lora", subfolder="condition-1-en-5k")
75
-
76
- # Load a language-specific adapter (e.g., Condition 2 β€” Chinese keyword-swapped)
77
- model = PeftModel.from_pretrained(base_model, "legesher/language-decoded-lora", subfolder="condition-2-zh-5k")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  ```
79
 
80
  ## Training Details
81
 
82
- | Parameter | Value |
83
- | ------------------ | ------------------------------------------------------------------------------------------------ |
84
- | Base model | [CohereLabs/tiny-aya-base](https://huggingface.co/CohereLabs/tiny-aya-base) (3.35B params) |
85
- | Method | QLoRA 4-bit (NF4), ~5.4GB VRAM |
86
- | Hardware | Kaggle T4 (16GB) |
87
- | Tokenizer | CohereLabs/tiny-aya-base |
88
- | Transpilation tool | [Legesher](https://github.com/legesher/legesher) v0.7.3 |
89
- | Training data | [legesher/language-decoded-data](https://huggingface.co/datasets/legesher/language-decoded-data) |
 
90
 
91
- ### QLoRA Hyperparameters
92
 
93
  | Parameter | Value |
94
  | --------------- | ------------------------------------------------------------- |
@@ -103,38 +129,40 @@ model = PeftModel.from_pretrained(base_model, "legesher/language-decoded-lora",
103
 
104
  ## Evaluation
105
 
106
- Models are evaluated on multilingual reasoning benchmarks with dual prompts (English + language-specific). Phase 3 adds SIB-200 and Belebele to the Phase 2 benchmark set.
 
 
 
 
 
 
 
107
 
108
- | Benchmark | What it measures | Phase | Examples per language |
109
- | --------- | -------------------------- | ----- | --------------------- |
110
- | MGSM | Math reasoning | 2, 3 | 250 |
111
- | X-CSQA | Commonsense reasoning | 2, 3 | ~1,000 |
112
- | XNLI | Natural language inference | 2, 3 | ~5,000 |
113
- | SIB-200 | Topic classification | 3 | ~204 |
114
- | Belebele | Reading comprehension | 3 | ~900 |
115
 
116
- Eval results live at [`legesher/language-decoded-experiments`](https://huggingface.co/datasets/legesher/language-decoded-experiments). **Cite `_summary_reparsed_*.json` files for Phase 3 numbers** β€” see the banner above.
117
 
118
  ## Limitations
119
 
120
- - **Single base model**: All adapters are trained on CohereLabs/tiny-aya-base (3.35B params). Results may not generalize to larger or architecturally different models.
121
- - **Limited training data**: Each condition uses a 5k-file subset for QLoRA fine-tuning, constrained by Kaggle T4 hardware limits.
122
- - **Evaluation scope**: Currently evaluated on 5 benchmarks (MGSM, X-CSQA, XNLI, SIB-200, Belebele). Other reasoning tasks may show different patterns.
123
- - **Consumer hardware**: Training on Kaggle T4 (16GB) with 4-bit quantization introduces approximation that may affect adapter quality compared to full-precision training.
124
- - **Extractor coverage**: Phase 3 inference-time extractor under-counts native-script SIB-200 answers; refined post-hoc extractor recovers them. See the banner above and [`expedition-tiny-aya/analysis/phase-3/phase3-refined-evaluation.md`](https://github.com/legesher/research/blob/main/expedition-tiny-aya/analysis/phase-3/phase3-refined-evaluation.md) on the research repo.
125
 
126
  ## Related Resources
127
 
 
128
  - **Training data**: [legesher/language-decoded-data](https://huggingface.co/datasets/legesher/language-decoded-data)
129
- - **Community code**: [legesher/language-decoded-community](https://huggingface.co/datasets/legesher/language-decoded-community)
130
- - **Experiment tracking**: [legesher/language-decoded-experiments](https://huggingface.co/datasets/legesher/language-decoded-experiments)
131
  - **Transpilation tool**: [Legesher on GitHub](https://github.com/legesher/legesher)
132
 
133
  ## Citation
134
 
135
  ```bibtex
136
  @misc{language-decoded-2026,
137
- title={Language Decoded: Investigating Language-Dependent vs. Structure-Dependent Reasoning Benefits of Code},
138
  author={Madison Edgar and Saad Ahmed Bazaz and Tom Sherborne and Rashik Shahjahan and Khojasteh Mirza and Sarah Jawaid and Rafay Mustafa and Sohaib Ahmed Bazaz},
139
  year={2026},
140
  publisher={Hugging Face},
 
25
 
26
  QLoRA adapters fine-tuned on multilingual code conditions for the **Language Decoded** project (part of [Cohere's Tiny Aya Expedition](https://aya.for.ai)).
27
 
28
+ > **Submitted paper title (2026-05-26):** _Language, Decoded: Exploring the Impact of Fine-Tuning a Multilingual Model on Native-Language Code_
29
+
30
  ## ⚠️ Phase 3 eval numbers β€” read the experiments repo before citing
31
 
32
  Original Phase 3 `_summary_*.json` files on [`legesher/language-decoded-experiments`](https://huggingface.co/datasets/legesher/language-decoded-experiments) **under-report cond-5 SIB-200 accuracy by 20–35pp** because the strict inference-time extractor refused native-script answers. Cite the `_summary_reparsed_*.json` siblings (refined extractor) instead. **Five** Phase 3 SIB-200 conclusions also flip winβ†’loss against baseline once the extractor is corrected (`cond-2-es-5k`, `cond-2-es-20k`, `cond-2-ur-20k`, `cond-2-zh-20k`, `cond-3-zh-5k`), and `cond-2-ur-5k`'s gain deflates 4.4Γ—. See the [banner on the experiments repo](https://huggingface.co/datasets/legesher/language-decoded-experiments) (top of the README) for the full picture.
33
 
34
  ## Research Question
35
 
36
+ > **How does fine-tuning Tiny Aya on non-English code β€” whether transpiled, mixed-native, or fully translated β€” affect its multilingual reasoning and instruction-following, and how does that impact _differ_ from fine-tuning on English code?**
37
+
38
+ The hypothesis is **not** that non-English code matches or exceeds English code as a generic reasoning aid β€” rather, that the _kind_ of effect non-English code produces depends on the target language, the data structure, and how the corpus was constructed. See [legesher/language-decoded-experiments](https://huggingface.co/datasets/legesher/language-decoded-experiments) for the full project context.
39
 
40
  ## Base Model
41
 
42
+ All adapters are trained on [CohereLabs/tiny-aya-base](https://huggingface.co/CohereLabs/tiny-aya-base) (3.35B parameters). Tiny Aya was chosen because it is small (deployable on a single 16 GB T4 GPU via QLoRA), accessible (Apache 2.0-licensed), and supports 70+ languages with explicit emphasis on lower-resourced ones β€” which makes the experimental ladder viable for `ur` at all.
43
+
44
+ ## Adapter Inventory
45
+
46
+ Each subdirectory is one trained condition Γ— file-volume Γ— seed combination. All adapters share the QLoRA hyperparameters listed under [Training Details](#training-details).
47
 
48
+ | Subdirectory | Condition | Training data | Seeds |
49
+ | ----------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
50
+ | `condition-1-en-5k-seed{42,123,456}/` | 1 | Raw English Python from `bigcode/the-stack-v2-dedup` (5k file subset) | 42, 123, 456 |
51
+ | `condition-1-en-20k-seed42/` | 1 | Raw English Python (20k file subset) | 42 |
52
+ | `condition-2-{zh,es,ur}-5k-seed{42,123,456}/` | 2 | The **same 5k subset as cond-1**, processed through Legesher v0.7.3 β€” Python's reserved words (keywords, exceptions, built-in functions, numerical system for some target languages) translated to the target language; user logic preserved | 42, 123, 456 |
53
+ | `condition-2-{zh,es,ur}-20k-seed42/` | 2 | The **same 20k subset as cond-1**, processed through Legesher v0.7.3 | 42 |
54
+ | `condition-3-zh-5k-native-code-seed42/` | 3 | Community-collected raw Chinese code from varied online public-source repositories (different source-file population from cond-1/2/5 by design) | 42 |
55
+ | `condition-5-{zh,es,ur}-5k-c4ai-aya-expanse-32b-seed42/` | 5 | The **same 5k subset as cond-1**, first transpiled by Legesher v0.7.3 to translate Python's reserved words, then run through `c4ai-aya-expanse-32b` via the Cohere API to translate the remaining content (identifiers, comments, docstrings, string literals) | 42 |
56
 
57
+ **Condition 4 ("Community-Contributed Native Code")** is pending sufficient direct community contributions to the [`legesher/legesher-native-code`](https://huggingface.co/spaces/legesher/legesher-native-code) HF Space; no cond-4 adapter exists yet.
58
 
59
+ ### Source-file control
 
 
 
 
 
 
 
60
 
61
+ Cond-1, cond-2, and cond-5 all train on the **same 5,000-file subset** drawn from `bigcode/the-stack-v2-dedup` (with a parallel 20k subset for the 20k tier). Differences across these conditions reflect the processing pipeline (raw / transpiled / fully translated), not file-quality or content drift. Cond-3 is the deliberate exception β€” its source files are a different population by design.
62
 
63
+ ### The experimental ladder
64
 
65
+ - **Baseline β†’ cond-1**: Does code help at all? (Replicates [Aryabumi et al., 2024](https://arxiv.org/abs/2408.10914).)
66
+ - **Cond-1 β†’ cond-2**: Does translating Python's reserved words (keywords, exceptions, built-in functions, numerical system for some target languages) into the target language change the model's behavior? User logic and library calls remain English-derived.
67
+ - **Cond-2 β†’ cond-3**: Does code pulled from real-world public-source repositories β€” code humans actually wrote in or with the target language β€” add value beyond Legesher's mechanical translation?
68
+ - **Cond-2 β†’ cond-5**: Cond-2 translates only Python's reserved words; cond-5 goes further by translating the rest of the file's content (identifiers, comments, docstrings, string literals) via `c4ai-aya-expanse-32b`. Logic and structure are preserved.
69
+ - **Cond-3 β†’ cond-5** (implicit): Human-authored vs. machine-synthesized native code.
70
+
71
+ For the full ladder including future directions (natural-language text control, combined-language training, similar-script evaluation), see [legesher/language-decoded-experiments](https://huggingface.co/datasets/legesher/language-decoded-experiments).
72
 
73
  ## Usage
74
 
 
80
  base_model = AutoModelForCausalLM.from_pretrained("CohereLabs/tiny-aya-base")
81
  tokenizer = AutoTokenizer.from_pretrained("CohereLabs/tiny-aya-base")
82
 
83
+ # Load a LoRA adapter β€” e.g., cond-1 (English code, seed 42, 5k tier)
84
+ model = PeftModel.from_pretrained(
85
+ base_model,
86
+ "legesher/language-decoded-lora",
87
+ subfolder="condition-1-en-5k-seed42",
88
+ )
89
+
90
+ # Or a language-specific cond-2 adapter (Chinese reserved-word translation, seed 42)
91
+ model = PeftModel.from_pretrained(
92
+ base_model,
93
+ "legesher/language-decoded-lora",
94
+ subfolder="condition-2-zh-5k-seed42",
95
+ )
96
+
97
+ # Or a cond-5 adapter (Synthesized Native Code, Urdu, seed 42)
98
+ model = PeftModel.from_pretrained(
99
+ base_model,
100
+ "legesher/language-decoded-lora",
101
+ subfolder="condition-5-ur-5k-c4ai-aya-expanse-32b-seed42",
102
+ )
103
  ```
104
 
105
  ## Training Details
106
 
107
+ | Parameter | Value |
108
+ | ------------------ | ------------------------------------------------------------------------------------------------------ |
109
+ | Base model | [CohereLabs/tiny-aya-base](https://huggingface.co/CohereLabs/tiny-aya-base) (3.35B params, 70+ languages, low-resource emphasis) |
110
+ | Method | QLoRA 4-bit (NF4), ~5.4 GB VRAM, Unsloth-accelerated |
111
+ | Hardware | Kaggle T4 (16 GB) |
112
+ | Tokenizer | `CohereLabs/tiny-aya-base` |
113
+ | Transpilation tool | [Legesher](https://github.com/legesher/legesher) v0.7.3 (Phase 3); v0.5.1 / v0.6.0 used in Phase 2 |
114
+ | Cond-5 translation | [`c4ai-aya-expanse-32b`](https://huggingface.co/CohereLabs/aya-expanse-32b) accessed via the Cohere API (made possible by Cohere credits awarded to Legesher) |
115
+ | Training data | [legesher/language-decoded-data](https://huggingface.co/datasets/legesher/language-decoded-data) |
116
 
117
+ ### QLoRA hyperparameters
118
 
119
  | Parameter | Value |
120
  | --------------- | ------------------------------------------------------------- |
 
129
 
130
  ## Evaluation
131
 
132
+ Phase 3 models are evaluated on four multilingual benchmarks under `template1` (English-prompt) and `template2` (native-prompt) across the full `data_lang Γ— instr_lang` matrix:
133
+
134
+ | Benchmark | What it measures | Examples per language |
135
+ | --------- | -------------------------- | --------------------- |
136
+ | XNLI | Natural-language inference | ~5,000 |
137
+ | X-CSQA | Commonsense reasoning | ~1,000 |
138
+ | SIB-200 | Topic classification | ~204 |
139
+ | Belebele | Reading comprehension | ~900 |
140
 
141
+ MGSM was used in Phase 2 and **dropped from Phase 3** β€” at 3.35B parameters and 250 examples per language, scores ranged 2.8% – 10.8% across all conditions with most condition-to-condition differences within noise. A useful null result; budget was reallocated to SIB-200 and Belebele.
 
 
 
 
 
 
142
 
143
+ Paper-grade evaluation results live on [`legesher/language-decoded-experiments`](https://huggingface.co/datasets/legesher/language-decoded-experiments) β€” see the refined-tables and the writeup at [`expedition-tiny-aya/analysis/phase-3/phase3-refined-evaluation.md`](https://github.com/legesher/research/blob/main/expedition-tiny-aya/analysis/phase-3/phase3-refined-evaluation.md).
144
 
145
  ## Limitations
146
 
147
+ - **Single base model**: All adapters are trained on `CohereLabs/tiny-aya-base` (3.35B params). Results may not generalize to larger or architecturally different models. Future iterations will expand to additional base models.
148
+ - **Per-language fine-tuning only**: Every condition is per-language β€” each `cond-2-{zh,es,ur}-5k` (and `cond-5-{zh,es,ur}-5k`) is a separate training run. Combined-language training is a planned future condition.
149
+ - **Limited training data**: 5k and 20k file tiers are constrained by Kaggle T4 hardware limits. 103k variants exist on the [training data repo](https://huggingface.co/datasets/legesher/language-decoded-data) but no 103k adapters have been trained yet.
150
+ - **Consumer hardware**: Training on Kaggle T4 (16 GB) with 4-bit quantization introduces approximation that may affect adapter quality compared to full-precision training.
151
+ - **Extractor coverage** β€” when citing Phase 3 results, use the refined-extractor scores. See the banner at the top of this card and the experiments repo for full details.
152
 
153
  ## Related Resources
154
 
155
+ - **Experiment tracking and results**: [legesher/language-decoded-experiments](https://huggingface.co/datasets/legesher/language-decoded-experiments) (canonical project source-of-truth)
156
  - **Training data**: [legesher/language-decoded-data](https://huggingface.co/datasets/legesher/language-decoded-data)
157
+ - **Community native code**: [legesher/language-decoded-community](https://huggingface.co/datasets/legesher/language-decoded-community)
158
+ - **Cond-4 contribution interface**: [`legesher/legesher-native-code`](https://huggingface.co/spaces/legesher/legesher-native-code) HF Space
159
  - **Transpilation tool**: [Legesher on GitHub](https://github.com/legesher/legesher)
160
 
161
  ## Citation
162
 
163
  ```bibtex
164
  @misc{language-decoded-2026,
165
+ title={Language Decoded: Exploring the Impact of Native Code on Multilingual Models},
166
  author={Madison Edgar and Saad Ahmed Bazaz and Tom Sherborne and Rashik Shahjahan and Khojasteh Mirza and Sarah Jawaid and Rafay Mustafa and Sohaib Ahmed Bazaz},
167
  year={2026},
168
  publisher={Hugging Face},