Gjusev commited on
Commit
cfe4860
·
verified ·
1 Parent(s): b4ca6a9

laya fine-tuned on BANKING77 routing: intent accuracy 0.905

Browse files
README.md CHANGED
@@ -1,170 +1,79 @@
1
- ---
2
- license: apache-2.0
3
- library_name: transformers
4
- base_model:
5
- - convaiinnovations/laya
6
- tags:
7
- - laya
8
- - system-one
9
- - ticket-triage
10
- - banking77
11
- - hierarchical-classification
12
- - customer-support
13
- - routing
14
- datasets:
15
- - PolyAI/banking77
16
- metrics:
17
- - accuracy
18
- - f1
19
- pipeline_tag: text-classification
20
- ---
21
-
22
- # laya-triage-banking77
23
-
24
- A [laya](https://github.com/NandhaKishorM/laya) System 1 decision model (421M) fine-tuned
25
- for **hierarchical support-ticket triage** on BANKING77: one local forward pass per stage
26
- returns a department route and a calibrated confidence — no API calls, no per-ticket cost.
27
- Part of the [laya-triage](https://github.com/Gjusev/laya-triage) project (Apache 2.0).
28
-
29
- | Configuration | Intent accuracy | Macro-F1 |
30
- |---|---:|---:|
31
- | zero-shot flat 77-way | 36.5% | 0.284 |
32
- | zero-shot hierarchical | 51.0% | 0.443 |
33
- | **fine-tuned hierarchical (this model)** | **90.5%** | **0.848** |
34
-
35
- 200-ticket seed-13 BANKING77 test sample, identical harness and questions for all three rows.
36
-
37
- ## How the hierarchy works
38
-
39
- BANKING77's 77 intents are grouped into 12 clusters of 3-10 intents (kept inside the
40
- calibrated choice-temperature bucket). Triage is two passes on this checkpoint:
41
-
42
- 1. **Coarse pass** — choose one of the 12 clusters. In production the same pass also scores
43
- urgency, frustration, churn risk and refund intent (heads inherited from the base model).
44
- 2. **Fine pass** — choose among only the 3-10 intents of the winning cluster.
45
-
46
- Coarse accuracy on the eval sample: **96.0%**. The two-pass eval ran the
47
- 200 tickets in 16.1s on one Kaggle T4.
48
-
49
- ## Training details
50
-
51
- - **Data**: the BANKING77 train split (10,003 tickets). Each ticket contributes two
52
- sequences — the coarse choice (gold = the intent's cluster) and the fine choice
53
- restricted to that cluster (gold = the intent) — 20,006 training items in total.
54
- - **Objective**: RLCD policy gradients over a proper scoring rule (log score + spherical +
55
- ranked-probability for score-type questions) plus a cross-entropy guidance term toward
56
- the gold answer.
57
- - **Hyperparameters** (from the committed trainer):
58
- 3 epochs; micro-batch 8 with gradient accumulation 4 (effective 32 per rank);
59
- RLCD group size 4 with sigma annealed 0.4 → 0.1 across epochs; AdamW with
60
- encoder lr 2.5e-5 / head lr 1e-4, weight decay 0.01.
61
- - **Hardware**: Kaggle 2× Tesla T4, `torchrun` DDP (9,803 items per rank after the
62
- equal-count trim), about 46 minutes end to end.
63
- - **Software**: laya 0.3.22, laya-triage 0.1.0, adapted from laya's official 2×T4 notebook.
64
- - **Notebook**: [`finetune/laya_triage_banking77.ipynb`](https://github.com/Gjusev/laya-triage/blob/main/finetune/laya_triage_banking77.ipynb)
65
- (opens directly in Kaggle; the committed run is [gjusev/laya-triage-banking77](https://www.kaggle.com/code/gjusev/laya-triage-banking77)).
66
-
67
- ## Calibration
68
-
69
- Choice-answer temperature fitted on a held-out calibration split carved from the training
70
- data **before** training: **3.825** (score and noul heads keep their 1.2 defaults).
71
- After three epochs on memorized training data the choice logits are sharply overconfident;
72
- the fitted temperature softens them back so `answer_confidence` remains a usable gate.
73
-
74
- ## Escalation
75
-
76
- The operational policy auto-handles a ticket only when every routing decision's calibrated
77
- confidence clears a threshold. For this checkpoint the 75% accuracy target is met at
78
- threshold **0.00** with **100% coverage**
79
- (90.5% accuracy among auto-handled tickets): on this English banking
80
- sample the calibrated confidence is strong enough that nothing needs escalating — a large
81
- change from the zero-shot checkpoint, whose operating point was 0.84 at ~60% coverage.
82
- Treat that as a property of this domain/sample, not a universal guarantee.
83
-
84
- ## What was trained and what was not
85
-
86
- - **Trained**: the two routing decisions (cluster choice, intent choice).
87
- - **NOT trained**: the auxiliary signal heads — BANKING77 carries no urgency/frustration/
88
- churn/refund labels. Measured on the project's English hand-labeled subset
89
- (n=60): urgency MAE **0.701**, frustration MAE
90
- **0.693** (zero-shot all-language baseline 0.813 / 1.071).
91
- The routing-only fine-tune did not disturb them.
92
- - **English only**: the base checkpoint is the English laya model. The repo documents
93
- per-language coarse-accuracy degradation zero-shot; this fine-tune does not address it.
94
-
95
- ## Where it fails (top confusions on the eval sample)
96
-
97
- | Gold | Predicted | Count |
98
- |---|---|---:|
99
- | `top_up_failed` | `topping_up_by_card` | 1 |
100
- | `beneficiary_not_allowed` | `failed_transfer` | 1 |
101
- | `order_physical_card` | `getting_virtual_card` | 1 |
102
- | `pin_blocked` | `change_pin` | 1 |
103
- | `beneficiary_not_allowed` | `transfer_into_account` | 1 |
104
- | `verify_top_up` | `verify_my_identity` | 1 |
105
- | `receiving_money` | `fiat_currency_support` | 1 |
106
- | `wrong_exchange_rate_for_cash_withdrawal` | `cash_withdrawal_charge` | 1 |
107
- | `declined_transfer` | `transfer_not_received_by_recipient` | 1 |
108
- | `get_disposable_virtual_card` | `getting_virtual_card` | 1 |
109
-
110
- Every top confusion is a single-ticket mistake on this sample — there is no systematic
111
- confusion pair at n=200.
112
-
113
- ## Intended use
114
-
115
- - Routing customer-support tickets to departments/queues in English banking-style domains.
116
- - As a drop-in laya checkpoint inside the [laya-triage pipeline](https://github.com/Gjusev/laya-triage),
117
- which adds multilingual routing, the escalation policy and the signal heads.
118
-
119
- **Out of scope**: languages other than English (use the zero-shot multilingual pipeline
120
- instead), non-banking domains, any decision with safety or legal consequences, and use of
121
- the urgency/frustration scores as anything beyond triage prioritization signals.
122
-
123
- ## Limitations
124
-
125
- - Evaluated on a 200-ticket sample (seed 13) of the BANKING77 test split; the full-split
126
- numbers may differ. Reproduce with the artifact, not the prose.
127
- - Out-of-domain tickets map to the nearest banking concept when confidence is high enough;
128
- the repo's smoke test escalated 7 of 8 IT-operations tickets at the zero-shot 0.84 gate.
129
- - Latency figures (CPU 577.4s / T4 16.1s per 200-ticket two-pass)
130
- are development measurements, not deployment benchmarks.
131
-
132
- ## Evaluation methodology and artifacts
133
-
134
- Sample selection, per-ticket records (predictions, confidences, correctness), the coverage
135
- curve and every number above live in
136
- [`evals/results/banking77_finetuned.json`](https://github.com/Gjusev/laya-triage/blob/main/evals/results/banking77_finetuned.json).
137
- The eval kernel that produced it attaches this checkpoint as a Kaggle dataset and re-runs
138
- the same seed-13 two-pass as the repo's zero-shot harness
139
- ([gjusev/laya-triage-ft-eval](https://www.kaggle.com/code/gjusev/laya-triage-ft-eval)).
140
-
141
- ## Usage
142
-
143
- ```python
144
- import laya
145
- from huggingface_hub import snapshot_download
146
- from laya_triage import schema
147
-
148
- agent = laya.Agent(snapshot_download("Gjusev/laya-triage-banking77"), device="cpu")
149
-
150
- stage1 = agent.predict([{"message": "I was charged twice for the same card payment"}],
151
- schema.coarse_questions())[0]
152
- cluster = stage1["answers"]["cluster"]["choice"]
153
- stage2 = agent.predict([{"message": "I was charged twice for the same card payment"}],
154
- schema.fine_questions(cluster))[0]
155
- print(cluster, stage2["answers"]["intent"]["choice"],
156
- stage2["answers"]["intent"]["answer_confidence"])
157
- ```
158
-
159
- The full pipeline (`TriagePipeline`) wraps both passes plus department mapping and the
160
- escalation gate — see the repo README.
161
-
162
- ## Base model and data
163
-
164
- Fine-tuned from the Apache-2.0 laya System 1 checkpoint by Convai Innovations
165
- (`convaiinnovations/laya`), trained on the BANKING77 dataset (PolyAI-LDN). Thanks to both.
166
-
167
- ## License
168
-
169
- Apache 2.0. The fine-tune and its evaluation artifacts are part of the
170
- [laya-triage](https://github.com/Gjusev/laya-triage) project.
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ tags:
5
+ - laya
6
+ - system-one
7
+ - ticket-triage
8
+ - banking77
9
+ - hierarchical-classification
10
+ metrics:
11
+ - accuracy
12
+ ---
13
+ # laya-triage-banking77
14
+
15
+ Laya (421M) fine-tuned on the BANKING77 training split for hierarchical
16
+ ticket triage: a coarse choice over 12 clusters plus a fine choice over
17
+ the winning cluster's intents, trained jointly on 2xT4 with DDP (RLCD
18
+ policy gradients plus cross-entropy guidance). Part of the
19
+ [laya-triage](https://github.com/Gjusev/laya-triage) project.
20
+
21
+ ## Results (200-ticket seed-13 test sample)
22
+
23
+ | Configuration | Intent accuracy |
24
+ |---|---|
25
+ | zero-shot flat 77-way | 0.365 |
26
+ | zero-shot hierarchical | 0.510 |
27
+ | fine-tuned hierarchical (this model) | 0.905 |
28
+
29
+ Coarse accuracy 0.960, macro-F1 0.848.
30
+ Escalation: the 75% accuracy target is met at threshold 0.00
31
+ with 100% coverage (90.5% accuracy among
32
+ auto-handled). Full artifact with per-ticket records:
33
+ [banking77_finetuned.json](https://github.com/Gjusev/laya-triage/blob/main/evals/results/banking77_finetuned.json).
34
+
35
+ ## What was trained and what was not
36
+
37
+ - Trained: the two routing decisions (cluster choice, intent choice).
38
+ - NOT trained: the auxiliary signal heads (urgency, frustration, churn risk,
39
+ refund requested) - BANKING77 carries no such labels. Measured on the
40
+ project's English hand-labeled subset (n=60): urgency MAE
41
+ 0.701, frustration MAE 0.693
42
+ (zero-shot all-language baseline: 0.813 / 1.071).
43
+ - Hold-out temperature calibration: choice 3.825
44
+ (score and noul keep their defaults).
45
+ - English only: the base checkpoint is the English laya model; the repo
46
+ documents in-domain coarse accuracy degradation for other languages, which
47
+ this fine-tune does not address.
48
+
49
+ ## Where it fails (top confusions on the eval sample)
50
+
51
+ - `top_up_failed` predicted as `topping_up_by_card` (x1)
52
+ - `beneficiary_not_allowed` predicted as `failed_transfer` (x1)
53
+ - `order_physical_card` predicted as `getting_virtual_card` (x1)
54
+ - `pin_blocked` predicted as `change_pin` (x1)
55
+ - `beneficiary_not_allowed` predicted as `transfer_into_account` (x1)
56
+ - `verify_top_up` predicted as `verify_my_identity` (x1)
57
+ - `receiving_money` predicted as `fiat_currency_support` (x1)
58
+ - `wrong_exchange_rate_for_cash_withdrawal` predicted as `cash_withdrawal_charge` (x1)
59
+ - `declined_transfer` predicted as `transfer_not_received_by_recipient` (x1)
60
+ - `get_disposable_virtual_card` predicted as `getting_virtual_card` (x1)
61
+
62
+ All top confusions are single-ticket mistakes; there is no systematic
63
+ confusion pair on this sample.
64
+
65
+ ## Usage
66
+
67
+ ```python
68
+ import laya
69
+ from huggingface_hub import snapshot_download
70
+
71
+ agent = laya.Agent(snapshot_download("Gjusev/laya-triage-banking77"))
72
+ ```
73
+ See the laya-triage repo for the full pipeline (escalation policy,
74
+ multilingual routing, signals) and the fine-tuning notebook that produced
75
+ this checkpoint.
76
+
77
+ ## License
78
+ Apache 2.0. Base model by Convai Innovations; fine-tune by the laya-triage
79
+ project, trained on the BANKING77 dataset (PolyAI-LDN).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
encoder/config.json ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ModernBertForMaskedLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 50281,
8
+ "classifier_activation": "gelu",
9
+ "classifier_bias": false,
10
+ "classifier_dropout": 0.0,
11
+ "classifier_pooling": "mean",
12
+ "cls_token_id": 50281,
13
+ "decoder_bias": true,
14
+ "deterministic_flash_attn": false,
15
+ "dtype": "float32",
16
+ "embedding_dropout": 0.0,
17
+ "eos_token_id": 50282,
18
+ "global_attn_every_n_layers": 3,
19
+ "gradient_checkpointing": false,
20
+ "hidden_activation": "gelu",
21
+ "hidden_size": 1024,
22
+ "initializer_cutoff_factor": 2.0,
23
+ "initializer_range": 0.02,
24
+ "intermediate_size": 2624,
25
+ "layer_norm_eps": 1e-05,
26
+ "layer_types": [
27
+ "full_attention",
28
+ "sliding_attention",
29
+ "sliding_attention",
30
+ "full_attention",
31
+ "sliding_attention",
32
+ "sliding_attention",
33
+ "full_attention",
34
+ "sliding_attention",
35
+ "sliding_attention",
36
+ "full_attention",
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "full_attention",
40
+ "sliding_attention",
41
+ "sliding_attention",
42
+ "full_attention",
43
+ "sliding_attention",
44
+ "sliding_attention",
45
+ "full_attention",
46
+ "sliding_attention",
47
+ "sliding_attention",
48
+ "full_attention",
49
+ "sliding_attention",
50
+ "sliding_attention",
51
+ "full_attention",
52
+ "sliding_attention",
53
+ "sliding_attention",
54
+ "full_attention"
55
+ ],
56
+ "local_attention": 128,
57
+ "max_position_embeddings": 8192,
58
+ "mlp_bias": false,
59
+ "mlp_dropout": 0.0,
60
+ "model_type": "modernbert",
61
+ "norm_bias": false,
62
+ "norm_eps": 1e-05,
63
+ "num_attention_heads": 16,
64
+ "num_hidden_layers": 28,
65
+ "pad_token_id": 50283,
66
+ "position_embedding_type": "absolute",
67
+ "repad_logits_with_grad": false,
68
+ "rope_parameters": {
69
+ "full_attention": {
70
+ "rope_theta": 160000.0,
71
+ "rope_type": "default"
72
+ },
73
+ "sliding_attention": {
74
+ "rope_theta": 10000.0,
75
+ "rope_type": "default"
76
+ }
77
+ },
78
+ "sep_token_id": 50282,
79
+ "sparse_pred_ignore_index": -100,
80
+ "sparse_prediction": false,
81
+ "tie_word_embeddings": true,
82
+ "transformers_version": "5.17.0",
83
+ "vocab_size": 50368
84
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a16c690089f44995189eb0857d38dd3220d623387e928f88f6b36ad4ac84b8a4
3
+ size 842609220
rl_agent_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "encoder": "answerdotai/ModernBERT-large",
3
+ "head_layers": 2,
4
+ "max_len": 512,
5
+ "head_max_len": 192,
6
+ "max_prefixes": 6,
7
+ "act_costs": {
8
+ "escalate": 0.5
9
+ },
10
+ "cost_wrong_act": 3.0,
11
+ "amp_dtype": "bf16",
12
+ "model_name": "laya-triage-banking77",
13
+ "temperature": [
14
+ 3.8246283531188965,
15
+ 1.2,
16
+ 1.2
17
+ ],
18
+ "training": {
19
+ "updates": 7313,
20
+ "epochs_completed": 1,
21
+ "hours": 1.96,
22
+ "world_size": 1,
23
+ "fine_tuned_from_checkpoint": true
24
+ },
25
+ "gradient_checkpointing": true,
26
+ "max_tokens_per_batch": 4096,
27
+ "fine_tuned": true
28
+ }
tokenizer/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "clean_up_tokenization_spaces": true,
3
+ "cls_token": "[CLS]",
4
+ "local_files_only": false,
5
+ "mask_token": "[MASK]",
6
+ "model_input_names": [
7
+ "input_ids",
8
+ "attention_mask"
9
+ ],
10
+ "model_max_length": 8192,
11
+ "pad_token": "[PAD]",
12
+ "sep_token": "[SEP]",
13
+ "tokenizer_class": "PreTrainedTokenizerFast",
14
+ "unk_token": "[UNK]"
15
+ }