domi29 commited on
Commit
efa2b17
·
verified ·
1 Parent(s): 85a8028

Release L3 v7: retrained with 1,890 hard examples, all ONNX variants rebuilt

Browse files

9 classes unchanged. Test acc 0.915 -> 0.936, OOD v2 macro-F1 0.777 -> 0.890. L2 heads unchanged (calibrated on previous L3). Previous L3 is commit 85a802825ccd.

README.md CHANGED
@@ -73,30 +73,62 @@ The model maps an input text to one of:
73
  ## Model Variants
74
 
75
  - **orca-sonar**: full model (`model.safetensors`, fp32).
76
- - **orca-sonar-fp16 (ONNX)**: FP16 ONNX export under `onnx/onnx_fp16/`, half the size, argmax-faithful to the full model.
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  # Training Data
79
 
80
  Trained on our own in-house dataset (German + English, 9 topic classes), purpose-built for this model.
81
  **The dataset will be published soon.**
82
 
 
 
 
 
83
  # Benchmark
84
 
85
- Held-out test set (**100 % real data**), per-class F1:
86
-
87
- | Metric | Score |
88
- |---|---|
89
- | **Accuracy** | **0.942** |
90
- | **F1 (macro)** | **0.940** |
91
- | F1 medical | 0.961 |
92
- | F1 education | 0.957 |
93
- | F1 marketing | 0.956 |
94
- | F1 finance | 0.948 |
95
- | F1 source_code | 0.945 |
96
- | F1 other | 0.943 |
97
- | F1 legal | 0.942 |
98
- | F1 internal_and_tech | 0.930 |
99
- | F1 hr | 0.877 |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  # Usage
102
 
@@ -119,7 +151,7 @@ from transformers import AutoTokenizer
119
 
120
  model_id = "patronus-studio/orca-sonar-document-classifier"
121
  tokenizer = AutoTokenizer.from_pretrained(model_id)
122
- model = ORTModelForSequenceClassification.from_pretrained(model_id, subfolder="onnx/onnx_fp16")
123
 
124
  inputs = tokenizer("def add(a, b):\n return a + b", return_tensors="pt")
125
  logits = model(**inputs).logits
@@ -150,6 +182,9 @@ MIT terms continue to apply to the portions originating from that work.
150
 
