binoykunhi convaiinnovations commited on
Commit
1c24f41
·
0 Parent(s):

Duplicate from convaiinnovations/laya-typed-decisions

Browse files

Co-authored-by: Convai Innovations <convaiinnovations@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: text-classification
5
+ language: [en]
6
+ tags: [laya, system-one, calibrated-decisions, rlcd, typed-decisions, classification, agent-observability, invoice-processing, security-incidents, customer-service, commercial-use]
7
+ ---
8
+
9
+ <p align="center">
10
+ <img src="https://huggingface.co/convaiinnovations/laya/resolve/main/assets/logo-mark.png" alt="" width="72" />
11
+ </p>
12
+
13
+ # Laya Typed-Decisions
14
+
15
+ Non-autoregressive **System 1 decision model**, fine-tuned on the
16
+ [typed-decisions](https://huggingface.co/datasets/LocalLLaMA/typed-decisions) workflows: agent-trace
17
+ observability, customer service, invoice processing and security incidents.
18
+
19
+ Part of the [Laya family](https://huggingface.co/convaiinnovations/laya).
20
+
21
+ | checkpoint | encoder | params | context | use it for |
22
+ |---|---|---|---|---|
23
+ | [`convaiinnovations/laya`](https://huggingface.co/convaiinnovations/laya) | ModernBERT-large | 421M | 512 | English, general |
24
+ | [`convaiinnovations/laya-multilingual`](https://huggingface.co/convaiinnovations/laya-multilingual) | mmBERT-base | 322M | 1024 | 100+ languages |
25
+ | **`convaiinnovations/laya-typed-decisions`** (this repo) | ModernBERT-large | 421M | 1024 | these four workflows |
26
+
27
+ ## Benchmark
28
+
29
+ 400 test cases, 2,000 decisions, measured on the official test split.
30
+
31
+ | model | accuracy | soft acc | Brier | ECE | score MAE |
32
+ |---|---|---|---|---|---|
33
+ | **this checkpoint** | **0.766** | 0.471 | **0.062** | 0.213 | **0.242** |
34
+ | *TypeSafe Jev 1.13.0 (published)* | *0.727* | *0.580* | *0.148* | *0.144* | *0.391* |
35
+ | *teacher self-agreement ceiling* | *0.735* | | | | |
36
+ | *ModernBERT-base specialist (published)* | *0.646* | | | | |
37
+ | *per-question majority class* | *0.461* | | | | |
38
+ | *random guess* | *0.318* | | | | |
39
+ | `laya` (not fine-tuned) | 0.362 | 0.332 | 0.316 | 0.175 | 0.694 |
40
+ | `laya-multilingual` (not fine-tuned) | 0.342 | 0.326 | 0.439 | 0.285 | 0.687 |
41
+
42
+ **+3.9 points over Jev's published 0.727, above the 0.735 teacher ceiling**, with 2.4x better
43
+ Brier and 1.6x better score MAE.
44
+
45
+ Jev figures are third-party published, not measured here — there is no TypeSafe API access in
46
+ this project, and sample sizes and prompts differ. Treat the comparison as indicative.
47
+
48
+ ### By workflow
49
+
50
+ | workflow | accuracy |
51
+ |---|---|
52
+ | invoice processing | **0.804** |
53
+ | security incidents | 0.766 |
54
+ | customer service | 0.764 |
55
+ | agent-trace observability | 0.730 |
56
+
57
+ ### By primitive
58
+
59
+ | type | accuracy | ECE | n |
60
+ |---|---|---|---|
61
+ | `noul` | **0.857** | 0.192 | 600 |
62
+ | `choice` | 0.733 | 0.255 | 600 |
63
+ | `score` | 0.723 | 0.199 | 800 |
64
+
65
+ ## Quickstart
66
+
67
+ ```bash
68
+ pip install laya
69
+ ```
70
+
71
+ ```python
72
+ import laya
73
+
74
+ agent = laya.load("convaiinnovations/laya-typed-decisions")
75
+ result = agent.predict(state, questions)
76
+ ```
77
+
78
+ Or route to it explicitly:
79
+
80
+ ```python
81
+ from laya import Router
82
+
83
+ router = Router()
84
+ router.predict(state, questions, model="typed-decisions")
85
+ ```
86
+
87
+ `Router` will not select this checkpoint automatically unless you construct it with
88
+ `auto_task_detection=True` — it is specialised to four synthetic workflows and should not be a
89
+ silent default.
90
+
91
+ If this checkpoint is on a hot path, keep it resident rather than loading it per request:
92
+
93
+ ```python
94
+ router = Router()
95
+ router.preload(["typed-decisions"]) # or router.attach("typed-decisions", agent)
96
+ ```
97
+
98
+ `preload` fetches and builds the checkpoints you name once; `attach` registers an `Agent` you
99
+ already hold, so nothing is loaded twice.
100
+
101
+ > **If `laya.load()` hangs:** `transformers` probes for TensorFlow at import, and when TF is
102
+ > installed its abseil runtime can deadlock model construction. Run with `USE_TF=0`.
103
+
104
+ ## Training
105
+
106
+ Fine-tuned from [`convaiinnovations/laya`](https://huggingface.co/convaiinnovations/laya) on the
107
+ benchmark's 1,200-case training split (6,000 decisions) with **RLCD**: the policy reports a
108
+ distribution, exploration adds zero-mean Gaussian noise to the logits, and the reward is a
109
+ strictly proper scoring rule (log + spherical, plus ranked probability score for ordinal
110
+ questions), so expected reward is maximised only by honest probabilities. Updates are REINFORCE
111
+ with a group-mean baseline, alongside soft cross-entropy against the teacher's distributions.
112
+
113
+ Reproduce it:
114
+ [`laya_finetune_typed_decisions_2xT4_kaggle.ipynb`](https://github.com/NandhaKishorM/laya/blob/main/notebooks/laya_finetune_typed_decisions_2xT4_kaggle.ipynb)
115
+ — about 4–5 hours on Kaggle's free 2xT4.
116
+
117
+ ## Limits
118
+
119
+ - **This is a specialist.** It was fine-tuned on four specific synthetic workflows. Expect it to
120
+ behave like the base `laya` checkpoint, or worse, on anything else.
121
+ - **Soft accuracy trails Jev** (0.471 vs 0.580): its argmax is better, but its probability
122
+ *distributions* match the teacher less well.
123
+ - **Still over-confident** (ECE 0.213 vs Jev's 0.144). Its `temperature_by_options` was inherited
124
+ from the base checkpoint and overrides the per-type temperatures fitted for this model — refit
125
+ on your own held-out data before relying on the probabilities.
126
+ - English only. Use `laya-multilingual` for other languages.
127
+ - **Keep `choice` questions under ~20 options.** Options share a fixed 256-token head budget, so
128
+ a large label space leaves few tokens per label and accuracy falls off sharply.
129
+
130
+ ## Links
131
+
132
+ - **Hub / family** https://huggingface.co/convaiinnovations/laya
133
+ - **GitHub** https://github.com/NandhaKishorM/laya · full benchmark data on the `research` branch
134
+ - **PyPI** https://pypi.org/project/laya/
135
+ - **Benchmark dataset** https://huggingface.co/datasets/LocalLLaMA/typed-decisions
136
+
137
+ Apache 2.0 · Convai Innovations
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:4fa56de72383a9d3efa9cfa78955733c81b9fc8067a587ca4beb82c78107a24e
3
+ size 842609220
rl_agent_config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "encoder": "answerdotai/ModernBERT-large",
3
+ "head_layers": 2,
4
+ "max_len": 1024,
5
+ "head_max_len": 256,
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-typed-decisions",
13
+ "temperature": [
14
+ 1.0148024559020996,
15
+ 1.0374259948730469,
16
+ 1.0575125217437744
17
+ ],
18
+ "temperature_by_options": {
19
+ "choice:3-5": 1.7601518630981445,
20
+ "choice:6-10": 1.0000158548355103,
21
+ "score:3-5": 1.2514300346374512,
22
+ "noul:2": 1.983399510383606,
23
+ "choice:11+": 0.10058280825614929,
24
+ "choice:2": 1.9063563346862793
25
+ },
26
+ "training": {
27
+ "updates": 7313,
28
+ "epochs_completed": 1,
29
+ "hours": 1.96,
30
+ "world_size": 1,
31
+ "fine_tuned_from_checkpoint": true
32
+ },
33
+ "gradient_checkpointing": true,
34
+ "max_tokens_per_batch": 4096,
35
+ "fine_tuned": true
36
+ }
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
+ }