codenamev commited on
Commit
1bc2622
·
verified ·
1 Parent(s): 4c74009

Laya 0.3.7 checkpoints exported to ONNX for ruby-laya

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
 
 
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
36
+ multilingual/tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: onnx
4
+ base_model: convaiinnovations/laya
5
+ tags: [laya, onnx, system-one, calibrated-decisions, ruby, decision-model]
6
+ ---
7
+
8
+ # Laya, exported to ONNX
9
+
10
+ ONNX exports of the three [Laya](https://github.com/NandhaKishorM/laya) checkpoints, published for
11
+ [ruby-laya](https://github.com/codenamev/ruby-laya). Laya is a non-autoregressive System 1 decision
12
+ engine by [Convai Innovations](https://huggingface.co/convaiinnovations): typed decisions over any
13
+ state in a single forward pass, with calibrated probabilities.
14
+
15
+ These are conversions, not new models. All credit for the weights belongs to Convai Innovations.
16
+
17
+ | folder | source | encoder | context |
18
+ |---|---|---|---|
19
+ | `english/` | [convaiinnovations/laya](https://huggingface.co/convaiinnovations/laya) (root) | ModernBERT-large | 512 |
20
+ | `multilingual/` | the same repository's `multilingual/` | mmBERT-base | 1024 |
21
+ | `typed-decisions/` | the same repository's `typed-decisions/` | ModernBERT-large | 1024 |
22
+
23
+ Source revision: `convaiinnovations/laya` at commit `1c5edc17a7acd8701df6fc341c0d179f1c62c982`, exported with `laya` 0.3.7 and
24
+ PyTorch 2.14.0.
25
+
26
+ ## What each folder holds
27
+
28
+ model.onnx the decision model: encoder, typed decision head and action head
29
+ rl_agent_config.json copied from the source checkpoint (token budgets, temperatures)
30
+ onnx_config.json export provenance and the verified deviation from PyTorch
31
+ tokenizer/ copied from the source checkpoint
32
+
33
+ ## Graph
34
+
35
+ Inputs are `input_ids`, `attention_mask` (int64 `[batch, seq]`), `marker_pos`, `marker_mask`
36
+ (int64 and bool `[batch, markers]`) and `qtype` (int64 `[batch]`). Outputs are `logits`
37
+ `[batch, markers]`, `act_logits` `[batch, 2]` and `last_hidden_state` `[batch, seq, dim]`, which
38
+ the embedding shortlist uses. ONNX Runtime prunes the graph to the outputs you request, so asking
39
+ for the first two costs nothing extra.
40
+
41
+ A question with a single option is padded to two markers with the second masked off, and a batch
42
+ shorter than eight tokens is padded up to it. Both are what the traced graph expects, and neither
43
+ changes an answer.
44
+
45
+ Weights are stored as float16 and cast to float32 in the graph. The published checkpoints are
46
+ float16 on disk and upstream widens them at load, so the round trip is exact and the download
47
+ stays the size of the original safetensors.
48
+
49
+ ## Verification
50
+
51
+ Every export is checked against upstream `laya` on CPU: same sequence construction, same
52
+ temperature buckets, same rounding. Each probability, score, confidence and action probability
53
+ upstream reports is reproduced, and raw logits agree within 2.5e-5. Reproduce with
54
+ [`tools/export_onnx.py`](https://github.com/codenamev/ruby-laya/blob/main/tools/export_onnx.py):
55
+
56
+ uv run tools/export_onnx.py <checkpoint-dir> <output-dir>
57
+
58
+ ## Use
59
+
60
+ gem install ruby-laya
61
+
62
+ require "laya"
63
+ agent = Laya.load("convaiinnovations/laya") # resolves to english/ here
64
+
65
+ Any ONNX Runtime can load these directly; the gem is a convenience, not a requirement.
66
+
67
+ ## License
68
+
69
+ Apache 2.0, inherited from the source checkpoints. Laya was developed by Convai Innovations.
english/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea2a37ef3bea4c1ebf7484b3b3da51de51cf9949fdd8a0088129db10dbb83615
3
+ size 846075711
english/onnx_config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "onnx",
3
+ "exported_from": "english",
4
+ "laya_version": "0.3.7",
5
+ "torch_version": "2.14.0",
6
+ "onnx_opset": 20,
7
+ "hidden_size": 1024,
8
+ "min_markers": 2,
9
+ "outputs": [
10
+ "logits",
11
+ "act_logits",
12
+ "last_hidden_state"
13
+ ],
14
+ "max_verified_diff": {
15
+ "logits": 2.4974346160888672e-05,
16
+ "act_logits": 0.00341796875,
17
+ "last_hidden_state": 0.00044655799865722656,
18
+ "predict_payload": 0.0
19
+ }
20
+ }
english/rl_agent_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": "rl-agent",
13
+ "temperature": [
14
+ 1.6369030475616455,
15
+ 1.2514300346374512,
16
+ 1.983399510383606
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
+ }
english/tokenizer/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
english/tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "clean_up_tokenization_spaces": true,
3
+ "cls_token": "[CLS]",
4
+ "mask_token": "[MASK]",
5
+ "model_input_names": [
6
+ "input_ids",
7
+ "attention_mask"
8
+ ],
9
+ "model_max_length": 8192,
10
+ "pad_token": "[PAD]",
11
+ "sep_token": "[SEP]",
12
+ "tokenizer_class": "PreTrainedTokenizerFast",
13
+ "unk_token": "[UNK]"
14
+ }
multilingual/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da6a0f87380597f679b12ce539e0a187e923fcffcf8dfc2f035728388dceacb0
3
+ size 646693695
multilingual/onnx_config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "onnx",
3
+ "exported_from": "multilingual",
4
+ "laya_version": "0.3.7",
5
+ "torch_version": "2.14.0",
6
+ "onnx_opset": 20,
7
+ "hidden_size": 768,
8
+ "min_markers": 2,
9
+ "outputs": [
10
+ "logits",
11
+ "act_logits",
12
+ "last_hidden_state"
13
+ ],
14
+ "max_verified_diff": {
15
+ "logits": 4.3392181396484375e-05,
16
+ "act_logits": 0.001220703125,
17
+ "last_hidden_state": 0.0003654062747955322,
18
+ "predict_payload": 0.0
19
+ }
20
+ }
multilingual/rl_agent_config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "encoder": "jhu-clsp/mmBERT-base",
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": "rl-agent",
13
+ "temperature": [
14
+ 1.0,
15
+ 1.0,
16
+ 1.0
17
+ ],
18
+ "temperature_by_options": {},
19
+ "training": {
20
+ "updates": 15987,
21
+ "epochs_completed": 4,
22
+ "hours": 4.97,
23
+ "world_size": 1,
24
+ "fine_tuned_from_checkpoint": false
25
+ }
26
+ }
multilingual/tokenizer/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:609d8f4c067cd3950f88594c5a802616cea245823836ef5848ee4fc40aab5b6f
3
+ size 34363188
multilingual/tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<bos>",
3
+ "clean_up_tokenization_spaces": false,
4
+ "cls_token": "<bos>",
5
+ "eos_token": "<eos>",
6
+ "extra_special_tokens": {
7
+ "extra_0": "<start_of_turn>",
8
+ "extra_1": "<end_of_turn>"
9
+ },
10
+ "mask_token": "<mask>",
11
+ "model_input_names": [
12
+ "input_ids",
13
+ "attention_mask"
14
+ ],
15
+ "model_max_length": 8192,
16
+ "pad_token": "<pad>",
17
+ "padding_side": "right",
18
+ "sep_token": "<eos>",
19
+ "spaces_between_special_tokens": false,
20
+ "tokenizer_class": "PreTrainedTokenizerFast",
21
+ "unk_token": "<unk>"
22
+ }
typed-decisions/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7bc0662f05f69635291b1f823a946931b9936fcebd2ea98db85da70ebb8f4ba2
3
+ size 846075712
typed-decisions/onnx_config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "onnx",
3
+ "exported_from": "typed-decisions",
4
+ "laya_version": "0.3.7",
5
+ "torch_version": "2.14.0",
6
+ "onnx_opset": 20,
7
+ "hidden_size": 1024,
8
+ "min_markers": 2,
9
+ "outputs": [
10
+ "logits",
11
+ "act_logits",
12
+ "last_hidden_state"
13
+ ],
14
+ "max_verified_diff": {
15
+ "logits": 6.4373016357421875e-06,
16
+ "act_logits": 0.001953125,
17
+ "last_hidden_state": 0.0009946823120117188,
18
+ "predict_payload": 0.0
19
+ }
20
+ }
typed-decisions/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
+ }
typed-decisions/tokenizer/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
typed-decisions/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
+ }