Text Classification
Transformers
Safetensors
English
qwen3_5_text
text-generation
Rodinia
finance
financial-ai
decision-intelligence
typed-decisions
financial-classification
calibrated-probabilities
probability-calibration
risk-assessment
sentiment-analysis
portfolio-analysis
0.8b
sociodynamics-ai
Instructions to use NeoSapian/Rodinia with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NeoSapian/Rodinia with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="NeoSapian/Rodinia")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NeoSapian/Rodinia") model = AutoModelForCausalLM.from_pretrained("NeoSapian/Rodinia", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload Jev-Fin-0.8B as Nirnay
Browse files- .gitattributes +1 -0
- README.md +281 -0
- chat_template.jinja +154 -0
- config.json +74 -0
- generation_config.json +6 -0
- jev_common.py +203 -0
- jev_config.json +11 -0
- metrics.json +244 -0
- model.safetensors +3 -0
- reliability.png +0 -0
- tokenizer.json +3 -0
- tokenizer_config.json +48 -0
.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 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
base_model: Qwen/Qwen3.5-0.8B-Base
|
| 4 |
+
tags: [finance, classification, calibrated-probabilities, system-one, typed-decisions]
|
| 5 |
+
---
|
| 6 |
+
# jev-fin-0.8b: a Jev-style typed decision model for finance
|
| 7 |
+
|
| 8 |
+
> Trained partly on FOMC data (CC BY-NC 4.0): **non-commercial use only**.
|
| 9 |
+
|
| 10 |
+
Full fine-tune of `Qwen/Qwen3.5-0.8B-Base`. It does **not generate text**: given a *state* (text or JSON) and typed questions
|
| 11 |
+
(`choice`, `score`, `noul`), a single forward pass reads next-token logits over option letters only, giving a
|
| 12 |
+
probability distribution per question. Probabilities are temperature-calibrated on a held-out split.
|
| 13 |
+
|
| 14 |
+
Trained on: FinGPT headline yes/no, FinGPT sentiment (FPB/FiQA/tweets/news), Twitter financial news sentiment + topic,
|
| 15 |
+
FOMC hawkish/dovish, extra tweet/text sentiment sets (if they passed the label audit), and *synthetic* portfolio questions whose labels come from exact formulas (concentration, drift, risk bucket, HHI).
|
| 16 |
+
|
| 17 |
+
## Use
|
| 18 |
+
```python
|
| 19 |
+
from huggingface_hub import hf_hub_download; import importlib.util, sys
|
| 20 |
+
p = hf_hub_download("siyah1/jev-fin-0.8b", "jev_common.py"); s = importlib.util.spec_from_file_location("jev_common", p)
|
| 21 |
+
m = importlib.util.module_from_spec(s); sys.modules["jev_common"] = m; s.loader.exec_module(m)
|
| 22 |
+
clf = m.JevClassifier("siyah1/jev-fin-0.8b")
|
| 23 |
+
print(clf.decide("Company X cuts full-year guidance and CFO resigns.", {
|
| 24 |
+
"bearish": {"type": "noul", "instructions": "Is this news negative for the stock?"},
|
| 25 |
+
"topic": {"type": "choice", "instructions": "Which topic?", "criteria": {"earnings": "results/guidance", "personnel": "executive changes", "m&a": "deals"}},
|
| 26 |
+
"severity": {"type": "score", "instructions": "How negative is this?", "levels": ["mild", "moderate", "severe"]}}))
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
## Limits (read this)
|
| 30 |
+
* It classifies **text/state**; it does **not predict returns**. Headline labels say what a headline *talks about*, not what the price will do.
|
| 31 |
+
* Portfolio questions are learned from synthetic, rule-labelled data; check arithmetic-heavy answers with real code.
|
| 32 |
+
* Calibration is measured in-distribution; expect worse calibration on questions unlike the training tasks.
|
| 33 |
+
* Not financial advice.
|
| 34 |
+
|
| 35 |
+
## Held-out test metrics
|
| 36 |
+
```json
|
| 37 |
+
[
|
| 38 |
+
{
|
| 39 |
+
"slice":"ALL",
|
| 40 |
+
"n":7290,
|
| 41 |
+
"acc":0.8963,
|
| 42 |
+
"ece_raw":0.0505,
|
| 43 |
+
"ece_cal":0.0112,
|
| 44 |
+
"brier_raw":0.1534,
|
| 45 |
+
"brier_cal":0.1431,
|
| 46 |
+
"nll_raw":0.304,
|
| 47 |
+
"nll_cal":0.2624
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"slice":"type:choice",
|
| 51 |
+
"n":1424,
|
| 52 |
+
"acc":0.8954,
|
| 53 |
+
"ece_raw":0.057,
|
| 54 |
+
"ece_cal":0.0266,
|
| 55 |
+
"brier_raw":0.1521,
|
| 56 |
+
"brier_cal":0.1416,
|
| 57 |
+
"nll_raw":0.3135,
|
| 58 |
+
"nll_cal":0.2748
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"slice":"type:score",
|
| 62 |
+
"n":2043,
|
| 63 |
+
"acc":0.7915,
|
| 64 |
+
"ece_raw":0.0898,
|
| 65 |
+
"ece_cal":0.0326,
|
| 66 |
+
"brier_raw":0.3022,
|
| 67 |
+
"brier_cal":0.2827,
|
| 68 |
+
"nll_raw":0.5894,
|
| 69 |
+
"nll_cal":0.5208
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"slice":"type:noul",
|
| 73 |
+
"n":3823,
|
| 74 |
+
"acc":0.9527,
|
| 75 |
+
"ece_raw":0.0278,
|
| 76 |
+
"ece_cal":0.0077,
|
| 77 |
+
"brier_raw":0.0744,
|
| 78 |
+
"brier_cal":0.069,
|
| 79 |
+
"nll_raw":0.1478,
|
| 80 |
+
"nll_cal":0.1196
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"slice":"src:climate",
|
| 84 |
+
"n":41,
|
| 85 |
+
"acc":0.8293,
|
| 86 |
+
"ece_raw":0.1386,
|
| 87 |
+
"ece_cal":0.0943,
|
| 88 |
+
"brier_raw":0.2745,
|
| 89 |
+
"brier_cal":0.246,
|
| 90 |
+
"nll_raw":0.4514,
|
| 91 |
+
"nll_cal":0.3913
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"slice":"src:esg_environmental",
|
| 95 |
+
"n":61,
|
| 96 |
+
"acc":0.9508,
|
| 97 |
+
"ece_raw":0.0403,
|
| 98 |
+
"ece_cal":0.0205,
|
| 99 |
+
"brier_raw":0.0869,
|
| 100 |
+
"brier_cal":0.077,
|
| 101 |
+
"nll_raw":0.2006,
|
| 102 |
+
"nll_cal":0.1489
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"slice":"src:esg_governance",
|
| 106 |
+
"n":58,
|
| 107 |
+
"acc":0.931,
|
| 108 |
+
"ece_raw":0.0709,
|
| 109 |
+
"ece_cal":0.0726,
|
| 110 |
+
"brier_raw":0.1147,
|
| 111 |
+
"brier_cal":0.1095,
|
| 112 |
+
"nll_raw":0.2294,
|
| 113 |
+
"nll_cal":0.1961
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"slice":"src:esg_social",
|
| 117 |
+
"n":72,
|
| 118 |
+
"acc":0.9583,
|
| 119 |
+
"ece_raw":0.03,
|
| 120 |
+
"ece_cal":0.0464,
|
| 121 |
+
"brier_raw":0.0492,
|
| 122 |
+
"brier_cal":0.052,
|
| 123 |
+
"nll_raw":0.0801,
|
| 124 |
+
"nll_cal":0.1018
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"slice":"src:fin_cls",
|
| 128 |
+
"n":60,
|
| 129 |
+
"acc":0.8833,
|
| 130 |
+
"ece_raw":0.1039,
|
| 131 |
+
"ece_cal":0.093,
|
| 132 |
+
"brier_raw":0.2087,
|
| 133 |
+
"brier_cal":0.1921,
|
| 134 |
+
"nll_raw":0.4029,
|
| 135 |
+
"nll_cal":0.3198
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"slice":"src:fomc",
|
| 139 |
+
"n":112,
|
| 140 |
+
"acc":0.6786,
|
| 141 |
+
"ece_raw":0.1843,
|
| 142 |
+
"ece_cal":0.1045,
|
| 143 |
+
"brier_raw":0.462,
|
| 144 |
+
"brier_cal":0.4127,
|
| 145 |
+
"nll_raw":0.8413,
|
| 146 |
+
"nll_cal":0.6986
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"slice":"src:headline",
|
| 150 |
+
"n":1788,
|
| 151 |
+
"acc":0.9771,
|
| 152 |
+
"ece_raw":0.0132,
|
| 153 |
+
"ece_cal":0.0108,
|
| 154 |
+
"brier_raw":0.0378,
|
| 155 |
+
"brier_cal":0.0354,
|
| 156 |
+
"nll_raw":0.0723,
|
| 157 |
+
"nll_cal":0.0645
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"slice":"src:sentiment",
|
| 161 |
+
"n":1383,
|
| 162 |
+
"acc":0.7628,
|
| 163 |
+
"ece_raw":0.0985,
|
| 164 |
+
"ece_cal":0.0398,
|
| 165 |
+
"brier_raw":0.3381,
|
| 166 |
+
"brier_cal":0.3171,
|
| 167 |
+
"nll_raw":0.6822,
|
| 168 |
+
"nll_cal":0.591
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"slice":"src:synth_company",
|
| 172 |
+
"n":435,
|
| 173 |
+
"acc":0.9862,
|
| 174 |
+
"ece_raw":0.0076,
|
| 175 |
+
"ece_cal":0.0134,
|
| 176 |
+
"brier_raw":0.0198,
|
| 177 |
+
"brier_cal":0.0198,
|
| 178 |
+
"nll_raw":0.0337,
|
| 179 |
+
"nll_cal":0.0378
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
"slice":"src:synth_loan",
|
| 183 |
+
"n":264,
|
| 184 |
+
"acc":0.9811,
|
| 185 |
+
"ece_raw":0.0186,
|
| 186 |
+
"ece_cal":0.0252,
|
| 187 |
+
"brier_raw":0.0322,
|
| 188 |
+
"brier_cal":0.0301,
|
| 189 |
+
"nll_raw":0.0482,
|
| 190 |
+
"nll_cal":0.051
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"slice":"src:synth_macro",
|
| 194 |
+
"n":279,
|
| 195 |
+
"acc":1.0,
|
| 196 |
+
"ece_raw":0.0,
|
| 197 |
+
"ece_cal":0.0015,
|
| 198 |
+
"brier_raw":0.0,
|
| 199 |
+
"brier_cal":0.0,
|
| 200 |
+
"nll_raw":0.0,
|
| 201 |
+
"nll_cal":0.0015
|
| 202 |
+
},
|
| 203 |
+
{
|
| 204 |
+
"slice":"src:synth_portfolio",
|
| 205 |
+
"n":940,
|
| 206 |
+
"acc":0.9734,
|
| 207 |
+
"ece_raw":0.0104,
|
| 208 |
+
"ece_cal":0.0204,
|
| 209 |
+
"brier_raw":0.0402,
|
| 210 |
+
"brier_cal":0.0402,
|
| 211 |
+
"nll_raw":0.0671,
|
| 212 |
+
"nll_cal":0.0742
|
| 213 |
+
},
|
| 214 |
+
{
|
| 215 |
+
"slice":"src:tfns",
|
| 216 |
+
"n":136,
|
| 217 |
+
"acc":0.9118,
|
| 218 |
+
"ece_raw":0.0533,
|
| 219 |
+
"ece_cal":0.0289,
|
| 220 |
+
"brier_raw":0.1389,
|
| 221 |
+
"brier_cal":0.1281,
|
| 222 |
+
"nll_raw":0.2646,
|
| 223 |
+
"nll_cal":0.2215
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"slice":"src:topic",
|
| 227 |
+
"n":650,
|
| 228 |
+
"acc":0.9123,
|
| 229 |
+
"ece_raw":0.0617,
|
| 230 |
+
"ece_cal":0.0305,
|
| 231 |
+
"brier_raw":0.1366,
|
| 232 |
+
"brier_cal":0.1265,
|
| 233 |
+
"nll_raw":0.3376,
|
| 234 |
+
"nll_cal":0.2793
|
| 235 |
+
},
|
| 236 |
+
{
|
| 237 |
+
"slice":"src:tweets2",
|
| 238 |
+
"n":536,
|
| 239 |
+
"acc":0.7948,
|
| 240 |
+
"ece_raw":0.1405,
|
| 241 |
+
"ece_cal":0.0803,
|
| 242 |
+
"brier_raw":0.3332,
|
| 243 |
+
"brier_cal":0.2984,
|
| 244 |
+
"nll_raw":0.6789,
|
| 245 |
+
"nll_cal":0.514
|
| 246 |
+
},
|
| 247 |
+
{
|
| 248 |
+
"slice":"src:wcb",
|
| 249 |
+
"n":231,
|
| 250 |
+
"acc":0.6667,
|
| 251 |
+
"ece_raw":0.1579,
|
| 252 |
+
"ece_cal":0.1003,
|
| 253 |
+
"brier_raw":0.457,
|
| 254 |
+
"brier_cal":0.4266,
|
| 255 |
+
"nll_raw":0.834,
|
| 256 |
+
"nll_cal":0.7591
|
| 257 |
+
},
|
| 258 |
+
{
|
| 259 |
+
"slice":"src:wcb_time",
|
| 260 |
+
"n":117,
|
| 261 |
+
"acc":0.8632,
|
| 262 |
+
"ece_raw":0.0392,
|
| 263 |
+
"ece_cal":0.0595,
|
| 264 |
+
"brier_raw":0.1891,
|
| 265 |
+
"brier_cal":0.1942,
|
| 266 |
+
"nll_raw":0.3138,
|
| 267 |
+
"nll_cal":0.3237
|
| 268 |
+
},
|
| 269 |
+
{
|
| 270 |
+
"slice":"src:wcb_uncertain",
|
| 271 |
+
"n":127,
|
| 272 |
+
"acc":0.8504,
|
| 273 |
+
"ece_raw":0.0815,
|
| 274 |
+
"ece_cal":0.0959,
|
| 275 |
+
"brier_raw":0.1847,
|
| 276 |
+
"brier_cal":0.1835,
|
| 277 |
+
"nll_raw":0.2823,
|
| 278 |
+
"nll_cal":0.3037
|
| 279 |
+
}
|
| 280 |
+
]
|
| 281 |
+
```
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set image_count = namespace(value=0) %}
|
| 2 |
+
{%- set video_count = namespace(value=0) %}
|
| 3 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
+
{%- if content is string %}
|
| 5 |
+
{{- content }}
|
| 6 |
+
{%- elif content is iterable and content is not mapping %}
|
| 7 |
+
{%- for item in content %}
|
| 8 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
| 9 |
+
{%- if is_system_content %}
|
| 10 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- if do_vision_count %}
|
| 13 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if add_vision_id %}
|
| 16 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
+
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
+
{%- if is_system_content %}
|
| 21 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{%- if do_vision_count %}
|
| 24 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
{%- if add_vision_id %}
|
| 27 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
+
{%- elif 'text' in item %}
|
| 31 |
+
{{- item.text }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- endfor %}
|
| 36 |
+
{%- elif content is none or content is undefined %}
|
| 37 |
+
{{- '' }}
|
| 38 |
+
{%- else %}
|
| 39 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endmacro %}
|
| 42 |
+
{%- if not messages %}
|
| 43 |
+
{{- raise_exception('No messages provided.') }}
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- if tools and tools is iterable and tools is not mapping %}
|
| 46 |
+
{{- '<|im_start|>system\n' }}
|
| 47 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 48 |
+
{%- for tool in tools %}
|
| 49 |
+
{{- "\n" }}
|
| 50 |
+
{{- tool | tojson }}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{{- "\n</tools>" }}
|
| 53 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 54 |
+
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 56 |
+
{%- if content %}
|
| 57 |
+
{{- '\n\n' + content }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endif %}
|
| 60 |
+
{{- '<|im_end|>\n' }}
|
| 61 |
+
{%- else %}
|
| 62 |
+
{%- if messages[0].role == 'system' %}
|
| 63 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 64 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endif %}
|
| 67 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 68 |
+
{%- for message in messages[::-1] %}
|
| 69 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 70 |
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 71 |
+
{%- set content = render_content(message.content, false)|trim %}
|
| 72 |
+
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 73 |
+
{%- set ns.multi_step_tool = false %}
|
| 74 |
+
{%- set ns.last_query_index = index %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- if ns.multi_step_tool %}
|
| 79 |
+
{{- raise_exception('No user query found in messages.') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- for message in messages %}
|
| 82 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 83 |
+
{%- if message.role == "system" %}
|
| 84 |
+
{%- if not loop.first %}
|
| 85 |
+
{{- raise_exception('System message must be at the beginning.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- elif message.role == "user" %}
|
| 88 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 89 |
+
{%- elif message.role == "assistant" %}
|
| 90 |
+
{%- set reasoning_content = '' %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 100 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 101 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 102 |
+
{%- else %}
|
| 103 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 106 |
+
{%- for tool_call in message.tool_calls %}
|
| 107 |
+
{%- if tool_call.function is defined %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{%- if loop.first %}
|
| 111 |
+
{%- if content|trim %}
|
| 112 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 113 |
+
{%- else %}
|
| 114 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{%- else %}
|
| 117 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 118 |
+
{%- endif %}
|
| 119 |
+
{%- if tool_call.arguments is defined %}
|
| 120 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 121 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 122 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 123 |
+
{{- args_value }}
|
| 124 |
+
{{- '\n</parameter>\n' }}
|
| 125 |
+
{%- endfor %}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
{{- '</function>\n</tool_call>' }}
|
| 128 |
+
{%- endfor %}
|
| 129 |
+
{%- endif %}
|
| 130 |
+
{{- '<|im_end|>\n' }}
|
| 131 |
+
{%- elif message.role == "tool" %}
|
| 132 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 133 |
+
{{- '<|im_start|>user' }}
|
| 134 |
+
{%- endif %}
|
| 135 |
+
{{- '\n<tool_response>\n' }}
|
| 136 |
+
{{- content }}
|
| 137 |
+
{{- '\n</tool_response>' }}
|
| 138 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 139 |
+
{{- '<|im_end|>\n' }}
|
| 140 |
+
{%- elif loop.last %}
|
| 141 |
+
{{- '<|im_end|>\n' }}
|
| 142 |
+
{%- endif %}
|
| 143 |
+
{%- else %}
|
| 144 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 145 |
+
{%- endif %}
|
| 146 |
+
{%- endfor %}
|
| 147 |
+
{%- if add_generation_prompt %}
|
| 148 |
+
{{- '<|im_start|>assistant\n' }}
|
| 149 |
+
{%- if enable_thinking is defined and enable_thinking is true %}
|
| 150 |
+
{{- '<think>\n' }}
|
| 151 |
+
{%- else %}
|
| 152 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 153 |
+
{%- endif %}
|
| 154 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3_5ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"attn_output_gate": true,
|
| 8 |
+
"bos_token_id": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": 248044,
|
| 11 |
+
"full_attention_interval": 4,
|
| 12 |
+
"head_dim": 256,
|
| 13 |
+
"hidden_act": "silu",
|
| 14 |
+
"hidden_size": 1024,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 3584,
|
| 17 |
+
"layer_types": [
|
| 18 |
+
"linear_attention",
|
| 19 |
+
"linear_attention",
|
| 20 |
+
"linear_attention",
|
| 21 |
+
"full_attention",
|
| 22 |
+
"linear_attention",
|
| 23 |
+
"linear_attention",
|
| 24 |
+
"linear_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"linear_attention",
|
| 27 |
+
"linear_attention",
|
| 28 |
+
"linear_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"linear_attention",
|
| 31 |
+
"linear_attention",
|
| 32 |
+
"linear_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"linear_attention",
|
| 35 |
+
"linear_attention",
|
| 36 |
+
"linear_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"linear_attention",
|
| 39 |
+
"linear_attention",
|
| 40 |
+
"linear_attention",
|
| 41 |
+
"full_attention"
|
| 42 |
+
],
|
| 43 |
+
"linear_conv_kernel_dim": 4,
|
| 44 |
+
"linear_key_head_dim": 128,
|
| 45 |
+
"linear_num_key_heads": 16,
|
| 46 |
+
"linear_num_value_heads": 16,
|
| 47 |
+
"linear_value_head_dim": 128,
|
| 48 |
+
"mamba_ssm_dtype": "float32",
|
| 49 |
+
"max_position_embeddings": 262144,
|
| 50 |
+
"mlp_only_layers": [],
|
| 51 |
+
"model_type": "qwen3_5_text",
|
| 52 |
+
"mtp_num_hidden_layers": 1,
|
| 53 |
+
"mtp_use_dedicated_embeddings": false,
|
| 54 |
+
"num_attention_heads": 8,
|
| 55 |
+
"num_hidden_layers": 24,
|
| 56 |
+
"num_key_value_heads": 2,
|
| 57 |
+
"pad_token_id": null,
|
| 58 |
+
"rms_norm_eps": 1e-06,
|
| 59 |
+
"rope_parameters": {
|
| 60 |
+
"mrope_interleaved": true,
|
| 61 |
+
"mrope_section": [
|
| 62 |
+
11,
|
| 63 |
+
11,
|
| 64 |
+
10
|
| 65 |
+
],
|
| 66 |
+
"partial_rotary_factor": 0.25,
|
| 67 |
+
"rope_theta": 10000000,
|
| 68 |
+
"rope_type": "default"
|
| 69 |
+
},
|
| 70 |
+
"tie_word_embeddings": true,
|
| 71 |
+
"transformers_version": "5.24.0",
|
| 72 |
+
"use_cache": false,
|
| 73 |
+
"vocab_size": 248320
|
| 74 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"eos_token_id": 248044,
|
| 4 |
+
"transformers_version": "5.24.0",
|
| 5 |
+
"use_cache": true
|
| 6 |
+
}
|
jev_common.py
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""jev_common.py - shared code for a Jev-style (System One) typed decision model.
|
| 2 |
+
|
| 3 |
+
Idea: one forward pass over <state> + <question> + <options> and read the next-token
|
| 4 |
+
logits ONLY over option-letter tokens (" A", " B", ...). Softmax over those letters is the
|
| 5 |
+
probability distribution over the typed answer. No text is ever generated.
|
| 6 |
+
"""
|
| 7 |
+
import json
|
| 8 |
+
import os
|
| 9 |
+
import random
|
| 10 |
+
|
| 11 |
+
import torch
|
| 12 |
+
import torch.nn as nn
|
| 13 |
+
|
| 14 |
+
LETTERS = [chr(65 + i) for i in range(26)]
|
| 15 |
+
MAX_OPTS = 26
|
| 16 |
+
TEMPLATE_VERSION = "v1"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# ----------------------------------------------------------------------------- prompt
|
| 20 |
+
def build_prompt(state, question, options, qtype):
|
| 21 |
+
opts = "\n".join(f"{LETTERS[i]}. {o}" for i, o in enumerate(options))
|
| 22 |
+
return (
|
| 23 |
+
f"<state>\n{state}\n</state>\n"
|
| 24 |
+
f"<question type=\"{qtype}\">\n{question}\n</question>\n"
|
| 25 |
+
f"<options>\n{opts}\n</options>\nAnswer:"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def prepare(rec, rng=None, shuffle=True):
|
| 30 |
+
"""Shuffle option order for choice/noul (kills position bias). Score levels keep low->high order."""
|
| 31 |
+
opts = list(rec["options"])
|
| 32 |
+
lab = rec.get("label", 0)
|
| 33 |
+
if shuffle and rng is not None and rec["qtype"] != "score":
|
| 34 |
+
perm = list(range(len(opts)))
|
| 35 |
+
rng.shuffle(perm)
|
| 36 |
+
opts = [opts[p] for p in perm]
|
| 37 |
+
lab = perm.index(lab)
|
| 38 |
+
return opts, lab
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def encode_prompt(tok, state, question, options, qtype, max_len, state_chars=1600):
|
| 42 |
+
st = state if len(state) <= state_chars else state[:state_chars] + " ..."
|
| 43 |
+
while True:
|
| 44 |
+
ids = tok(build_prompt(st, question, options, qtype), add_special_tokens=False)["input_ids"]
|
| 45 |
+
if len(ids) <= max_len or len(st) < 50:
|
| 46 |
+
return ids[-max_len:] # keep the tail (question + options + "Answer:")
|
| 47 |
+
st = st[: len(st) // 2]
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def letter_token_ids(tok):
|
| 51 |
+
ids = []
|
| 52 |
+
for L in LETTERS:
|
| 53 |
+
t = tok.encode(" " + L, add_special_tokens=False)
|
| 54 |
+
assert len(t) == 1, f"' {L}' is not a single token for this tokenizer: {t}"
|
| 55 |
+
ids.append(t[0])
|
| 56 |
+
return ids
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def collate(items, pad_id):
|
| 60 |
+
"""items: list of (ids, n_opts, label). Right padding (safe for linear-attention layers too)."""
|
| 61 |
+
L = max(len(i[0]) for i in items)
|
| 62 |
+
ids = torch.full((len(items), L), pad_id, dtype=torch.long)
|
| 63 |
+
mask = torch.zeros((len(items), L), dtype=torch.long)
|
| 64 |
+
for j, (x, _, _) in enumerate(items):
|
| 65 |
+
ids[j, : len(x)] = torch.tensor(x)
|
| 66 |
+
mask[j, : len(x)] = 1
|
| 67 |
+
n_opts = torch.tensor([i[1] for i in items], dtype=torch.long)
|
| 68 |
+
labels = torch.tensor([i[2] for i in items], dtype=torch.long)
|
| 69 |
+
return {"input_ids": ids, "attention_mask": mask, "n_opts": n_opts, "labels": labels}
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def mask_logits(logits, n_opts):
|
| 73 |
+
cols = torch.arange(logits.size(1), device=logits.device)[None, :]
|
| 74 |
+
return logits.masked_fill(cols >= n_opts.to(logits.device)[:, None], -1e4)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
# ----------------------------------------------------------------------------- model
|
| 78 |
+
def load_lm(path, dtype=torch.float32, **kw):
|
| 79 |
+
from transformers import AutoModelForCausalLM
|
| 80 |
+
try:
|
| 81 |
+
return AutoModelForCausalLM.from_pretrained(path, dtype=dtype, **kw)
|
| 82 |
+
except TypeError: # older transformers
|
| 83 |
+
return AutoModelForCausalLM.from_pretrained(path, torch_dtype=dtype, **kw)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class JevModel(nn.Module):
|
| 87 |
+
"""Backbone + restricted read-out. Never materialises the 248k-vocab logits (huge memory saver)."""
|
| 88 |
+
|
| 89 |
+
def __init__(self, lm, letter_ids):
|
| 90 |
+
super().__init__()
|
| 91 |
+
self.lm = lm
|
| 92 |
+
self.register_buffer("letter_ids", torch.tensor(letter_ids, dtype=torch.long), persistent=False)
|
| 93 |
+
|
| 94 |
+
def forward(self, input_ids, attention_mask):
|
| 95 |
+
out = self.lm.model(input_ids=input_ids, attention_mask=attention_mask)
|
| 96 |
+
h = out.last_hidden_state
|
| 97 |
+
last = attention_mask.sum(1) - 1
|
| 98 |
+
h = h[torch.arange(h.size(0), device=h.device), last]
|
| 99 |
+
W = self.lm.get_output_embeddings().weight[self.letter_ids] # (26, hidden)
|
| 100 |
+
return (h @ W.t()).float() # (B, 26) unmasked
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
@torch.no_grad()
|
| 104 |
+
def predict_logits(model, tok, recs, device, bs=32, max_len=640, shuffle_seed=1234):
|
| 105 |
+
"""Returns list of (logits[n_opts] cpu float, label) with deterministic option shuffling."""
|
| 106 |
+
model.eval()
|
| 107 |
+
pad = tok.pad_token_id if tok.pad_token_id is not None else tok.eos_token_id
|
| 108 |
+
order = sorted(range(len(recs)), key=lambda i: len(recs[i]["state"]))
|
| 109 |
+
out = [None] * len(recs)
|
| 110 |
+
for s in range(0, len(order), bs):
|
| 111 |
+
idx = order[s : s + bs]
|
| 112 |
+
items = []
|
| 113 |
+
for i in idx:
|
| 114 |
+
r = recs[i]
|
| 115 |
+
opts, lab = prepare(r, random.Random(shuffle_seed + i), True)
|
| 116 |
+
items.append((encode_prompt(tok, r["state"], r["question"], opts, r["qtype"], max_len), len(opts), lab))
|
| 117 |
+
b = collate(items, pad)
|
| 118 |
+
with torch.autocast("cuda", dtype=torch.float16, enabled=str(device).startswith("cuda")):
|
| 119 |
+
lg = model(b["input_ids"].to(device), b["attention_mask"].to(device))
|
| 120 |
+
for j, i in enumerate(idx):
|
| 121 |
+
n = items[j][1]
|
| 122 |
+
out[i] = (lg[j, :n].float().cpu(), items[j][2])
|
| 123 |
+
return out
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
# ----------------------------------------------------------------------------- inference API
|
| 127 |
+
class JevClassifier:
|
| 128 |
+
"""Jev-API-like interface: decide(state, {key: {type, instructions, criteria|levels}})"""
|
| 129 |
+
|
| 130 |
+
def __init__(self, path, device=None, dtype=torch.float16):
|
| 131 |
+
from transformers import AutoTokenizer
|
| 132 |
+
if not os.path.isdir(path):
|
| 133 |
+
from huggingface_hub import snapshot_download
|
| 134 |
+
path = snapshot_download(path)
|
| 135 |
+
self.cfg = json.load(open(os.path.join(path, "jev_config.json")))
|
| 136 |
+
self.tok = AutoTokenizer.from_pretrained(path)
|
| 137 |
+
self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
|
| 138 |
+
lm = load_lm(path, dtype=dtype if self.device != "cpu" else torch.float32).to(self.device)
|
| 139 |
+
self.model = JevModel(lm, letter_token_ids(self.tok)).eval()
|
| 140 |
+
self.max_len = self.cfg.get("max_len", 640)
|
| 141 |
+
self.pad = self.tok.pad_token_id if self.tok.pad_token_id is not None else self.tok.eos_token_id
|
| 142 |
+
|
| 143 |
+
def _temp(self, qtype):
|
| 144 |
+
t = self.cfg.get("temperature", {})
|
| 145 |
+
return float(t.get(qtype, t.get("default", 1.0)))
|
| 146 |
+
|
| 147 |
+
@torch.no_grad()
|
| 148 |
+
def decide(self, state, questions, debias=True):
|
| 149 |
+
if not isinstance(state, str):
|
| 150 |
+
state = json.dumps(state, ensure_ascii=False)
|
| 151 |
+
specs, jobs = {}, []
|
| 152 |
+
for key, q in questions.items():
|
| 153 |
+
t = q["type"].lower()
|
| 154 |
+
instr = q.get("instructions", "")
|
| 155 |
+
if t == "noul":
|
| 156 |
+
base, text = ["No", "Yes"], instr
|
| 157 |
+
elif t == "choice":
|
| 158 |
+
crit = q["criteria"]
|
| 159 |
+
base = list(crit)
|
| 160 |
+
text = instr + "\n" + "\n".join(f"- {k}: {v}" for k, v in crit.items())
|
| 161 |
+
elif t == "score":
|
| 162 |
+
lv = q["levels"]
|
| 163 |
+
base = list(lv)
|
| 164 |
+
text = instr
|
| 165 |
+
if isinstance(lv, dict):
|
| 166 |
+
text += "\n" + "\n".join(f"- {k}: {v}" for k, v in lv.items())
|
| 167 |
+
else:
|
| 168 |
+
raise ValueError(f"unknown question type {t}")
|
| 169 |
+
specs[key] = (t, base)
|
| 170 |
+
orders = [base] + ([base[::-1]] if debias and t != "score" else [])
|
| 171 |
+
for o in orders:
|
| 172 |
+
jobs.append((key, o, encode_prompt(self.tok, state, text, o, t, self.max_len)))
|
| 173 |
+
|
| 174 |
+
acc = {k: torch.zeros(len(v[1])) for k, v in specs.items()}
|
| 175 |
+
cnt = {k: 0 for k in specs}
|
| 176 |
+
for s in range(0, len(jobs), 32):
|
| 177 |
+
chunk = jobs[s : s + 32]
|
| 178 |
+
b = collate([(ids, len(o), 0) for _, o, ids in chunk], self.pad)
|
| 179 |
+
with torch.autocast("cuda", dtype=torch.float16, enabled=self.device.startswith("cuda")):
|
| 180 |
+
lg = self.model(b["input_ids"].to(self.device), b["attention_mask"].to(self.device)).cpu()
|
| 181 |
+
for j, (key, o, _) in enumerate(chunk):
|
| 182 |
+
t, base = specs[key]
|
| 183 |
+
p = torch.softmax(lg[j, : len(o)] / self._temp(t), dim=-1)
|
| 184 |
+
for pos, name in enumerate(o):
|
| 185 |
+
acc[key][base.index(name)] += p[pos]
|
| 186 |
+
cnt[key] += 1
|
| 187 |
+
|
| 188 |
+
res = {}
|
| 189 |
+
for key, (t, base) in specs.items():
|
| 190 |
+
p = acc[key] / cnt[key]
|
| 191 |
+
probs = {n: round(float(p[i]), 4) for i, n in enumerate(base)}
|
| 192 |
+
best = int(p.argmax())
|
| 193 |
+
if t == "noul":
|
| 194 |
+
res[key] = {"type": "noul", "noul": probs["Yes"]}
|
| 195 |
+
elif t == "choice":
|
| 196 |
+
res[key] = {"type": "choice", "choice": base[best], "probabilities": probs,
|
| 197 |
+
"confidence": round(float(p.max()), 4)}
|
| 198 |
+
else:
|
| 199 |
+
k = len(base)
|
| 200 |
+
expected = float(sum(p[i] * (i / (k - 1)) for i in range(k))) if k > 1 else 0.0
|
| 201 |
+
res[key] = {"type": "score", "level": base[best], "score": round(expected, 4),
|
| 202 |
+
"probabilities": probs, "confidence": round(float(p.max()), 4)}
|
| 203 |
+
return res
|
jev_config.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"base_model": "Qwen/Qwen3.5-0.8B-Base",
|
| 3 |
+
"template_version": "v1",
|
| 4 |
+
"max_len": 640,
|
| 5 |
+
"temperature": {
|
| 6 |
+
"default": 1.6105858214307611,
|
| 7 |
+
"choice": 1.4563030894060642,
|
| 8 |
+
"score": 1.6105858214307611,
|
| 9 |
+
"noul": 1.8731908277980631
|
| 10 |
+
}
|
| 11 |
+
}
|
metrics.json
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"slice":"ALL",
|
| 4 |
+
"n":7290,
|
| 5 |
+
"acc":0.8963,
|
| 6 |
+
"ece_raw":0.0505,
|
| 7 |
+
"ece_cal":0.0112,
|
| 8 |
+
"brier_raw":0.1534,
|
| 9 |
+
"brier_cal":0.1431,
|
| 10 |
+
"nll_raw":0.304,
|
| 11 |
+
"nll_cal":0.2624
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"slice":"type:choice",
|
| 15 |
+
"n":1424,
|
| 16 |
+
"acc":0.8954,
|
| 17 |
+
"ece_raw":0.057,
|
| 18 |
+
"ece_cal":0.0266,
|
| 19 |
+
"brier_raw":0.1521,
|
| 20 |
+
"brier_cal":0.1416,
|
| 21 |
+
"nll_raw":0.3135,
|
| 22 |
+
"nll_cal":0.2748
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"slice":"type:score",
|
| 26 |
+
"n":2043,
|
| 27 |
+
"acc":0.7915,
|
| 28 |
+
"ece_raw":0.0898,
|
| 29 |
+
"ece_cal":0.0326,
|
| 30 |
+
"brier_raw":0.3022,
|
| 31 |
+
"brier_cal":0.2827,
|
| 32 |
+
"nll_raw":0.5894,
|
| 33 |
+
"nll_cal":0.5208
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"slice":"type:noul",
|
| 37 |
+
"n":3823,
|
| 38 |
+
"acc":0.9527,
|
| 39 |
+
"ece_raw":0.0278,
|
| 40 |
+
"ece_cal":0.0077,
|
| 41 |
+
"brier_raw":0.0744,
|
| 42 |
+
"brier_cal":0.069,
|
| 43 |
+
"nll_raw":0.1478,
|
| 44 |
+
"nll_cal":0.1196
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"slice":"src:climate",
|
| 48 |
+
"n":41,
|
| 49 |
+
"acc":0.8293,
|
| 50 |
+
"ece_raw":0.1386,
|
| 51 |
+
"ece_cal":0.0943,
|
| 52 |
+
"brier_raw":0.2745,
|
| 53 |
+
"brier_cal":0.246,
|
| 54 |
+
"nll_raw":0.4514,
|
| 55 |
+
"nll_cal":0.3913
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"slice":"src:esg_environmental",
|
| 59 |
+
"n":61,
|
| 60 |
+
"acc":0.9508,
|
| 61 |
+
"ece_raw":0.0403,
|
| 62 |
+
"ece_cal":0.0205,
|
| 63 |
+
"brier_raw":0.0869,
|
| 64 |
+
"brier_cal":0.077,
|
| 65 |
+
"nll_raw":0.2006,
|
| 66 |
+
"nll_cal":0.1489
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"slice":"src:esg_governance",
|
| 70 |
+
"n":58,
|
| 71 |
+
"acc":0.931,
|
| 72 |
+
"ece_raw":0.0709,
|
| 73 |
+
"ece_cal":0.0726,
|
| 74 |
+
"brier_raw":0.1147,
|
| 75 |
+
"brier_cal":0.1095,
|
| 76 |
+
"nll_raw":0.2294,
|
| 77 |
+
"nll_cal":0.1961
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"slice":"src:esg_social",
|
| 81 |
+
"n":72,
|
| 82 |
+
"acc":0.9583,
|
| 83 |
+
"ece_raw":0.03,
|
| 84 |
+
"ece_cal":0.0464,
|
| 85 |
+
"brier_raw":0.0492,
|
| 86 |
+
"brier_cal":0.052,
|
| 87 |
+
"nll_raw":0.0801,
|
| 88 |
+
"nll_cal":0.1018
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"slice":"src:fin_cls",
|
| 92 |
+
"n":60,
|
| 93 |
+
"acc":0.8833,
|
| 94 |
+
"ece_raw":0.1039,
|
| 95 |
+
"ece_cal":0.093,
|
| 96 |
+
"brier_raw":0.2087,
|
| 97 |
+
"brier_cal":0.1921,
|
| 98 |
+
"nll_raw":0.4029,
|
| 99 |
+
"nll_cal":0.3198
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"slice":"src:fomc",
|
| 103 |
+
"n":112,
|
| 104 |
+
"acc":0.6786,
|
| 105 |
+
"ece_raw":0.1843,
|
| 106 |
+
"ece_cal":0.1045,
|
| 107 |
+
"brier_raw":0.462,
|
| 108 |
+
"brier_cal":0.4127,
|
| 109 |
+
"nll_raw":0.8413,
|
| 110 |
+
"nll_cal":0.6986
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"slice":"src:headline",
|
| 114 |
+
"n":1788,
|
| 115 |
+
"acc":0.9771,
|
| 116 |
+
"ece_raw":0.0132,
|
| 117 |
+
"ece_cal":0.0108,
|
| 118 |
+
"brier_raw":0.0378,
|
| 119 |
+
"brier_cal":0.0354,
|
| 120 |
+
"nll_raw":0.0723,
|
| 121 |
+
"nll_cal":0.0645
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"slice":"src:sentiment",
|
| 125 |
+
"n":1383,
|
| 126 |
+
"acc":0.7628,
|
| 127 |
+
"ece_raw":0.0985,
|
| 128 |
+
"ece_cal":0.0398,
|
| 129 |
+
"brier_raw":0.3381,
|
| 130 |
+
"brier_cal":0.3171,
|
| 131 |
+
"nll_raw":0.6822,
|
| 132 |
+
"nll_cal":0.591
|
| 133 |
+
},
|
| 134 |
+
{
|
| 135 |
+
"slice":"src:synth_company",
|
| 136 |
+
"n":435,
|
| 137 |
+
"acc":0.9862,
|
| 138 |
+
"ece_raw":0.0076,
|
| 139 |
+
"ece_cal":0.0134,
|
| 140 |
+
"brier_raw":0.0198,
|
| 141 |
+
"brier_cal":0.0198,
|
| 142 |
+
"nll_raw":0.0337,
|
| 143 |
+
"nll_cal":0.0378
|
| 144 |
+
},
|
| 145 |
+
{
|
| 146 |
+
"slice":"src:synth_loan",
|
| 147 |
+
"n":264,
|
| 148 |
+
"acc":0.9811,
|
| 149 |
+
"ece_raw":0.0186,
|
| 150 |
+
"ece_cal":0.0252,
|
| 151 |
+
"brier_raw":0.0322,
|
| 152 |
+
"brier_cal":0.0301,
|
| 153 |
+
"nll_raw":0.0482,
|
| 154 |
+
"nll_cal":0.051
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"slice":"src:synth_macro",
|
| 158 |
+
"n":279,
|
| 159 |
+
"acc":1.0,
|
| 160 |
+
"ece_raw":0.0,
|
| 161 |
+
"ece_cal":0.0015,
|
| 162 |
+
"brier_raw":0.0,
|
| 163 |
+
"brier_cal":0.0,
|
| 164 |
+
"nll_raw":0.0,
|
| 165 |
+
"nll_cal":0.0015
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"slice":"src:synth_portfolio",
|
| 169 |
+
"n":940,
|
| 170 |
+
"acc":0.9734,
|
| 171 |
+
"ece_raw":0.0104,
|
| 172 |
+
"ece_cal":0.0204,
|
| 173 |
+
"brier_raw":0.0402,
|
| 174 |
+
"brier_cal":0.0402,
|
| 175 |
+
"nll_raw":0.0671,
|
| 176 |
+
"nll_cal":0.0742
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"slice":"src:tfns",
|
| 180 |
+
"n":136,
|
| 181 |
+
"acc":0.9118,
|
| 182 |
+
"ece_raw":0.0533,
|
| 183 |
+
"ece_cal":0.0289,
|
| 184 |
+
"brier_raw":0.1389,
|
| 185 |
+
"brier_cal":0.1281,
|
| 186 |
+
"nll_raw":0.2646,
|
| 187 |
+
"nll_cal":0.2215
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"slice":"src:topic",
|
| 191 |
+
"n":650,
|
| 192 |
+
"acc":0.9123,
|
| 193 |
+
"ece_raw":0.0617,
|
| 194 |
+
"ece_cal":0.0305,
|
| 195 |
+
"brier_raw":0.1366,
|
| 196 |
+
"brier_cal":0.1265,
|
| 197 |
+
"nll_raw":0.3376,
|
| 198 |
+
"nll_cal":0.2793
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"slice":"src:tweets2",
|
| 202 |
+
"n":536,
|
| 203 |
+
"acc":0.7948,
|
| 204 |
+
"ece_raw":0.1405,
|
| 205 |
+
"ece_cal":0.0803,
|
| 206 |
+
"brier_raw":0.3332,
|
| 207 |
+
"brier_cal":0.2984,
|
| 208 |
+
"nll_raw":0.6789,
|
| 209 |
+
"nll_cal":0.514
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"slice":"src:wcb",
|
| 213 |
+
"n":231,
|
| 214 |
+
"acc":0.6667,
|
| 215 |
+
"ece_raw":0.1579,
|
| 216 |
+
"ece_cal":0.1003,
|
| 217 |
+
"brier_raw":0.457,
|
| 218 |
+
"brier_cal":0.4266,
|
| 219 |
+
"nll_raw":0.834,
|
| 220 |
+
"nll_cal":0.7591
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"slice":"src:wcb_time",
|
| 224 |
+
"n":117,
|
| 225 |
+
"acc":0.8632,
|
| 226 |
+
"ece_raw":0.0392,
|
| 227 |
+
"ece_cal":0.0595,
|
| 228 |
+
"brier_raw":0.1891,
|
| 229 |
+
"brier_cal":0.1942,
|
| 230 |
+
"nll_raw":0.3138,
|
| 231 |
+
"nll_cal":0.3237
|
| 232 |
+
},
|
| 233 |
+
{
|
| 234 |
+
"slice":"src:wcb_uncertain",
|
| 235 |
+
"n":127,
|
| 236 |
+
"acc":0.8504,
|
| 237 |
+
"ece_raw":0.0815,
|
| 238 |
+
"ece_cal":0.0959,
|
| 239 |
+
"brier_raw":0.1847,
|
| 240 |
+
"brier_cal":0.1835,
|
| 241 |
+
"nll_raw":0.2823,
|
| 242 |
+
"nll_cal":0.3037
|
| 243 |
+
}
|
| 244 |
+
]
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc9af247bcc71ae0d0e4484a1e6a5471c68e522a6758a538378b7d02bee085cc
|
| 3 |
+
size 2013387056
|
reliability.png
ADDED
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5cd9732badce41de57e6efce8302930ded1c1188c5f81feb2bd6c24c4a1941f
|
| 3 |
+
size 19989339
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|endoftext|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"extra_special_tokens": [
|
| 12 |
+
"<|im_start|>",
|
| 13 |
+
"<|im_end|>",
|
| 14 |
+
"<|object_ref_start|>",
|
| 15 |
+
"<|object_ref_end|>",
|
| 16 |
+
"<|box_start|>",
|
| 17 |
+
"<|box_end|>",
|
| 18 |
+
"<|quad_start|>",
|
| 19 |
+
"<|quad_end|>",
|
| 20 |
+
"<|vision_start|>",
|
| 21 |
+
"<|vision_end|>",
|
| 22 |
+
"<|vision_pad|>",
|
| 23 |
+
"<|image_pad|>",
|
| 24 |
+
"<|video_pad|>"
|
| 25 |
+
],
|
| 26 |
+
"image_token": "<|image_pad|>",
|
| 27 |
+
"is_local": false,
|
| 28 |
+
"local_files_only": false,
|
| 29 |
+
"merges_file": null,
|
| 30 |
+
"model_max_length": 262144,
|
| 31 |
+
"model_specific_special_tokens": {
|
| 32 |
+
"audio_bos_token": "<|audio_start|>",
|
| 33 |
+
"audio_eos_token": "<|audio_end|>",
|
| 34 |
+
"audio_token": "<|audio_pad|>",
|
| 35 |
+
"image_token": "<|image_pad|>",
|
| 36 |
+
"video_token": "<|video_pad|>",
|
| 37 |
+
"vision_bos_token": "<|vision_start|>",
|
| 38 |
+
"vision_eos_token": "<|vision_end|>"
|
| 39 |
+
},
|
| 40 |
+
"pad_token": "<|endoftext|>",
|
| 41 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 42 |
+
"split_special_tokens": false,
|
| 43 |
+
"tokenizer_class": "Qwen3_5Tokenizer",
|
| 44 |
+
"unk_token": null,
|
| 45 |
+
"video_token": "<|video_pad|>",
|
| 46 |
+
"vision_bos_token": "<|vision_start|>",
|
| 47 |
+
"vision_eos_token": "<|vision_end|>"
|
| 48 |
+
}
|