151
  This model is built to run inside **[Patronus Ark](https://github.com/patronus-protect/patronus-security)**, Patronus' open-source on-device
152
  AI-security scanning library (L1 native rules → L2 NTDB cascade → L3 transformer).
 
 
 
153
  Ark is open source: [GitHub repository](https://github.com/patronus-protect/patronus-security) · [product page](https://patronus.studio/product/security-lib).
154
 
155
  ## More information
 
73
  ## Model Variants
74
 
75
  - **orca-sonar**: full model (`model.safetensors`, fp32).
76
+ - **ONNX** under `onnx/` (inputs `input_ids`, `attention_mask`; output `logits`):
77
+
78
+ | Variant | Path | Size | argmax agreement with fp32 PyTorch (test / OOD) |
79
+ |---|---|---|---|
80
+ | fp32 | `onnx/onnx_fp32/model.onnx` | 563 MB | 100 % / 100 % |
81
+ | fp16 | `onnx/onnx_fp16/model_fp16.onnx` | 282 MB | 100 % / 99.9 % |
82
+ | mixed (fp16 embeddings, int8 matmuls) | `onnx/onnx_mixed/model_mixed.onnx` | 240 MB | 99.5 % / 99.5 % |
83
+ | int8 | `onnx/int8/model.onnx` | 142 MB | 99.6 % / 99.6 % |
84
+ | int8 + int4 embeddings | `onnx/int8_int4_embeddings/model.onnx` | 96 MB | 99.0 % / 98.9 % |
85
+
86
+ Agreement was measured on the held-out test set (3,367 samples) and the OOD benchmark (845 samples), max length 256.
87
+ Build details: `onnx/quantization_manifest.json`.
88
 
89
  # Training Data
90
 
91
  Trained on our own in-house dataset (German + English, 9 topic classes), purpose-built for this model.
92
  **The dataset will be published soon.**
93
 
94
+ This version adds 1,890 hard examples for the seven original classes (270 per class). They come from an evolutionary
95
+ generation loop: LLM-generated candidates are checked by two independent LLM judges, and only the examples the
96
+ previous model got wrong or barely right are kept. `education` and `medical` received no new examples.
97
+
98
  # Benchmark
99
 
100
+ Both models were evaluated with the same script and max length 256. "Previous" is the model that was in this repository
101
+ before this update.
102
+
103
+ Held-out test set (3,367 samples, **100 % real data**):
104
+
105
+ | Metric | Previous | This version |
106
+ |---|---|---|
107
+ | **Accuracy** | 0.915 | **0.936** |
108
+ | **F1 (macro)** | 0.913 | **0.936** |
109
+ | F1 legal | 0.901 | 0.932 |
110
+ | F1 hr | 0.852 | 0.913 |
111
+ | F1 finance | 0.915 | 0.948 |
112
+ | F1 internal_and_tech | 0.890 | 0.917 |
113
+ | F1 source_code | 0.932 | 0.955 |
114
+ | F1 marketing | 0.942 | 0.930 |
115
+ | F1 other | 0.914 | 0.933 |
116
+ | F1 education | 0.938 | 0.953 |
117
+ | F1 medical | 0.937 | 0.942 |
118
+
119
+ Earlier versions of this card listed accuracy 0.942 for the previous model. On the current test split we measure
120
+ 0.915 for that model, so the two numbers are not comparable.
121
+
122
+ Out-of-distribution benchmark (845 real samples from 23 public sources not used in training, judge-verified and
123
+ deduplicated against the training data; seven classes, no `education`/`medical`):
124
+
125
+ | Metric | Previous | This version |
126
+ |---|---|---|
127
+ | **Accuracy** | 0.807 | **0.898** |
128
+ | **F1 (macro)** | 0.777 | **0.890** |
129
+
130
+ On the OOD set the largest gains are `marketing` (F1 0.54 → 0.84) and `hr` (0.68 → 0.84). Website-style promotional copy
131
+ is still the weakest case: on a 35-sample diagnostic set of such pages, 31 % are classified as `marketing`.
132
 
133
  # Usage
134
 
 
151
 
152
  model_id = "patronus-studio/orca-sonar-document-classifier"
153
  tokenizer = AutoTokenizer.from_pretrained(model_id)
154
+ model = ORTModelForSequenceClassification.from_pretrained(model_id, subfolder="onnx/onnx_fp16", file_name="model_fp16.onnx")
155
 
156
  inputs = tokenizer("def add(a, b):\n return a + b", return_tensors="pt")
157
  logits = model(**inputs).logits
 
182
 
183
  This model is built to run inside **[Patronus Ark](https://github.com/patronus-protect/patronus-security)**, Patronus' open-source on-device
184
  AI-security scanning library (L1 native rules → L2 NTDB cascade → L3 transformer).
185
+
186
+ Note: the L2 heads under `l2/` were trained and calibrated against the previous L3 model and have not been retrained
187
+ for this update.
188
  Ark is open source: [GitHub repository](https://github.com/patronus-protect/patronus-security) · [product page](https://patronus.studio/product/security-lib).
189
 
190
  ## More information
config.json CHANGED
@@ -96,6 +96,7 @@
96
  "sparse_pred_ignore_index": -100,
97
  "sparse_prediction": false,
98
  "tie_word_embeddings": true,
99
- "transformers_version": "5.10.2",
 
100
  "vocab_size": 256000
101
  }
 
96
  "sparse_pred_ignore_index": -100,
97
  "sparse_prediction": false,
98
  "tie_word_embeddings": true,
99
+ "transformers_version": "5.8.1",
100
+ "use_cache": false,
101
  "vocab_size": 256000
102
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1469a1e301fab859108fdd363ded035de50ed7f0aea68f926f7c971f5ef5ba5c
3
  size 562594180
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1f3c3feb59f656bfa212b8a82e5d7a1a51bb9e9360c6581ee9002cd8c21bfa6
3
  size 562594180
onnx/int8/model.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4c72c8fce7d29d25505085fb459270cfe2b42a3f4f70f1b325a4dea9c2a727b9
3
  size 142079828
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bdda65145b6942b2cb0a5200733ab5170b39b180f8870cfafa4d9b8a3eafcfed
3
  size 142079828
onnx/int8_int4_embeddings/model.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1269651681b8c6cecd3a9666ae82a248db50d59606e91a68bdbfbe5110a6c2f0
3
  size 96298877
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f7c5545a1c97e8dac1f93bdff08eebec90c1ffc552aac22099604b58f87283e
3
  size 96298877
onnx/onnx_fp16/model_fp16.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5c85ff37d636b0c2b38ecec9519aceaa2df968054aa67ee9dc7fa8c9caa09c85
3
  size 281832222
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:daf4b53e67f03affbfb158b08295e36d7768611ab7f9b4a888036e3c2f49467a
3
  size 281832222
onnx/onnx_fp32/model.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:95d4a704ae086353424d200370ab7419b16a8799d9317c91bc235c7fc605a4ab
3
  size 563151381
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa621292bdada26e9f3be6999906f37185ef5d4a370ba7bbc05631f92cfb0dca
3
  size 563151381
onnx/onnx_mixed/model_mixed.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:615c6b3175c53b6f49151bd3551af56496abfe0c263332bbb353d56012fad838
3
- size 240383444
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7362b07bff928654af83bb382e5ff6b86ae914392b3dad1954651bf6e210b776
3
+ size 240383501
onnx/quantization_manifest.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "schema_version": 1,
3
  "head": "sensitive_document",
4
- "source_model": "patronus-studio/Sensitive-Ablation@418836779304518da1f84ec798efbf27dc943731",
5
  "source_fp32_graph": {
6
  "bytes": 563151381,
7
  "operators": {
@@ -138,7 +138,7 @@
138
  "mixed": {
139
  "path": "onnx/onnx_mixed/model_mixed.onnx",
140
  "graph": {
141
- "bytes": 240383444,
142
  "operators": {
143
  "Abs": 1,
144
  "Add": 157,
@@ -287,4 +287,4 @@
287
  "int8_int4_embeddings": 0,
288
  "mixed": 0
289
  }
290
- }
 
1
  {
2
  "schema_version": 1,
3
  "head": "sensitive_document",
4
+ "source_model": "orca-sonar v7: training/mmbert_runs/mmbert_20261104_125540_v7_9class/checkpoint-11928",
5
  "source_fp32_graph": {
6
  "bytes": 563151381,
7
  "operators": {
 
138
  "mixed": {
139
  "path": "onnx/onnx_mixed/model_mixed.onnx",
140
  "graph": {
141
+ "bytes": 240383501,
142
  "operators": {
143
  "Abs": 1,
144
  "Add": 157,
 
287
  "int8_int4_embeddings": 0,
288
  "mixed": 0
289
  }
290
+ }
training_args.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4c7e34b9f8728ad03118313718aa5221f7524aabc42576b3d5c62809693ca052
3
  size 5329
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:364488349611ec772506646bdd1b1873790a4cd7607aa1b412f1d1662fdc190e
3
  size 5329