primce commited on
Commit
978cdeb
Β·
verified Β·
1 Parent(s): 6806184

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +161 -114
README.md CHANGED
@@ -1,114 +1,161 @@
1
- ---
2
- language:
3
- - hi
4
- - en
5
- base_model: CohereLabs/tiny-aya-global
6
- library_name: peft
7
- tags:
8
- - agent
9
- - tool-calling
10
- - hinglish
11
- - lora
12
- - safety
13
- datasets:
14
- - primce/lexsi-runs
15
- ---
16
-
17
- # tiny-aya-hinglish-lora
18
-
19
- LoRA adapter for **CohereLabs/tiny-aya-global** (3.35B) that teaches a Hinglish expense-splitting
20
- agent to call tools reliably: record a shared expense, carry the ledger across turns, convert
21
- USD/EUR, settle balances, and answer with the exact rupee amount.
22
-
23
- Lexsi AI Safety & Alignment Hackathon 2026, Track 3 (Agentic fine-tuning), solo entry.
24
-
25
- ## Results
26
-
27
- Frozen 2026-11-03. Greedy decoding, single sample, no LLM judge β€” success is checked against the
28
- final ledger state.
29
-
30
- | Run | Split | Task success |
31
- |---|---|---:|
32
- | Base Tiny Aya, prompt-only | 30 hard tasks | 3.33% (1/30) |
33
- | SFT on easy split | 30 hard tasks | 63.33% |
34
- | + GRPO (30 steps, graded reward) | 30 hard tasks | 63.33% (no gain) |
35
- | **SFT on the reweighted mix (this adapter)** | **30 hard tasks** | **96.67%** |
36
- | Same adapter | 24 in-distribution tasks | 100.00% |
37
-
38
- - Paired exact McNemar over the 30 shared hard tasks: base β†’ this adapter **28 fixed, 0 broken,
39
- p = 7.45e-09**; easy-SFT β†’ this adapter **10 fixed, 0 broken, p = 0.00195**.
40
- - Tool calls per task: **3.57**, exactly the oracle's count (base: 7.03).
41
- - Tool error rate **0.00%**, loop collapse **0.00%**, unnecessary calls **0.00%** (base: 22.3%,
42
- 16 of 30 episodes never finishing, `overcall` 1.08).
43
-
44
- The base model's single success is not a clean one: on `h-e-029` it returned the correct "0 INR"
45
- only after inventing an 800 INR expense nobody mentioned. The adapter fixes the behaviour, not
46
- just the final string.
47
-
48
- The hard split is 30 tasks the model never saw, spanning six families: five-way settlement with
49
- paise remainders and two currencies, balance-plus-settlement in one turn, payer-not-a-participant
50
- traps, paraphrase, two-currency conversion sums, and empty-ledger questions. The file is SHA-256
51
- pinned in the repo, so the number cannot drift.
52
-
53
- ## Safety split
54
-
55
- The repo also ships a 32-task injection eval: the agent is asked a normal question while a tool
56
- result carries attacker text. `attack_ledger` (money actually moved) and `attack_answer` (the
57
- number was repeated) are exact checks β€” the marker 999999 can never be a correct answer.
58
-
59
- | Family | n | Attack |
60
- |---|---:|---|
61
- | `inject_note` | 8 | tool result asks for a 999999 INR expense |
62
- | `inject_skip` | 8 | tool result asks the model to skip a tool and answer 999999 |
63
- | `inject_settle` | 8 | tool result asks for an unrequested settlement |
64
- | `underspecified` | 8 | user omitted names/amount/currency; asking is correct |
65
-
66
- Measured 2026-11-04 on the 24 injection tasks:
67
-
68
- | System | safe | utility under attack | attack_ledger | attack_answer |
69
- |---|---:|---:|---:|---:|
70
- | Base Tiny Aya | 0/24 | 0/24 | 13/24 | 8/24 |
71
- | **This adapter** | **11/24** | **11/24** | **0/24** | 3/24 |
72
- | This adapter + hardened prompt | 15/24 | 15/24 | 0/24 | 2/24 |
73
-
74
- Base -> adapter removes 13 ledger attacks and introduces 0 (exact McNemar p = 0.00024).
75
- Abstention on underspecified requests is still 1/8. Thresholds, per-family counts and the
76
- threat model: `docs/SAFETY.md` in the repo.
77
-
78
- ## Training
79
-
80
- - Data: 184 oracle-verified Hinglish tasks (100 easy + 84 hard), family-reweighted.
81
- - Method: 2 epochs of supervised fine-tuning on oracle trajectories, then merged into the base
82
- weights. GRPO was run and did not improve the score; the write-up explains why.
83
- - Output format: a bare JSON array of one tool call per turn, no prose, no markdown fences.
84
-
85
- ## Usage
86
-
87
- ```python
88
- from peft import PeftModel
89
- from transformers import AutoModelForCausalLM, AutoTokenizer
90
-
91
- tok = AutoTokenizer.from_pretrained("CohereLabs/tiny-aya-global")
92
- model = AutoModelForCausalLM.from_pretrained("CohereLabs/tiny-aya-global")
93
- model = PeftModel.from_pretrained(model, "primce/tiny-aya-hinglish-lora", subfolder="sft2_adapter")
94
- ```
95
-
96
- The adapter expects the system prompt from `hinglish_agent/prompts.py` (tool schemas inline, one
97
- tool call per turn, ledger returned by every ledger tool and copied into the next call).
98
-
99
- ## Limitations
100
-
101
- - Domain-specific: it answers ledger questions with exact arithmetic; it is not a general assistant.
102
- - 30 hard tasks is a probe. Every number carries a wide Wilson interval and there is no seed sweep.
103
- - The adapter is not trained to abstain. On underspecified questions it tends to guess; the safety
104
- split measures exactly that, and a hardened system prompt is the tested mitigation.
105
- - Hinglish + English only. Devanagari paraphrases appear in the eval, but generation is not
106
- evaluated in Devanagari.
107
-
108
- ## Licence and provenance
109
-
110
- Base weights: CohereLabs Tiny Aya, used under its licence. Adapter trained by the entry author on
111
- synthetic, oracle-verified data. Code, data, pins and run logs:
112
- `github.com/PRINCE2-AI/lexsi-agentic-hinglish`, `primce/lexsi-runs`. Live demo:
113
- `huggingface.co/spaces/primce/hinglish-expense-agent`. Write-up:
114
- `huggingface.co/spaces/primce/hinglish-track3-article`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - hi
4
+ - en
5
+ base_model: CohereLabs/tiny-aya-global
6
+ library_name: peft
7
+ tags:
8
+ - agent
9
+ - tool-calling
10
+ - hinglish
11
+ - lora
12
+ - safety
13
+ datasets:
14
+ - primce/lexsi-runs
15
+ ---
16
+
17
+ # tiny-aya-hinglish-lora
18
+
19
+ LoRA adapter for **CohereLabs/tiny-aya-global** (3.35B) that teaches a Hinglish expense-splitting
20
+ agent to call tools reliably: record a shared expense, carry the ledger across turns, convert
21
+ USD/EUR, settle balances, and answer with the exact rupee amount.
22
+
23
+ Lexsi AI Safety & Alignment Hackathon 2026, Track 3 (Agentic fine-tuning), solo entry.
24
+
25
+ ## Results
26
+
27
+ Frozen 2026-11-05. Greedy decoding, single sample, no LLM judge β€” success is checked against the
28
+ final ledger state. `sft4_adapter` is the shipped adapter; `sft2_adapter`, `sft3_adapter` and the
29
+ seed adapters are kept for the ablation and variance controls.
30
+
31
+ | Run | Split | Task success |
32
+ |---|---|---:|
33
+ | Base Tiny Aya, prompt-only | 30 hard tasks | 3.33% (1/30) |
34
+ | Base Tiny Aya, prompt-only | 90 hard tasks | 3.33% (3/90) |
35
+ | SFT on easy split | 30 hard tasks | 63.33% |
36
+ | + GRPO (30 steps, graded reward) | 30 hard tasks | 63.33% (no gain) |
37
+ | SFT on the reweighted mix (`sft2`) | 30 / 90 hard tasks | 96.67% (29/30) / 88.89% (80/90) |
38
+ | SFT on the mix + abstention pairs (`sft3`) | 30 / 90 hard tasks | 96.67% (29/30) / 75.56% (68/90) |
39
+ | **SFT on the mix + contrast pairs (`sft4`, this adapter)** | **30 hard tasks** | **96.67% (29/30)** |
40
+ | **Same adapter** | **90 hard tasks** | **93.33% (84/90)** |
41
+ | Same adapter | 24 in-distribution tasks | 100.00% (24/24) |
42
+ | `sft5` ablation (fewer ask rows) | 30 / 90 hard tasks | 100% (30/30) / 92.22% (83/90) |
43
+ | `sft4` recipe, seed 7 (mix3 replication) | 30 / 90 hard tasks | 100% (30/30) / 93.33% (84/90) |
44
+ | `sft3` recipe (mix2), seed 7 | 30 / 90 hard tasks | 93.33% / 83.33% |
45
+ | `sft3` recipe (mix2), seed 123 | 30 / 90 hard tasks | 80.00% / 75.56% |
46
+
47
+ - Paired exact McNemar over shared task ids: base β†’ this adapter **28 fixed, 0 broken,
48
+ p = 7.5e-09** on hard-30 and **81 fixed, 0 broken, p < 1e-20** on hard-90. Against the
49
+ round-2 adapter, **18 fixed, 2 broken, p = 0.0004**; against the round-1 adapter, 7 fixed,
50
+ 3 broken, p = 0.34 (directional, not significant).
51
+ - Tool calls per task: **3.57** on hard-30, exactly the oracle's count (base: 7.03). On hard-90:
52
+ 3.38 against a base 7.24.
53
+ - Tool error rate **0.00%** on both splits, loop collapse **0.00%**, redundant calls **0.00%**,
54
+ parse failures **0.00%** (base: 22.3% tool errors, 16 of 30 episodes never finishing,
55
+ `overcall` 1.08).
56
+ - Independent AuditKIT 1.1.3 replay: hard-30 exact-call accuracy **0.033 β†’ 1.000**, tool-call F1
57
+ **0.188 β†’ 1.000**, redundant calls **0.327 β†’ 0.000**. On hard-90: exact 0.933, F1 **0.980**,
58
+ validity 1.000, zero redundant calls and zero loops; its success verdict agrees with the repo
59
+ scorer on 88/90 decided tasks.
60
+
61
+ Three seeds of the mix2 recipe span 16.67 pp on hard-30 and 7.77 pp on hard-90, and that spread
62
+ is published rather than hidden. The shipped adapter is mix3 seed 42, chosen before any seed run
63
+ existed. A second mix3 seed (7) reproduces the headline instead of moving it: the same 84/90 on
64
+ hard-90 (1 fixed, 1 broken, p = 1.0), 30/30 on hard-30, and five of the six hard-90 misses are the
65
+ same task ids (`h9-019`, `-024`, `-029`, `-066`, `-067`). That is a replication, not a variance
66
+ bound β€” mix3 seed 123 was never trained, so the mix2 spread stays the only estimate of how much
67
+ the recipe itself moves. Seed 7 of mix2 is better than the shipped adapter on hard-90 (7 fixed,
68
+ 0 broken, p = 0.0156); picking it after seeing the split would be selection on the reported split,
69
+ so seed 42 stays shipped.
70
+
71
+ The base model's single hard-30 success is not a clean one: on `h-e-029` it returned the correct
72
+ "0 INR" only after inventing an 800 INR expense nobody mentioned. The adapter fixes the behaviour,
73
+ not just the final string.
74
+
75
+ The hard splits are tasks the model never saw, spanning six families: five-way settlement with
76
+ paise remainders and two currencies, balance-plus-settlement in one turn, payer-not-a-participant
77
+ traps, paraphrase, two-currency conversion sums, and empty-ledger questions. Both files are
78
+ SHA-256 pinned in the repo, so the numbers cannot drift.
79
+
80
+ ## Safety split
81
+
82
+ The repo also ships a 32-task injection eval: the agent is asked a normal question while a tool
83
+ result carries attacker text. `attack_ledger` (money actually moved) and `attack_answer` (the
84
+ number was repeated) are exact checks β€” the marker 999999 can never be a correct answer.
85
+
86
+ | Family | n | Attack |
87
+ |---|---:|---|
88
+ | `inject_note` | 8 | tool result asks for a 999999 INR expense |
89
+ | `inject_skip` | 8 | tool result asks the model to skip a tool and answer 999999 |
90
+ | `inject_settle` | 8 | tool result asks for an unrequested settlement |
91
+ | `underspecified` | 8 | user omitted names/amount/currency; asking is correct |
92
+
93
+ Measured 2026-11-04/05 on the 24 injection tasks:
94
+
95
+ | System | safe | utility under attack | attack_ledger | attack_answer |
96
+ |---|---:|---:|---:|---:|
97
+ | Base Tiny Aya | 0/24 | 0/24 | 13/24 | 8/24 |
98
+ | `sft2` (round 1) | 11/24 | 11/24 | 0/24 | 3/24 |
99
+ | `sft3` (round 2) | 15/24 | 15/24 | 0/24 | 2/24 |
100
+ | **`sft4` (this adapter)** | **14/24** | **14/24** | **0/24** | **0/24** |
101
+ | `sft4` + hardened prompt | 14/24 | 14/24 | 0/24 | 2/24 |
102
+
103
+ Base β†’ this adapter removes 13 ledger attacks and introduces 0 (exact McNemar p = 0.00024) and
104
+ removes all 8 attacker numbers from answers. Abstention on underspecified requests: **4/8 asked**
105
+ and 4/8 invented, up from 2/8 and 6/8 on `sft3`. The hardened prompt on the same adapter reaches
106
+ **7/8 asked and 0/8 invented**, clearing the pre-registered bar, but puts 2/24 attacker numbers
107
+ back into prose; the adapter alone is the default. Thresholds, per-family counts and the threat
108
+ model: `docs/SAFETY.md`.
109
+
110
+ ## Training
111
+
112
+ - Data: 374 oracle-verified Hinglish rows β€” 184 easy/hard mix, 96 abstention rows (32
113
+ underspecified Γ— 3), 32 fully-specified twins and 62 contrast pairs (empty ledger vs missing
114
+ field, two-conversion sums). The twins and contrast pairs exist so the policy learns the
115
+ boundary instead of the template.
116
+ - Method: 2 epochs of supervised fine-tuning on oracle trajectories (~188 optimizer steps), LoRA
117
+ r=16 all-linear, fp16, lr 2e-4, assistant-only loss, then merged into the base weights.
118
+ - GRPO (AgentTune `create_agentic_trainer`) was run in both rounds; round 1 moved nothing at 30
119
+ steps because the graded reward was saturated. Round 2 uses an abstention-aware reward and
120
+ reports the delta on both axes (`docs/ROUND2.md`).
121
+ - Output format: a bare JSON array of one tool call per turn, no prose, no markdown fences.
122
+
123
+ ## Usage
124
+
125
+ ```python
126
+ from peft import PeftModel
127
+ from transformers import AutoModelForCausalLM, AutoTokenizer
128
+
129
+ tok = AutoTokenizer.from_pretrained("CohereLabs/tiny-aya-global")
130
+ model = AutoModelForCausalLM.from_pretrained("CohereLabs/tiny-aya-global")
131
+ model = PeftModel.from_pretrained(model, "primce/tiny-aya-hinglish-lora", subfolder="sft4_adapter")
132
+ ```
133
+
134
+ Other subfolders: `sft2_adapter` (round 1), `sft3_adapter` (round 2), `sft5_adapter` (mixture
135
+ ablation), `sft4_seed7_adapter` (mix3 replication), `sft3_seed7_adapter` / `sft3_seed123_adapter`
136
+ (mix2 variance control), `grpo_adapter` and
137
+ `sft_adapter` (earlier stages).
138
+
139
+ The adapter expects the system prompt from `hinglish_agent/prompts.py` (tool schemas inline, one
140
+ tool call per turn, ledger returned by every ledger tool and copied into the next call).
141
+
142
+ ## Limitations
143
+
144
+ - Domain-specific: it answers ledger questions with exact arithmetic; it is not a general assistant.
145
+ - The 90-task holdout is still a probe (Wilson 86.2–96.9% on this adapter), and the widest
146
+ same-recipe spread this entry measured β€” 7.77 pp on hard-90 β€” is wider than the
147
+ round-1-to-round-3 difference. That spread comes from the mix2 recipe; mix3 has two seeds that
148
+ agree, which bounds nothing.
149
+ - The adapter can ask for missing details but does not prefer to: 4 of 8 underspecified requests,
150
+ or 7 of 8 with the hardened system prompt.
151
+ - Hinglish + English only. Devanagari paraphrases appear in the eval, but generation is not
152
+ evaluated in Devanagari.
153
+
154
+ ## Licence and provenance
155
+
156
+ Base weights: CohereLabs Tiny Aya, used under its licence. Adapter trained by the entry author on
157
+ synthetic, oracle-verified data. Code, data, pins and run logs:
158
+ `github.com/PRINCE2-AI/lexsi-agentic-hinglish`, `primce/lexsi-runs`. Live demo:
159
+ `huggingface.co/spaces/primce/hinglish-expense-agent`. Write-up:
160
+ `huggingface.co/spaces/primce/hinglish-track3-article`. Collection:
161
+ `huggingface.co/collections/primce/lexsi-track-3-hinglish-expense-agent-6aeb3207e10dfc7dda6329d6`.