Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- README.md +279 -0
- config.json +259 -0
- equivalence/expected.npz +3 -0
- equivalence/inputs.npz +3 -0
- equivalence/records.jsonl +0 -0
- manifest.json +26 -0
- onnx/model.onnx +3 -0
- onnx/model.onnx_data +3 -0
- onnx/model_fp16.onnx +3 -0
- onnx/model_fp16.onnx_data +3 -0
- policy/build-fp32.stats.json +99 -0
- policy/fp32.json +361 -0
- policy/fp32.npz +3 -0
- tokenizer.json +0 -0
- transformers/config.json +96 -0
- transformers/configuration_mimir.py +122 -0
- transformers/model.safetensors +3 -0
- transformers/modeling_mimir.py +838 -0
- transformers/tokenizer.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ 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 |
+
onnx/model.onnx_data filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
onnx/model_fp16.onnx_data filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: mimirai
|
| 3 |
+
license: other
|
| 4 |
+
license_name: mythologic-community-license
|
| 5 |
+
license_link: LICENSE
|
| 6 |
+
base_model: answerdotai/ModernBERT-Large-Instruct
|
| 7 |
+
language: en
|
| 8 |
+
pipeline_tag: text-classification
|
| 9 |
+
tags:
|
| 10 |
+
- decision-model
|
| 11 |
+
- calibrated-decisions
|
| 12 |
+
- structured-output
|
| 13 |
+
- classification
|
| 14 |
+
- abstention
|
| 15 |
+
- routing
|
| 16 |
+
- guardrails
|
| 17 |
+
- scoring
|
| 18 |
+
- document-verification
|
| 19 |
+
- onnx
|
| 20 |
+
- safetensors
|
| 21 |
+
- agent-tool
|
| 22 |
+
model-index:
|
| 23 |
+
- name: MIMIR-1
|
| 24 |
+
results:
|
| 25 |
+
- task: {type: text-classification, name: Banking77 intent}
|
| 26 |
+
dataset: {name: Banking77 test, type: banking77, split: test}
|
| 27 |
+
metrics: [{type: accuracy, value: 0.883, name: Exact-match accuracy}]
|
| 28 |
+
- task: {type: text-classification, name: MASSIVE English intent}
|
| 29 |
+
dataset: {name: MASSIVE English test, type: massive, split: test}
|
| 30 |
+
metrics: [{type: accuracy, value: 0.866, name: Exact-match accuracy}]
|
| 31 |
+
- task: {type: text-classification, name: Typed decisions}
|
| 32 |
+
dataset: {name: typed-decisions test, type: typed-decisions, split: test}
|
| 33 |
+
metrics: [{type: accuracy, value: 0.725, name: Exact-match accuracy}]
|
| 34 |
+
- task: {type: text-classification, name: Prompt injections}
|
| 35 |
+
dataset: {name: prompt-injections, type: prompt-injections, split: test}
|
| 36 |
+
metrics: [{type: accuracy, value: 0.957, name: Exact-match accuracy}]
|
| 37 |
+
- task: {type: text-classification, name: XNLI English}
|
| 38 |
+
dataset: {name: XNLI English test, type: xnli, split: test}
|
| 39 |
+
metrics: [{type: accuracy, value: 0.828, name: Exact-match accuracy}]
|
| 40 |
+
- task: {type: text-classification, name: BoolQ}
|
| 41 |
+
dataset: {name: BoolQ test, type: boolq, split: test}
|
| 42 |
+
metrics: [{type: accuracy, value: 0.84, name: Exact-match accuracy}]
|
| 43 |
+
- task: {type: text-classification, name: AG News}
|
| 44 |
+
dataset: {name: AG News test, type: ag-news, split: test}
|
| 45 |
+
metrics: [{type: accuracy, value: 0.921, name: Exact-match accuracy}]
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
# MIMIR-1
|
| 49 |
+
|
| 50 |
+
**English-only, non-generative decision model.** Give it a **context**, a **question** and
|
| 51 |
+
the **options**; it returns a typed answer with calibrated probabilities, the parts of
|
| 52 |
+
the context it relied on, and a certified signal for when to act and when to escalate.
|
| 53 |
+
419M parameters: a ModernBERT-Large encoder plus a decision head that refines one readout
|
| 54 |
+
per iteration over four iterations, with a certified early exit at depth 2. It never
|
| 55 |
+
generates text, so there is nothing to parse and nothing to hallucinate.
|
| 56 |
+
|
| 57 |
+
## Installation
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
pip install "mimirai[local]"
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
Python 3.12. `mimirai` is the package, `mimir` the import.
|
| 64 |
+
|
| 65 |
+
## Quickstart
|
| 66 |
+
|
| 67 |
+
> **Three outcomes, not two.** Every call ends `DECIDED`, `ABSTAINED` or `DEFERRED`.
|
| 68 |
+
> `ABSTAINED` means none of the listed options is supported; `DEFERRED` means the
|
| 69 |
+
> certificate does not cover this call at your risk level. Both are answers, not errors.
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
from mimir import Mimir
|
| 73 |
+
|
| 74 |
+
model = Mimir.from_pretrained("Mythologic/MIMIR-1") # downloads weights on first use
|
| 75 |
+
|
| 76 |
+
result = model.choose(
|
| 77 |
+
"My card was charged twice for the same order.",
|
| 78 |
+
"Which team should handle this?",
|
| 79 |
+
options={"billing": "Billing: payments, refunds", "security": "Security: account access"},
|
| 80 |
+
)
|
| 81 |
+
print(result.status) # DECIDED
|
| 82 |
+
print(result.answer) # billing, with calibrated probabilities over the options
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## Calibrate for tighter guarantees
|
| 86 |
+
|
| 87 |
+
The shipped policy is certified on 95,550 held-out records (see
|
| 88 |
+
[Certificate](#certificate)), but a policy fit on your own decisions is where the
|
| 89 |
+
guarantees get tight. Calibrate from your context/decision/label triples:
|
| 90 |
+
|
| 91 |
+
```python
|
| 92 |
+
from mimir import Mimir
|
| 93 |
+
from mimir.core.labels import LabelledDecision
|
| 94 |
+
from mimir.runtime.calibrate import calibrate
|
| 95 |
+
|
| 96 |
+
model = Mimir.from_pretrained("Mythologic/MIMIR-1")
|
| 97 |
+
labelled: list[LabelledDecision] = [...] # your context/decision/label triples
|
| 98 |
+
policy = calibrate(model, labelled, risk=0.01, confidence=0.95)
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## Documentation
|
| 102 |
+
|
| 103 |
+
Package repository with HTTP, MCP and framework adapters, worked examples and the full
|
| 104 |
+
API reference: [Mythologic/mimir](https://github.com/Mythologic/mimir).
|
| 105 |
+
|
| 106 |
+
---
|
| 107 |
+
|
| 108 |
+
**This repo holds all three load paths.** The release root is the `mimirai` contract
|
| 109 |
+
(ONNX graphs plus certified policy); the same weights ship as plain `transformers` under
|
| 110 |
+
a subfolder, and only what you load is downloaded:
|
| 111 |
+
|
| 112 |
+
| Path | Format | Best at |
|
| 113 |
+
|---|---|---|
|
| 114 |
+
| **`Mythologic/MIMIR-1`** (this repo root) | ONNX graphs + certified policy via `mimirai` | routing, gating, verification |
|
| 115 |
+
| **`Mythologic/MIMIR-1`, `subfolder="transformers"`** | same weights for plain `transformers` | research, custom runtimes |
|
| 116 |
+
|
| 117 |
+
## Quickstart: Package Mode (Recommended)
|
| 118 |
+
|
| 119 |
+
`mimirai` is the recommended way to use MIMIR in production. It handles chunking, typed
|
| 120 |
+
readouts, evidence, the distance gate and the certificate in one call:
|
| 121 |
+
|
| 122 |
+
```python
|
| 123 |
+
from mimir import Mimir
|
| 124 |
+
|
| 125 |
+
model = Mimir.from_pretrained("Mythologic/MIMIR-1")
|
| 126 |
+
|
| 127 |
+
result = model.choose(
|
| 128 |
+
"My card was charged twice for the same order.",
|
| 129 |
+
"Which team should handle this?",
|
| 130 |
+
options={"billing": "Billing: payments, refunds", "security": "Security: account access"},
|
| 131 |
+
)
|
| 132 |
+
print(result.status, result.answer) # DECIDED billing
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
Every result carries the evidence spans behind the decision and the gate verdict, and
|
| 136 |
+
where the certificate applies, whether the call should act or be escalated.
|
| 137 |
+
|
| 138 |
+
### Why MIMIR: the evidence
|
| 139 |
+
|
| 140 |
+
Head-to-head against Laya (`convaiinnovations/laya`) and GLiNER2.5-Decide
|
| 141 |
+
(`fastino/GLiNER2.5-Decide`), each run by us on identical records with paired bootstrap
|
| 142 |
+
95% intervals. Exact-match accuracy at full coverage:
|
| 143 |
+
|
| 144 |
+
| Task | n | MIMIR | Laya | GLiNER | MIMIR − Laya |
|
| 145 |
+
|---|---|---|---|---|---|
|
| 146 |
+
| Banking77 | 3,076 | **0.883** | 0.335 | 0.706 | +0.547 [+0.530, +0.564] |
|
| 147 |
+
| MASSIVE en | 2,974 | **0.866** | 0.443 | 0.643 | +0.423 [+0.403, +0.443] |
|
| 148 |
+
| typed-decisions | 2,000 | **0.725** | 0.361 | 0.487 | +0.363 [+0.332, +0.394] |
|
| 149 |
+
| prompt-injections | 116 | **0.957** | 0.681 | 0.638 | +0.276 [+0.190, +0.362] |
|
| 150 |
+
| XNLI en | 4,995 | **0.828** | 0.676 | 0.398 | +0.152 [+0.137, +0.167] |
|
| 151 |
+
| BoolQ | 3,270 | **0.840** | 0.777 | 0.727 | +0.064 [+0.048, +0.080] |
|
| 152 |
+
| AG News | 7,600 | 0.921 | 0.926 | 0.735 | −0.005 [−0.011, +0.000] |
|
| 153 |
+
| SST-5 | 2,210 | 0.362 | 0.360 | 0.446 | +0.001 [−0.029, +0.033] |
|
| 154 |
+
| fast-decisions | 2,900 | 0.432 | 0.527 | 0.620 | −0.050 [−0.071, −0.030] |
|
| 155 |
+
| DAIR Emotion | 2,000 | 0.080 | 0.589 | 0.562 | −0.508 [−0.530, −0.485] |
|
| 156 |
+
|
| 157 |
+
MIMIR leads decisively on six tasks and ties Laya on AG News and SST-5; GLiNER leads on
|
| 158 |
+
its own fast-decisions showcase. DAIR Emotion is abstention, not error — the model answers
|
| 159 |
+
"none of the listed options" on 1,792 of 2,000 records (mean abstain mass 0.656); forced
|
| 160 |
+
to pick among the six emotions it scores 0.595, against Laya's 0.589.
|
| 161 |
+
|
| 162 |
+
### Production: server and MCP
|
| 163 |
+
|
| 164 |
+
```bash
|
| 165 |
+
mimir serve # HTTP, configured decision endpoints
|
| 166 |
+
mimir mcp # MCP server: configured decision tools by default
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
Both serve the certified fp32 graph with the shipped policy, so the certificate below
|
| 170 |
+
applies to what they return. Framework adapters and worked examples are in the package
|
| 171 |
+
repository.
|
| 172 |
+
|
| 173 |
+
## Single-Model Mode (transformers)
|
| 174 |
+
|
| 175 |
+
If you need the raw weights for a dedicated pipeline, with no `mimirai` install:
|
| 176 |
+
|
| 177 |
+
```python
|
| 178 |
+
from transformers import AutoModel, AutoTokenizer
|
| 179 |
+
|
| 180 |
+
model = AutoModel.from_pretrained(
|
| 181 |
+
"Mythologic/MIMIR-1", subfolder="transformers", trust_remote_code=True
|
| 182 |
+
)
|
| 183 |
+
tokenizer = AutoTokenizer.from_pretrained("Mythologic/MIMIR-1", subfolder="transformers")
|
| 184 |
+
outputs = model(chunk_ids, chunk_mask, ...) # the 21 graph inputs, in order
|
| 185 |
+
outputs.utilities # [4 depths, records, candidates]: every depth's readouts
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
This path is load plus forward on pre-encoded batches only: text handling, calibration,
|
| 189 |
+
the server and MCP stay in `mimirai`. The staged modelling code holds the
|
| 190 |
+
inference-only head forward — no loss, no training machinery — the same computation the
|
| 191 |
+
shipped `model.onnx` already carries.
|
| 192 |
+
|
| 193 |
+
## Architecture
|
| 194 |
+
|
| 195 |
+
- **Backbone:** ModernBERT-Large encoder plus a decision head trained from scratch:
|
| 196 |
+
question-conditioned state memory, a candidate set processor, and a shared reasoning
|
| 197 |
+
cell applied once per iteration. 419M total.
|
| 198 |
+
- **Typed readouts:** choice, multi-choice, yes/no, verification, ranking, rating,
|
| 199 |
+
estimation. The answer space is defined at request time, so new schemas need no
|
| 200 |
+
retraining.
|
| 201 |
+
- **Budget:** 512-token chunks capped at 256 question tokens; tested to 150 options,
|
| 202 |
+
49 levels and 26,406 context tokens. Larger inputs are refused.
|
| 203 |
+
- **Refusal built in:** an out-of-distribution distance gate, conformal prediction sets,
|
| 204 |
+
selective thresholds with finite-sample certificates, and an evidence mass over the
|
| 205 |
+
context behind every decision.
|
| 206 |
+
|
| 207 |
+
## Training
|
| 208 |
+
|
| 209 |
+
Training data and procedure are private.
|
| 210 |
+
|
| 211 |
+
## Benchmarks
|
| 212 |
+
|
| 213 |
+
### Speed
|
| 214 |
+
|
| 215 |
+
About **1.7 decisions per second on an M4 CPU**, flat from 1 to 32 concurrent clients —
|
| 216 |
+
the batching absorbs concurrency rather than queueing it. GPU throughput is not measured
|
| 217 |
+
in this release.
|
| 218 |
+
|
| 219 |
+
### Certificate
|
| 220 |
+
|
| 221 |
+
The fp32 policy ships selective thresholds proven on 95,550 held-out records at four risk
|
| 222 |
+
levels (origin `custom` in `policy/fp32.json`):
|
| 223 |
+
|
| 224 |
+
| Type | 1% risk: taken | Errors |
|
| 225 |
+
|---|---|---|
|
| 226 |
+
| binary | 6,781 of 19,319 (35.1%) | 47 (0.69%) |
|
| 227 |
+
| categorical | 19,947 of 54,728 (36.4%) | 166 (0.83%) |
|
| 228 |
+
| ranking | 1,441 of 3,863 (37.3%) | 5 (0.35%) |
|
| 229 |
+
| ordinal, multilabel | defer every record | — |
|
| 230 |
+
|
| 231 |
+
Read the table as a contract: at 1% risk the model acts on about a third of binary,
|
| 232 |
+
categorical and ranking calls and its error rate on the acted calls stays under the risk.
|
| 233 |
+
Thresholds were fit on the PyTorch model's outputs and transferred to the graph, whose
|
| 234 |
+
outputs match the model on every decision over 312 verification records (max relative
|
| 235 |
+
readout gap 6.5e-5, zero decision differences). The release also ships a 200-record
|
| 236 |
+
equivalence set, so any CPU hardware replays the graph and must reproduce every shipped
|
| 237 |
+
decision. The certified configuration is CPU, ONNX Runtime 1.30.0. The fp16 graph ships
|
| 238 |
+
without a policy; certify it the same way.
|
| 239 |
+
|
| 240 |
+
## Honest Limits
|
| 241 |
+
|
| 242 |
+
- **English only.** Non-English input is out of scope and unmeasured.
|
| 243 |
+
- **Ordinal and multilabel always defer in this release.** Their first testable thresholds
|
| 244 |
+
fail on held-out data, so shipping them would be shipping an unproven promise.
|
| 245 |
+
- **Tested limits: 150 options, 49 levels, 26,406 context tokens.** Larger inputs are
|
| 246 |
+
refused, not truncated silently.
|
| 247 |
+
- **No CUDA certificate.** GPU users run the equivalence set or calibrate their own
|
| 248 |
+
policy; there is no GPU latency figure in this release.
|
| 249 |
+
- **Abstention is load-bearing.** On DAIR Emotion the model refuses 1,792 of 2,000
|
| 250 |
+
records. If your pipeline treats every call as an answer, those refusals become someone
|
| 251 |
+
else's silent default — handle `ABSTAINED` and `DEFERRED` explicitly.
|
| 252 |
+
|
| 253 |
+
## Files
|
| 254 |
+
|
| 255 |
+
| file | description |
|
| 256 |
+
|---|---|
|
| 257 |
+
| `onnx/model.onnx` (+ `_data`) | the public fp32 graph, CPU-certified |
|
| 258 |
+
| `onnx/model_fp16.onnx` (+ `_data`) | the fp16 graph, uncertified |
|
| 259 |
+
| `transformers/model.safetensors` | the same weights for plain `transformers` |
|
| 260 |
+
| `transformers/config.json` | encoder and head shapes, `auto_map`, architectures |
|
| 261 |
+
| `transformers/modeling_mimir.py`, `transformers/configuration_mimir.py` | the architecture, `transformers` and `torch` only |
|
| 262 |
+
| `tokenizer.json` | the 50,368-entry vocabulary |
|
| 263 |
+
| `config.json` | variants, limits, layout and graph contract for `mimirai` |
|
| 264 |
+
| `policy/fp32.json` (+ `.npz`) | the certified selective thresholds |
|
| 265 |
+
| `equivalence/` | 200 records with inputs, so any CPU replays the graph |
|
| 266 |
+
| `manifest.json` | SHA-256 of every file above |
|
| 267 |
+
|
| 268 |
+
No optimiser state, no scheduler state, no RNG. Training cannot be resumed from these files.
|
| 269 |
+
|
| 270 |
+
## Links
|
| 271 |
+
|
| 272 |
+
- Package: `mimirai` on PyPI (`https://pypi.org/project/mimirai/`), `from mimir import Mimir`
|
| 273 |
+
- Code: [Mythologic/mimir](https://github.com/Mythologic/mimir) on GitHub
|
| 274 |
+
|
| 275 |
+
## Licence
|
| 276 |
+
|
| 277 |
+
Mythologic Community License (see `LICENSE`): free for research, personal use and
|
| 278 |
+
organisations under $1M annual revenue; commercial use above that needs a commercial
|
| 279 |
+
licence. Contact Mythologic for production, on-premises and indemnity terms.
|
config.json
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format_version": 1,
|
| 3 |
+
"variants": {
|
| 4 |
+
"fp32": {
|
| 5 |
+
"graph": "onnx/model.onnx",
|
| 6 |
+
"policy": "policy/fp32",
|
| 7 |
+
"devices": [
|
| 8 |
+
"cpu"
|
| 9 |
+
]
|
| 10 |
+
},
|
| 11 |
+
"fp16": {
|
| 12 |
+
"graph": "onnx/model_fp16.onnx",
|
| 13 |
+
"policy": "policy/fp16",
|
| 14 |
+
"devices": [
|
| 15 |
+
"cuda"
|
| 16 |
+
]
|
| 17 |
+
}
|
| 18 |
+
},
|
| 19 |
+
"tokenizer": "tokenizer.json",
|
| 20 |
+
"decision_types": [
|
| 21 |
+
"binary",
|
| 22 |
+
"categorical",
|
| 23 |
+
"multilabel",
|
| 24 |
+
"ranking",
|
| 25 |
+
"ordinal",
|
| 26 |
+
"continuous"
|
| 27 |
+
],
|
| 28 |
+
"risk_levels": [
|
| 29 |
+
0.005,
|
| 30 |
+
0.01,
|
| 31 |
+
0.02,
|
| 32 |
+
0.05
|
| 33 |
+
],
|
| 34 |
+
"default_alpha": 0.1,
|
| 35 |
+
"limits": {
|
| 36 |
+
"options": 150,
|
| 37 |
+
"levels": 49,
|
| 38 |
+
"context_tokens": 26406
|
| 39 |
+
},
|
| 40 |
+
"layout": {
|
| 41 |
+
"chunk_tokens": 512,
|
| 42 |
+
"question_cap": 256,
|
| 43 |
+
"crossing_tokens": 4096,
|
| 44 |
+
"special_tokens": {
|
| 45 |
+
"cls": 50281,
|
| 46 |
+
"sep": 50282,
|
| 47 |
+
"pad": 50283,
|
| 48 |
+
"mask": 50284,
|
| 49 |
+
"newline": 187
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
"graph": {
|
| 53 |
+
"opset": {
|
| 54 |
+
"ai.onnx": 20
|
| 55 |
+
},
|
| 56 |
+
"operators": [
|
| 57 |
+
"ai.onnx::Abs",
|
| 58 |
+
"ai.onnx::Add",
|
| 59 |
+
"ai.onnx::And",
|
| 60 |
+
"ai.onnx::Cast",
|
| 61 |
+
"ai.onnx::Clip",
|
| 62 |
+
"ai.onnx::Concat",
|
| 63 |
+
"ai.onnx::ConstantOfShape",
|
| 64 |
+
"ai.onnx::Cos",
|
| 65 |
+
"ai.onnx::CumSum",
|
| 66 |
+
"ai.onnx::Div",
|
| 67 |
+
"ai.onnx::Einsum",
|
| 68 |
+
"ai.onnx::Equal",
|
| 69 |
+
"ai.onnx::Expand",
|
| 70 |
+
"ai.onnx::Floor",
|
| 71 |
+
"ai.onnx::Gather",
|
| 72 |
+
"ai.onnx::GatherND",
|
| 73 |
+
"ai.onnx::Gelu",
|
| 74 |
+
"ai.onnx::Gemm",
|
| 75 |
+
"ai.onnx::Greater",
|
| 76 |
+
"ai.onnx::GreaterOrEqual",
|
| 77 |
+
"ai.onnx::IsInf",
|
| 78 |
+
"ai.onnx::IsNaN",
|
| 79 |
+
"ai.onnx::LayerNormalization",
|
| 80 |
+
"ai.onnx::Less",
|
| 81 |
+
"ai.onnx::LessOrEqual",
|
| 82 |
+
"ai.onnx::Log",
|
| 83 |
+
"ai.onnx::MatMul",
|
| 84 |
+
"ai.onnx::Max",
|
| 85 |
+
"ai.onnx::Min",
|
| 86 |
+
"ai.onnx::Mod",
|
| 87 |
+
"ai.onnx::Mul",
|
| 88 |
+
"ai.onnx::Neg",
|
| 89 |
+
"ai.onnx::Not",
|
| 90 |
+
"ai.onnx::Pad",
|
| 91 |
+
"ai.onnx::Pow",
|
| 92 |
+
"ai.onnx::Range",
|
| 93 |
+
"ai.onnx::Reciprocal",
|
| 94 |
+
"ai.onnx::ReduceMax",
|
| 95 |
+
"ai.onnx::ReduceMean",
|
| 96 |
+
"ai.onnx::ReduceSum",
|
| 97 |
+
"ai.onnx::Reshape",
|
| 98 |
+
"ai.onnx::ScatterND",
|
| 99 |
+
"ai.onnx::Shape",
|
| 100 |
+
"ai.onnx::Sigmoid",
|
| 101 |
+
"ai.onnx::Sign",
|
| 102 |
+
"ai.onnx::Sin",
|
| 103 |
+
"ai.onnx::Slice",
|
| 104 |
+
"ai.onnx::Softmax",
|
| 105 |
+
"ai.onnx::Softplus",
|
| 106 |
+
"ai.onnx::Split",
|
| 107 |
+
"ai.onnx::Sqrt",
|
| 108 |
+
"ai.onnx::Squeeze",
|
| 109 |
+
"ai.onnx::Sub",
|
| 110 |
+
"ai.onnx::Transpose",
|
| 111 |
+
"ai.onnx::Unsqueeze",
|
| 112 |
+
"ai.onnx::Where"
|
| 113 |
+
],
|
| 114 |
+
"inputs": [
|
| 115 |
+
{
|
| 116 |
+
"name": "chunk_ids",
|
| 117 |
+
"dtype": "int64",
|
| 118 |
+
"rank": 2
|
| 119 |
+
},
|
| 120 |
+
{
|
| 121 |
+
"name": "chunk_mask",
|
| 122 |
+
"dtype": "bool",
|
| 123 |
+
"rank": 2
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"name": "chunk_record",
|
| 127 |
+
"dtype": "int64",
|
| 128 |
+
"rank": 1
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"name": "question_length",
|
| 132 |
+
"dtype": "int64",
|
| 133 |
+
"rank": 1
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"name": "key_chunk",
|
| 137 |
+
"dtype": "int64",
|
| 138 |
+
"rank": 2
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"name": "key_position",
|
| 142 |
+
"dtype": "int64",
|
| 143 |
+
"rank": 2
|
| 144 |
+
},
|
| 145 |
+
{
|
| 146 |
+
"name": "key_mask",
|
| 147 |
+
"dtype": "bool",
|
| 148 |
+
"rank": 2
|
| 149 |
+
},
|
| 150 |
+
{
|
| 151 |
+
"name": "candidate_ids",
|
| 152 |
+
"dtype": "int64",
|
| 153 |
+
"rank": 2
|
| 154 |
+
},
|
| 155 |
+
{
|
| 156 |
+
"name": "candidate_mask",
|
| 157 |
+
"dtype": "bool",
|
| 158 |
+
"rank": 2
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"name": "candidate_text_mask",
|
| 162 |
+
"dtype": "bool",
|
| 163 |
+
"rank": 2
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
"name": "candidate_index",
|
| 167 |
+
"dtype": "int64",
|
| 168 |
+
"rank": 2
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"name": "candidate_present",
|
| 172 |
+
"dtype": "bool",
|
| 173 |
+
"rank": 2
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"name": "decision_type",
|
| 177 |
+
"dtype": "int64",
|
| 178 |
+
"rank": 1
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"name": "typed_kind",
|
| 182 |
+
"dtype": "int64",
|
| 183 |
+
"rank": 1
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"name": "typed_number",
|
| 187 |
+
"dtype": "float32",
|
| 188 |
+
"rank": 1
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"name": "typed_year",
|
| 192 |
+
"dtype": "int64",
|
| 193 |
+
"rank": 1
|
| 194 |
+
},
|
| 195 |
+
{
|
| 196 |
+
"name": "typed_month",
|
| 197 |
+
"dtype": "int64",
|
| 198 |
+
"rank": 1
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"name": "typed_day",
|
| 202 |
+
"dtype": "int64",
|
| 203 |
+
"rank": 1
|
| 204 |
+
},
|
| 205 |
+
{
|
| 206 |
+
"name": "typed_second",
|
| 207 |
+
"dtype": "int64",
|
| 208 |
+
"rank": 1
|
| 209 |
+
},
|
| 210 |
+
{
|
| 211 |
+
"name": "typed_chunk",
|
| 212 |
+
"dtype": "int64",
|
| 213 |
+
"rank": 1
|
| 214 |
+
},
|
| 215 |
+
{
|
| 216 |
+
"name": "typed_position",
|
| 217 |
+
"dtype": "int64",
|
| 218 |
+
"rank": 1
|
| 219 |
+
}
|
| 220 |
+
],
|
| 221 |
+
"outputs": [
|
| 222 |
+
{
|
| 223 |
+
"name": "utilities",
|
| 224 |
+
"dtype": "float32",
|
| 225 |
+
"rank": 2
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"name": "thresholds",
|
| 229 |
+
"dtype": "float32",
|
| 230 |
+
"rank": 2
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"name": "abstain",
|
| 234 |
+
"dtype": "float32",
|
| 235 |
+
"rank": 1
|
| 236 |
+
},
|
| 237 |
+
{
|
| 238 |
+
"name": "ordinal_score",
|
| 239 |
+
"dtype": "float32",
|
| 240 |
+
"rank": 1
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"name": "histogram_logits",
|
| 244 |
+
"dtype": "float32",
|
| 245 |
+
"rank": 2
|
| 246 |
+
},
|
| 247 |
+
{
|
| 248 |
+
"name": "evidence",
|
| 249 |
+
"dtype": "float32",
|
| 250 |
+
"rank": 2
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"name": "workspace",
|
| 254 |
+
"dtype": "float32",
|
| 255 |
+
"rank": 2
|
| 256 |
+
}
|
| 257 |
+
]
|
| 258 |
+
}
|
| 259 |
+
}
|
equivalence/expected.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8317cc5b1e8c1e7168b991fdd030ea7e1eb45fbbbbd7922a07d302876bd67118
|
| 3 |
+
size 108294
|
equivalence/inputs.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:53777dff2852935d1009f556834f0607f1a25d9775c215632a13bd544300b29c
|
| 3 |
+
size 2995770
|
equivalence/records.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
manifest.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format_version": 1,
|
| 3 |
+
"files": {
|
| 4 |
+
"README.md": "750154de4a18eb8fe5d6ed9477df66a54370e8bf9bb3f3ff2897018c856e1045",
|
| 5 |
+
"config.json": "10cbc7c171d2ce17fcf214f8ba31e08a8a8f68ea422e7bb92930c719b30c1ce4",
|
| 6 |
+
"equivalence/expected.npz": "8317cc5b1e8c1e7168b991fdd030ea7e1eb45fbbbbd7922a07d302876bd67118",
|
| 7 |
+
"equivalence/inputs.npz": "53777dff2852935d1009f556834f0607f1a25d9775c215632a13bd544300b29c",
|
| 8 |
+
"equivalence/records.jsonl": "500efc9931ac074efb362ef2a5e0af1f66e8971e0f09d4ead1e67be967ef8456",
|
| 9 |
+
"onnx/model.onnx": "5e2aa30163e7e06294d9f7c472eed0462e26d0a9f52b363c2676a4fe71c208f7",
|
| 10 |
+
"onnx/model.onnx_data": "8a970e22e7d5bafff3ba9bbffd46ee556aef6db93c6aba3dcd1be27ea6852e09",
|
| 11 |
+
"onnx/model_fp16.onnx": "e984443e0022b5268b6affd623a2314b1ca27f7e8f6227862b6a591aa9a830c0",
|
| 12 |
+
"onnx/model_fp16.onnx_data": "53a59c076a385d50f64db222dc56f7469f0059a300cad19af7126119626cb7ab",
|
| 13 |
+
"policy/build-fp32.stats.json": "e679a9a195a758ab8ed848a401c5769c95a43df1103cfd8b4c69e926be35982a",
|
| 14 |
+
"policy/fp32.json": "38fc95b115560dd86fbfc156edac44c81808585724f409de1a01cd962abc73ff",
|
| 15 |
+
"policy/fp32.npz": "5e349654764d7a729a82ecdea5cfe2ba786842db99d71f2c6b37fdae40cd33f6",
|
| 16 |
+
"tokenizer.json": "bc2788d5ddc9e2ced5d7a6aa695b30bb0c56751e60fd65ac595b16b9f0784812",
|
| 17 |
+
"transformers/config.json": "9bfb0c09a755d523c3d77f204f680b35acf8e14387017c7a683fc92398e6d4aa",
|
| 18 |
+
"transformers/configuration_mimir.py": "312e94e5c7c3a342879a3ef3dc3a6c4293bb9783b20f37546291626ecf626637",
|
| 19 |
+
"transformers/model.safetensors": "0f8653c106d0f5b29498b81c73e7977262a333fcce5c6169463167328b801f55",
|
| 20 |
+
"transformers/modeling_mimir.py": "7b802d7a1354d970a1305560a1d17a8a32936ccef2d2e6e9cec124163922b005",
|
| 21 |
+
"transformers/tokenizer.json": "bc2788d5ddc9e2ced5d7a6aa695b30bb0c56751e60fd65ac595b16b9f0784812"
|
| 22 |
+
},
|
| 23 |
+
"loadable_by": {
|
| 24 |
+
"mimirai": ">=1,<2"
|
| 25 |
+
}
|
| 26 |
+
}
|
onnx/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5e2aa30163e7e06294d9f7c472eed0462e26d0a9f52b363c2676a4fe71c208f7
|
| 3 |
+
size 486232
|
onnx/model.onnx_data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a970e22e7d5bafff3ba9bbffd46ee556aef6db93c6aba3dcd1be27ea6852e09
|
| 3 |
+
size 1675493376
|
onnx/model_fp16.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e984443e0022b5268b6affd623a2314b1ca27f7e8f6227862b6a591aa9a830c0
|
| 3 |
+
size 569033
|
onnx/model_fp16.onnx_data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:53a59c076a385d50f64db222dc56f7469f0059a300cad19af7126119626cb7ab
|
| 3 |
+
size 842334208
|
policy/build-fp32.stats.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"tau": 1.0,
|
| 3 |
+
"probe": {
|
| 4 |
+
"provider": "CPUExecutionProvider",
|
| 5 |
+
"options_sha256": "f9c064421831f161abf37882ab184b908a6b103d7458ce1db9c3f2a00a0dcb1a",
|
| 6 |
+
"hardware": "arm64 Apple M4",
|
| 7 |
+
"onnxruntime": "1.30.0"
|
| 8 |
+
},
|
| 9 |
+
"taken": {
|
| 10 |
+
"0.005": {
|
| 11 |
+
"binary": {
|
| 12 |
+
"taken": 2909,
|
| 13 |
+
"errors": 5
|
| 14 |
+
},
|
| 15 |
+
"categorical": {
|
| 16 |
+
"taken": 15171,
|
| 17 |
+
"errors": 55
|
| 18 |
+
},
|
| 19 |
+
"multilabel": {
|
| 20 |
+
"taken": 0,
|
| 21 |
+
"errors": 0
|
| 22 |
+
},
|
| 23 |
+
"ordinal": {
|
| 24 |
+
"taken": 0,
|
| 25 |
+
"errors": 0
|
| 26 |
+
},
|
| 27 |
+
"ranking": {
|
| 28 |
+
"taken": 0,
|
| 29 |
+
"errors": 0
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
"0.01": {
|
| 33 |
+
"binary": {
|
| 34 |
+
"taken": 6781,
|
| 35 |
+
"errors": 47
|
| 36 |
+
},
|
| 37 |
+
"categorical": {
|
| 38 |
+
"taken": 19947,
|
| 39 |
+
"errors": 166
|
| 40 |
+
},
|
| 41 |
+
"multilabel": {
|
| 42 |
+
"taken": 0,
|
| 43 |
+
"errors": 0
|
| 44 |
+
},
|
| 45 |
+
"ordinal": {
|
| 46 |
+
"taken": 0,
|
| 47 |
+
"errors": 0
|
| 48 |
+
},
|
| 49 |
+
"ranking": {
|
| 50 |
+
"taken": 1441,
|
| 51 |
+
"errors": 5
|
| 52 |
+
}
|
| 53 |
+
},
|
| 54 |
+
"0.02": {
|
| 55 |
+
"binary": {
|
| 56 |
+
"taken": 8903,
|
| 57 |
+
"errors": 145
|
| 58 |
+
},
|
| 59 |
+
"categorical": {
|
| 60 |
+
"taken": 25917,
|
| 61 |
+
"errors": 457
|
| 62 |
+
},
|
| 63 |
+
"multilabel": {
|
| 64 |
+
"taken": 0,
|
| 65 |
+
"errors": 0
|
| 66 |
+
},
|
| 67 |
+
"ordinal": {
|
| 68 |
+
"taken": 0,
|
| 69 |
+
"errors": 0
|
| 70 |
+
},
|
| 71 |
+
"ranking": {
|
| 72 |
+
"taken": 2339,
|
| 73 |
+
"errors": 30
|
| 74 |
+
}
|
| 75 |
+
},
|
| 76 |
+
"0.05": {
|
| 77 |
+
"binary": {
|
| 78 |
+
"taken": 11173,
|
| 79 |
+
"errors": 497
|
| 80 |
+
},
|
| 81 |
+
"categorical": {
|
| 82 |
+
"taken": 35761,
|
| 83 |
+
"errors": 1675
|
| 84 |
+
},
|
| 85 |
+
"multilabel": {
|
| 86 |
+
"taken": 0,
|
| 87 |
+
"errors": 0
|
| 88 |
+
},
|
| 89 |
+
"ordinal": {
|
| 90 |
+
"taken": 192,
|
| 91 |
+
"errors": 2
|
| 92 |
+
},
|
| 93 |
+
"ranking": {
|
| 94 |
+
"taken": 3422,
|
| 95 |
+
"errors": 52
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
}
|
policy/fp32.json
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
| 8 |
+
"weights_sha256": "8a970e22e7d5bafff3ba9bbffd46ee556aef6db93c6aba3dcd1be27ea6852e09",
|
| 9 |
+
"opset": 20,
|
| 10 |
+
"onnxruntime": "1.30.0",
|
| 11 |
+
"configurations": [
|
| 12 |
+
{
|
| 13 |
+
"provider": "CPUExecutionProvider",
|
| 14 |
+
"options_sha256": "f9c064421831f161abf37882ab184b908a6b103d7458ce1db9c3f2a00a0dcb1a",
|
| 15 |
+
"hardware": "arm64 Apple M4"
|
| 16 |
+
}
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
"confidence": 0.95,
|
| 20 |
+
"gate_level": 0.01,
|
| 21 |
+
"label_taken": 0.5,
|
| 22 |
+
"decision_types": {
|
| 23 |
+
"binary": {
|
| 24 |
+
"scaling": [
|
| 25 |
+
{
|
| 26 |
+
"bucket": 1,
|
| 27 |
+
"parameters": [
|
| 28 |
+
1.0409415120415813
|
| 29 |
+
]
|
| 30 |
+
}
|
| 31 |
+
],
|
| 32 |
+
"conformal": "bucket",
|
| 33 |
+
"thresholds": {
|
| 34 |
+
"0.005": {
|
| 35 |
+
"threshold": 0.9949074874951082,
|
| 36 |
+
"records": 19319,
|
| 37 |
+
"taken": 2909,
|
| 38 |
+
"errors": 5,
|
| 39 |
+
"p_value": 0.0037583916634767204,
|
| 40 |
+
"coverage": 0.1505771520265024,
|
| 41 |
+
"coverage_interval": [
|
| 42 |
+
0.14560354505467576,
|
| 43 |
+
0.1556896923414774
|
| 44 |
+
]
|
| 45 |
+
},
|
| 46 |
+
"0.01": {
|
| 47 |
+
"threshold": 0.9719800962254757,
|
| 48 |
+
"records": 19319,
|
| 49 |
+
"taken": 6781,
|
| 50 |
+
"errors": 47,
|
| 51 |
+
"p_value": 0.004679953940435846,
|
| 52 |
+
"coverage": 0.35100160463792124,
|
| 53 |
+
"coverage_interval": [
|
| 54 |
+
0.3443015654654972,
|
| 55 |
+
0.3577608867743113
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"0.02": {
|
| 59 |
+
"threshold": 0.9207146941059774,
|
| 60 |
+
"records": 19319,
|
| 61 |
+
"taken": 8903,
|
| 62 |
+
"errors": 145,
|
| 63 |
+
"p_value": 0.005668096179287009,
|
| 64 |
+
"coverage": 0.46084165847093533,
|
| 65 |
+
"coverage_interval": [
|
| 66 |
+
0.45382119831269946,
|
| 67 |
+
0.4678776883016534
|
| 68 |
+
]
|
| 69 |
+
},
|
| 70 |
+
"0.05": {
|
| 71 |
+
"threshold": 0.786841460149322,
|
| 72 |
+
"records": 19319,
|
| 73 |
+
"taken": 11173,
|
| 74 |
+
"errors": 497,
|
| 75 |
+
"p_value": 0.0035102019063473944,
|
| 76 |
+
"coverage": 0.5783425643149231,
|
| 77 |
+
"coverage_interval": [
|
| 78 |
+
0.5713641538832366,
|
| 79 |
+
0.5852898251110485
|
| 80 |
+
]
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
},
|
| 84 |
+
"categorical": {
|
| 85 |
+
"scaling": [
|
| 86 |
+
{
|
| 87 |
+
"bucket": 2,
|
| 88 |
+
"parameters": [
|
| 89 |
+
1.0564966261027586
|
| 90 |
+
]
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"bucket": 4,
|
| 94 |
+
"parameters": [
|
| 95 |
+
1.0143682237623908
|
| 96 |
+
]
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"bucket": 6,
|
| 100 |
+
"parameters": [
|
| 101 |
+
1.0555197820719635
|
| 102 |
+
]
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"bucket": 8,
|
| 106 |
+
"parameters": [
|
| 107 |
+
0.9840583191942824
|
| 108 |
+
]
|
| 109 |
+
}
|
| 110 |
+
],
|
| 111 |
+
"conformal": "bucket",
|
| 112 |
+
"thresholds": {
|
| 113 |
+
"0.005": {
|
| 114 |
+
"threshold": 0.9892163123582928,
|
| 115 |
+
"records": 54728,
|
| 116 |
+
"taken": 15171,
|
| 117 |
+
"errors": 55,
|
| 118 |
+
"p_value": 0.007323585857601648,
|
| 119 |
+
"coverage": 0.2772072796374799,
|
| 120 |
+
"coverage_interval": [
|
| 121 |
+
0.27347283241497794,
|
| 122 |
+
0.28097300112512663
|
| 123 |
+
]
|
| 124 |
+
},
|
| 125 |
+
"0.01": {
|
| 126 |
+
"threshold": 0.9733773916365551,
|
| 127 |
+
"records": 54728,
|
| 128 |
+
"taken": 19947,
|
| 129 |
+
"errors": 166,
|
| 130 |
+
"p_value": 0.008129485421490949,
|
| 131 |
+
"coverage": 0.3644752229206256,
|
| 132 |
+
"coverage_interval": [
|
| 133 |
+
0.36045265147938066,
|
| 134 |
+
0.36851681849248474
|
| 135 |
+
]
|
| 136 |
+
},
|
| 137 |
+
"0.02": {
|
| 138 |
+
"threshold": 0.9370174059553127,
|
| 139 |
+
"records": 54728,
|
| 140 |
+
"taken": 25917,
|
| 141 |
+
"errors": 457,
|
| 142 |
+
"p_value": 0.003010774763011832,
|
| 143 |
+
"coverage": 0.4735601520245578,
|
| 144 |
+
"coverage_interval": [
|
| 145 |
+
0.4693789866409686,
|
| 146 |
+
0.47774502887059794
|
| 147 |
+
]
|
| 148 |
+
},
|
| 149 |
+
"0.05": {
|
| 150 |
+
"threshold": 0.8059233276321787,
|
| 151 |
+
"records": 54728,
|
| 152 |
+
"taken": 35761,
|
| 153 |
+
"errors": 1675,
|
| 154 |
+
"p_value": 0.002934331808967096,
|
| 155 |
+
"coverage": 0.6534315158602544,
|
| 156 |
+
"coverage_interval": [
|
| 157 |
+
0.6494339491092762,
|
| 158 |
+
0.6574075448432983
|
| 159 |
+
]
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
},
|
| 163 |
+
"continuous": {
|
| 164 |
+
"scaling": [
|
| 165 |
+
{
|
| 166 |
+
"bucket": 0,
|
| 167 |
+
"parameters": [
|
| 168 |
+
1.0826732554709506
|
| 169 |
+
]
|
| 170 |
+
}
|
| 171 |
+
],
|
| 172 |
+
"conformal": "type",
|
| 173 |
+
"thresholds": {}
|
| 174 |
+
},
|
| 175 |
+
"multilabel": {
|
| 176 |
+
"scaling": [
|
| 177 |
+
{
|
| 178 |
+
"bucket": 5,
|
| 179 |
+
"parameters": [
|
| 180 |
+
0.974903423436956,
|
| 181 |
+
-0.026482633363254213
|
| 182 |
+
]
|
| 183 |
+
}
|
| 184 |
+
],
|
| 185 |
+
"conformal": null,
|
| 186 |
+
"thresholds": {
|
| 187 |
+
"0.005": {
|
| 188 |
+
"threshold": null,
|
| 189 |
+
"records": 2709,
|
| 190 |
+
"taken": 0,
|
| 191 |
+
"errors": 0,
|
| 192 |
+
"p_value": 1.0,
|
| 193 |
+
"coverage": 0.0,
|
| 194 |
+
"coverage_interval": [
|
| 195 |
+
1.0842021724855044e-19,
|
| 196 |
+
0.0014160277624052737
|
| 197 |
+
]
|
| 198 |
+
},
|
| 199 |
+
"0.01": {
|
| 200 |
+
"threshold": null,
|
| 201 |
+
"records": 2709,
|
| 202 |
+
"taken": 0,
|
| 203 |
+
"errors": 0,
|
| 204 |
+
"p_value": 1.0,
|
| 205 |
+
"coverage": 0.0,
|
| 206 |
+
"coverage_interval": [
|
| 207 |
+
1.0842021724855044e-19,
|
| 208 |
+
0.0014160277624052737
|
| 209 |
+
]
|
| 210 |
+
},
|
| 211 |
+
"0.02": {
|
| 212 |
+
"threshold": null,
|
| 213 |
+
"records": 2709,
|
| 214 |
+
"taken": 0,
|
| 215 |
+
"errors": 0,
|
| 216 |
+
"p_value": 1.0,
|
| 217 |
+
"coverage": 0.0,
|
| 218 |
+
"coverage_interval": [
|
| 219 |
+
1.0842021724855044e-19,
|
| 220 |
+
0.0014160277624052737
|
| 221 |
+
]
|
| 222 |
+
},
|
| 223 |
+
"0.05": {
|
| 224 |
+
"threshold": null,
|
| 225 |
+
"records": 2709,
|
| 226 |
+
"taken": 0,
|
| 227 |
+
"errors": 0,
|
| 228 |
+
"p_value": 1.0,
|
| 229 |
+
"coverage": 0.0,
|
| 230 |
+
"coverage_interval": [
|
| 231 |
+
1.0842021724855044e-19,
|
| 232 |
+
0.0014160277624052737
|
| 233 |
+
]
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
},
|
| 237 |
+
"ordinal": {
|
| 238 |
+
"scaling": [
|
| 239 |
+
{
|
| 240 |
+
"bucket": 3,
|
| 241 |
+
"parameters": [
|
| 242 |
+
0.9896384316738945
|
| 243 |
+
]
|
| 244 |
+
}
|
| 245 |
+
],
|
| 246 |
+
"conformal": "type",
|
| 247 |
+
"thresholds": {
|
| 248 |
+
"0.005": {
|
| 249 |
+
"threshold": null,
|
| 250 |
+
"records": 14160,
|
| 251 |
+
"taken": 0,
|
| 252 |
+
"errors": 0,
|
| 253 |
+
"p_value": 1.0,
|
| 254 |
+
"coverage": 0.0,
|
| 255 |
+
"coverage_interval": [
|
| 256 |
+
0.0,
|
| 257 |
+
0.00027121588672554737
|
| 258 |
+
]
|
| 259 |
+
},
|
| 260 |
+
"0.01": {
|
| 261 |
+
"threshold": null,
|
| 262 |
+
"records": 14160,
|
| 263 |
+
"taken": 0,
|
| 264 |
+
"errors": 0,
|
| 265 |
+
"p_value": 1.0,
|
| 266 |
+
"coverage": 0.0,
|
| 267 |
+
"coverage_interval": [
|
| 268 |
+
0.0,
|
| 269 |
+
0.00027121588672554737
|
| 270 |
+
]
|
| 271 |
+
},
|
| 272 |
+
"0.02": {
|
| 273 |
+
"threshold": null,
|
| 274 |
+
"records": 14160,
|
| 275 |
+
"taken": 0,
|
| 276 |
+
"errors": 0,
|
| 277 |
+
"p_value": 1.0,
|
| 278 |
+
"coverage": 0.0,
|
| 279 |
+
"coverage_interval": [
|
| 280 |
+
0.0,
|
| 281 |
+
0.00027121588672554737
|
| 282 |
+
]
|
| 283 |
+
},
|
| 284 |
+
"0.05": {
|
| 285 |
+
"threshold": 0.9958498101888688,
|
| 286 |
+
"records": 14160,
|
| 287 |
+
"taken": 192,
|
| 288 |
+
"errors": 2,
|
| 289 |
+
"p_value": 0.003270433875043758,
|
| 290 |
+
"coverage": 0.013559322033898305,
|
| 291 |
+
"coverage_interval": [
|
| 292 |
+
0.011782052448866454,
|
| 293 |
+
0.015600452498558062
|
| 294 |
+
]
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
},
|
| 298 |
+
"ranking": {
|
| 299 |
+
"scaling": [
|
| 300 |
+
{
|
| 301 |
+
"bucket": 4,
|
| 302 |
+
"parameters": [
|
| 303 |
+
1.0367358457794178
|
| 304 |
+
]
|
| 305 |
+
}
|
| 306 |
+
],
|
| 307 |
+
"conformal": null,
|
| 308 |
+
"thresholds": {
|
| 309 |
+
"0.005": {
|
| 310 |
+
"threshold": null,
|
| 311 |
+
"records": 3863,
|
| 312 |
+
"taken": 0,
|
| 313 |
+
"errors": 0,
|
| 314 |
+
"p_value": 1.0,
|
| 315 |
+
"coverage": 0.0,
|
| 316 |
+
"coverage_interval": [
|
| 317 |
+
0.0,
|
| 318 |
+
0.0009934358213552644
|
| 319 |
+
]
|
| 320 |
+
},
|
| 321 |
+
"0.01": {
|
| 322 |
+
"threshold": 0.8535177039125583,
|
| 323 |
+
"records": 3863,
|
| 324 |
+
"taken": 1441,
|
| 325 |
+
"errors": 5,
|
| 326 |
+
"p_value": 0.004056431842790958,
|
| 327 |
+
"coverage": 0.3730261454827854,
|
| 328 |
+
"coverage_interval": [
|
| 329 |
+
0.3579089811951534,
|
| 330 |
+
0.38839559052132316
|
| 331 |
+
]
|
| 332 |
+
},
|
| 333 |
+
"0.02": {
|
| 334 |
+
"threshold": 0.6790546963219036,
|
| 335 |
+
"records": 3863,
|
| 336 |
+
"taken": 2339,
|
| 337 |
+
"errors": 30,
|
| 338 |
+
"p_value": 0.0055351584233824126,
|
| 339 |
+
"coverage": 0.6054879627232721,
|
| 340 |
+
"coverage_interval": [
|
| 341 |
+
0.5899781267467805,
|
| 342 |
+
0.6207882076579816
|
| 343 |
+
]
|
| 344 |
+
},
|
| 345 |
+
"0.05": {
|
| 346 |
+
"threshold": 0.5,
|
| 347 |
+
"records": 3863,
|
| 348 |
+
"taken": 3422,
|
| 349 |
+
"errors": 52,
|
| 350 |
+
"p_value": 1.3520023405895525e-27,
|
| 351 |
+
"coverage": 0.8858400207092932,
|
| 352 |
+
"coverage_interval": [
|
| 353 |
+
0.8754262306678195,
|
| 354 |
+
0.8954871961549968
|
| 355 |
+
]
|
| 356 |
+
}
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
},
|
| 360 |
+
"origin": "custom"
|
| 361 |
+
}
|
policy/fp32.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5e349654764d7a729a82ecdea5cfe2ba786842db99d71f2c6b37fdae40cd33f6
|
| 3 |
+
size 14291202
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
transformers/config.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"MimirModel"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"auto_map": {
|
| 8 |
+
"AutoConfig": "configuration_mimir.MimirConfig",
|
| 9 |
+
"AutoModel": "modeling_mimir.MimirModel"
|
| 10 |
+
},
|
| 11 |
+
"bos_token_id": 50281,
|
| 12 |
+
"classifier_activation": "gelu",
|
| 13 |
+
"classifier_bias": false,
|
| 14 |
+
"classifier_dropout": 0.0,
|
| 15 |
+
"classifier_pooling": "cls",
|
| 16 |
+
"cls_token_id": 50281,
|
| 17 |
+
"decoder_bias": true,
|
| 18 |
+
"deterministic_flash_attn": false,
|
| 19 |
+
"dtype": "float32",
|
| 20 |
+
"embedding_dropout": 0.0,
|
| 21 |
+
"encoder_layers": 28,
|
| 22 |
+
"encoder_width": 1024,
|
| 23 |
+
"eos_token_id": 50282,
|
| 24 |
+
"feedforward_hidden": 1408,
|
| 25 |
+
"global_attn_every_n_layers": 3,
|
| 26 |
+
"head_size": 64,
|
| 27 |
+
"hidden_activation": "gelu",
|
| 28 |
+
"hidden_size": 1024,
|
| 29 |
+
"histogram_bins": 64,
|
| 30 |
+
"initializer_cutoff_factor": 2.0,
|
| 31 |
+
"initializer_range": 0.02,
|
| 32 |
+
"intermediate_size": 2624,
|
| 33 |
+
"iterations": 4,
|
| 34 |
+
"latents": 32,
|
| 35 |
+
"layer_types": [
|
| 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 |
+
"sliding_attention",
|
| 56 |
+
"sliding_attention",
|
| 57 |
+
"full_attention",
|
| 58 |
+
"sliding_attention",
|
| 59 |
+
"sliding_attention",
|
| 60 |
+
"full_attention",
|
| 61 |
+
"sliding_attention",
|
| 62 |
+
"sliding_attention",
|
| 63 |
+
"full_attention"
|
| 64 |
+
],
|
| 65 |
+
"local_attention": 128,
|
| 66 |
+
"max_position_embeddings": 8192,
|
| 67 |
+
"mlp_bias": false,
|
| 68 |
+
"mlp_dropout": 0.0,
|
| 69 |
+
"model_type": "mimir",
|
| 70 |
+
"norm_bias": false,
|
| 71 |
+
"norm_eps": 1e-05,
|
| 72 |
+
"num_attention_heads": 16,
|
| 73 |
+
"num_hidden_layers": 28,
|
| 74 |
+
"pad_token_id": 50283,
|
| 75 |
+
"question_cap": 256,
|
| 76 |
+
"rope_parameters": {
|
| 77 |
+
"full_attention": {
|
| 78 |
+
"rope_theta": 160000.0,
|
| 79 |
+
"rope_type": "default"
|
| 80 |
+
},
|
| 81 |
+
"sliding_attention": {
|
| 82 |
+
"rope_theta": 10000.0,
|
| 83 |
+
"rope_type": "default"
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
"sep_token_id": 50282,
|
| 87 |
+
"slots": 4,
|
| 88 |
+
"sparse_pred_ignore_index": -100,
|
| 89 |
+
"sparse_prediction": false,
|
| 90 |
+
"tie_word_embeddings": false,
|
| 91 |
+
"trained_layers": 14,
|
| 92 |
+
"transformers_version": "5.17.0",
|
| 93 |
+
"value_bins": 64,
|
| 94 |
+
"vocab_size": 50368,
|
| 95 |
+
"width": 512
|
| 96 |
+
}
|
transformers/configuration_mimir.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The Hub configuration: the pinned encoder's sizes plus the decision head's, in one object."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import Any
|
| 6 |
+
|
| 7 |
+
from transformers import ModernBertConfig
|
| 8 |
+
|
| 9 |
+
DECISION_TYPES: tuple[str, ...] = (
|
| 10 |
+
"binary",
|
| 11 |
+
"categorical",
|
| 12 |
+
"multilabel",
|
| 13 |
+
"ranking",
|
| 14 |
+
"ordinal",
|
| 15 |
+
"continuous",
|
| 16 |
+
)
|
| 17 |
+
"""The decision kinds in the order the head's schema embedding and the graph read them."""
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class MimirConfig(ModernBertConfig):
|
| 21 |
+
"""A ModernBertConfig that also carries the decision head's shapes.
|
| 22 |
+
|
| 23 |
+
It is-a ModernBertConfig so `self.encoder = ModernBertModel(config)` builds the
|
| 24 |
+
stock encoder with no separate encoder config. Every encoder default is pinned to
|
| 25 |
+
answerdotai/ModernBERT-Large-Instruct's values, so a bare `MimirConfig()` builds
|
| 26 |
+
the encoder the checkpoint was trained on. `model_type` is `mimir`, and only the
|
| 27 |
+
`transformers/` subfolder's config carries it: the Hub root's release contract
|
| 28 |
+
forbids extra keys.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
model_type = "mimir"
|
| 32 |
+
|
| 33 |
+
def __init__(
|
| 34 |
+
self,
|
| 35 |
+
encoder_width: int = 1024,
|
| 36 |
+
encoder_layers: int = 28,
|
| 37 |
+
trained_layers: int = 14,
|
| 38 |
+
width: int = 512,
|
| 39 |
+
head_size: int = 64,
|
| 40 |
+
feedforward_hidden: int = 1408,
|
| 41 |
+
latents: int = 32,
|
| 42 |
+
slots: int = 4,
|
| 43 |
+
iterations: int = 4,
|
| 44 |
+
value_bins: int = 64,
|
| 45 |
+
histogram_bins: int = 64,
|
| 46 |
+
question_cap: int = 256,
|
| 47 |
+
**kwargs: Any,
|
| 48 |
+
) -> None:
|
| 49 |
+
kwargs.setdefault("vocab_size", 50368)
|
| 50 |
+
kwargs.setdefault("hidden_size", 1024)
|
| 51 |
+
kwargs.setdefault("intermediate_size", 2624)
|
| 52 |
+
kwargs.setdefault("num_hidden_layers", 28)
|
| 53 |
+
kwargs.setdefault("num_attention_heads", 16)
|
| 54 |
+
kwargs.setdefault("hidden_activation", "gelu")
|
| 55 |
+
kwargs.setdefault("max_position_embeddings", 8192)
|
| 56 |
+
kwargs.setdefault("norm_eps", 1e-5)
|
| 57 |
+
kwargs.setdefault("norm_bias", False)
|
| 58 |
+
kwargs.setdefault("local_attention", 128)
|
| 59 |
+
kwargs.setdefault("global_attn_every_n_layers", 3)
|
| 60 |
+
kwargs.setdefault("global_rope_theta", 160000.0)
|
| 61 |
+
kwargs.setdefault("local_rope_theta", 10000.0)
|
| 62 |
+
kwargs.setdefault("attention_bias", False)
|
| 63 |
+
kwargs.setdefault("attention_dropout", 0.0)
|
| 64 |
+
kwargs.setdefault("embedding_dropout", 0.0)
|
| 65 |
+
kwargs.setdefault("mlp_bias", False)
|
| 66 |
+
kwargs.setdefault("mlp_dropout", 0.0)
|
| 67 |
+
kwargs.setdefault("pad_token_id", 50283)
|
| 68 |
+
kwargs.setdefault("bos_token_id", 50281)
|
| 69 |
+
kwargs.setdefault("eos_token_id", 50282)
|
| 70 |
+
kwargs.setdefault("cls_token_id", 50281)
|
| 71 |
+
kwargs.setdefault("sep_token_id", 50282)
|
| 72 |
+
kwargs.setdefault("tie_word_embeddings", False)
|
| 73 |
+
super().__init__(**kwargs)
|
| 74 |
+
if self.hidden_size != encoder_width:
|
| 75 |
+
message = f"head reads width {encoder_width}, encoder has {self.hidden_size}"
|
| 76 |
+
raise ValueError(message)
|
| 77 |
+
if self.num_hidden_layers != encoder_layers:
|
| 78 |
+
message = f"head expects {encoder_layers} layers, encoder has {self.num_hidden_layers}"
|
| 79 |
+
raise ValueError(message)
|
| 80 |
+
if width % head_size:
|
| 81 |
+
message = f"width {width} is not a multiple of head size {head_size}"
|
| 82 |
+
raise ValueError(message)
|
| 83 |
+
if not 0 < trained_layers <= self.num_hidden_layers:
|
| 84 |
+
message = f"{trained_layers} trained layers of {self.num_hidden_layers}"
|
| 85 |
+
raise ValueError(message)
|
| 86 |
+
for name, value in (
|
| 87 |
+
("latents", latents),
|
| 88 |
+
("slots", slots),
|
| 89 |
+
("iterations", iterations),
|
| 90 |
+
("value_bins", value_bins),
|
| 91 |
+
("histogram_bins", histogram_bins),
|
| 92 |
+
):
|
| 93 |
+
if value < 1:
|
| 94 |
+
message = f"{name} is {value}"
|
| 95 |
+
raise ValueError(message)
|
| 96 |
+
self.encoder_width = encoder_width
|
| 97 |
+
self.encoder_layers = encoder_layers
|
| 98 |
+
self.trained_layers = trained_layers
|
| 99 |
+
self.width = width
|
| 100 |
+
self.head_size = head_size
|
| 101 |
+
self.feedforward_hidden = feedforward_hidden
|
| 102 |
+
self.latents = latents
|
| 103 |
+
self.slots = slots
|
| 104 |
+
self.iterations = iterations
|
| 105 |
+
self.value_bins = value_bins
|
| 106 |
+
self.histogram_bins = histogram_bins
|
| 107 |
+
self.question_cap = question_cap
|
| 108 |
+
# The Hub forward calls encoder layers directly with prepared dense masks,
|
| 109 |
+
# which is the SDPA path the model trained on. Read at call time by the
|
| 110 |
+
# attention modules, so this also survives a from_pretrained round trip.
|
| 111 |
+
self._attn_implementation = "sdpa"
|
| 112 |
+
|
| 113 |
+
@property
|
| 114 |
+
def heads(self) -> int:
|
| 115 |
+
return self.width // self.head_size
|
| 116 |
+
|
| 117 |
+
@property
|
| 118 |
+
def injection_layer(self) -> int:
|
| 119 |
+
return self.num_hidden_layers - self.trained_layers
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
__all__ = ["DECISION_TYPES", "MimirConfig"]
|
transformers/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f8653c106d0f5b29498b81c73e7977262a333fcce5c6169463167328b801f55
|
| 3 |
+
size 1675436184
|
transformers/modeling_mimir.py
ADDED
|
@@ -0,0 +1,838 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""MIMIR-1 as a transformers model: load with `AutoModel`, forward on encoded batches.
|
| 2 |
+
|
| 3 |
+
Module and parameter names are the training checkpoint's state-dict keys. Renaming
|
| 4 |
+
one breaks `from_pretrained` for everybody who downloaded the release, so the head
|
| 5 |
+
below keeps the training code's attribute names exactly (`projection`, `roles`,
|
| 6 |
+
`typed_values`, `state_memory`, `candidate_processor`, `reasoner` with `.cell`,
|
| 7 |
+
`readout` with `utility`/`abstain`/`ordinal_score`/`threshold`/`histogram`), and the
|
| 8 |
+
encoder is a stock `ModernBertModel` under `self.encoder` for zero remapping.
|
| 9 |
+
|
| 10 |
+
The computation is the same one the shipped `model.onnx` already carries, so this
|
| 11 |
+
file ports the head's forward only: no loss, no training machinery. Text handling,
|
| 12 |
+
calibration, the server and MCP stay in the `mimirai` package; this path is load
|
| 13 |
+
plus forward on the 21 flat named tensors the graph reads, returning every depth's
|
| 14 |
+
readouts, evidence and workspace.
|
| 15 |
+
|
| 16 |
+
The typed-value quantile edges live in the checkpoint buffers, so the constructor
|
| 17 |
+
takes them as optional: without them the buffers are zeros of the right shape and
|
| 18 |
+
`load_state_dict` fills the real values. A forward before loading is meaningless.
|
| 19 |
+
|
| 20 |
+
The encoder forward replicates the training encoder call exactly (embeddings, per
|
| 21 |
+
layer-kind rotary, direct layer calls with prepared dense masks, typed-value
|
| 22 |
+
injection at `injection_layer`, final norm). SDPA only; tested transformers==5.17.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
from __future__ import annotations
|
| 26 |
+
|
| 27 |
+
import math
|
| 28 |
+
from dataclasses import dataclass
|
| 29 |
+
from typing import Any
|
| 30 |
+
|
| 31 |
+
import numpy as np
|
| 32 |
+
import numpy.typing as npt
|
| 33 |
+
import torch
|
| 34 |
+
from torch import nn
|
| 35 |
+
from transformers import ModernBertModel, PreTrainedModel
|
| 36 |
+
from transformers.modeling_outputs import ModelOutput
|
| 37 |
+
|
| 38 |
+
try:
|
| 39 |
+
from .configuration_mimir import DECISION_TYPES, MimirConfig
|
| 40 |
+
except ImportError:
|
| 41 |
+
# Loaded as remote code, where the subfolder is on sys.path but is no package.
|
| 42 |
+
from configuration_mimir import DECISION_TYPES, MimirConfig # type: ignore[import-not-found]
|
| 43 |
+
|
| 44 |
+
STATE_ROLE = 0
|
| 45 |
+
QUESTION_ROLE = 1
|
| 46 |
+
CANDIDATE_ROLE = 2
|
| 47 |
+
|
| 48 |
+
FULL_ATTENTION = "full_attention"
|
| 49 |
+
SLIDING_ATTENTION = "sliding_attention"
|
| 50 |
+
|
| 51 |
+
NUMBER = 0
|
| 52 |
+
DATE = 1
|
| 53 |
+
CYCLES = 4
|
| 54 |
+
SECONDS_PER_DAY = 86_400
|
| 55 |
+
FEBRUARY = 2
|
| 56 |
+
EPOCH_WEEKDAY = 3
|
| 57 |
+
|
| 58 |
+
RELATIONS = ("supports", "contradicts", "irrelevant")
|
| 59 |
+
|
| 60 |
+
INPUTS = (
|
| 61 |
+
"chunk_ids",
|
| 62 |
+
"chunk_mask",
|
| 63 |
+
"chunk_record",
|
| 64 |
+
"question_length",
|
| 65 |
+
"key_chunk",
|
| 66 |
+
"key_position",
|
| 67 |
+
"key_mask",
|
| 68 |
+
"candidate_ids",
|
| 69 |
+
"candidate_mask",
|
| 70 |
+
"candidate_text_mask",
|
| 71 |
+
"candidate_index",
|
| 72 |
+
"candidate_present",
|
| 73 |
+
"decision_type",
|
| 74 |
+
"typed_kind",
|
| 75 |
+
"typed_number",
|
| 76 |
+
"typed_year",
|
| 77 |
+
"typed_month",
|
| 78 |
+
"typed_day",
|
| 79 |
+
"typed_second",
|
| 80 |
+
"typed_chunk",
|
| 81 |
+
"typed_position",
|
| 82 |
+
)
|
| 83 |
+
"""The forward's named inputs, in order: the same 21 the ONNX graph reads."""
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class Norm(nn.RMSNorm):
|
| 87 |
+
"""RMSNorm in float32, returned in the input's dtype."""
|
| 88 |
+
|
| 89 |
+
def forward(self, states: torch.Tensor) -> torch.Tensor:
|
| 90 |
+
normed: torch.Tensor = super().forward(states.float())
|
| 91 |
+
return normed.to(states.dtype)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
@dataclass(frozen=True, slots=True)
|
| 95 |
+
class Memory:
|
| 96 |
+
"""Keys (normalised) and values over [batch, heads, length, size], with the key mask."""
|
| 97 |
+
|
| 98 |
+
key: torch.Tensor
|
| 99 |
+
value: torch.Tensor
|
| 100 |
+
mask: torch.Tensor
|
| 101 |
+
|
| 102 |
+
def extend(self, other: Memory) -> Memory:
|
| 103 |
+
return Memory(
|
| 104 |
+
torch.cat([self.key, other.key], dim=2),
|
| 105 |
+
torch.cat([self.value, other.value], dim=2),
|
| 106 |
+
torch.cat([self.mask, other.mask], dim=1),
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def masked_attention(query: torch.Tensor, memory: Memory) -> torch.Tensor:
|
| 111 |
+
"""Fused attention; a row with no valid key reads zeros instead of NaN."""
|
| 112 |
+
bias = torch.zeros(memory.mask.shape, dtype=query.dtype, device=query.device)
|
| 113 |
+
bias = bias.masked_fill(~memory.mask, torch.finfo(query.dtype).min)[:, None, None, :]
|
| 114 |
+
read: torch.Tensor = nn.functional.scaled_dot_product_attention(
|
| 115 |
+
query, memory.key, memory.value.to(query.dtype), attn_mask=bias
|
| 116 |
+
)
|
| 117 |
+
return read * memory.mask.any(dim=1)[:, None, None, None]
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def attention_weights(query: torch.Tensor, memory: Memory) -> torch.Tensor:
|
| 121 |
+
"""The same attention's weights in float32, zero on masked keys and on keyless rows."""
|
| 122 |
+
logits = (query @ memory.key.transpose(-1, -2)).float() / math.sqrt(query.shape[-1])
|
| 123 |
+
mask = memory.mask[:, None, None, :]
|
| 124 |
+
logits = logits.masked_fill(~mask, torch.finfo(logits.dtype).min)
|
| 125 |
+
return logits.softmax(dim=-1) * mask.any(dim=-1, keepdim=True)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
class Attention(nn.Module):
|
| 129 |
+
"""Multi-head attention from queries onto a memory, with RMSNorm on queries and keys."""
|
| 130 |
+
|
| 131 |
+
def __init__(self, config: MimirConfig, *, zero_output: bool) -> None:
|
| 132 |
+
super().__init__()
|
| 133 |
+
self.heads = config.heads
|
| 134 |
+
self.head_size = config.head_size
|
| 135 |
+
self.query = nn.Linear(config.width, config.width, bias=False)
|
| 136 |
+
self.key_value = nn.Linear(config.width, 2 * config.width, bias=False)
|
| 137 |
+
self.output = nn.Linear(config.width, config.width, bias=False)
|
| 138 |
+
self.query_norm = Norm(config.head_size)
|
| 139 |
+
self.key_norm = Norm(config.head_size)
|
| 140 |
+
if zero_output:
|
| 141 |
+
nn.init.zeros_(self.output.weight)
|
| 142 |
+
|
| 143 |
+
def _split(self, states: torch.Tensor) -> torch.Tensor:
|
| 144 |
+
batch, length, _ = states.shape
|
| 145 |
+
return states.view(batch, length, self.heads, self.head_size).transpose(1, 2)
|
| 146 |
+
|
| 147 |
+
def _merge(self, read: torch.Tensor) -> torch.Tensor:
|
| 148 |
+
batch, _, length, _ = read.shape
|
| 149 |
+
width = self.heads * self.head_size
|
| 150 |
+
merged: torch.Tensor = self.output(read.transpose(1, 2).reshape(batch, length, width))
|
| 151 |
+
return merged
|
| 152 |
+
|
| 153 |
+
def memory(self, states: torch.Tensor, mask: torch.Tensor) -> Memory:
|
| 154 |
+
key, value = self.key_value(states).chunk(2, dim=-1)
|
| 155 |
+
return Memory(self.key_norm(self._split(key)), self._split(value), mask)
|
| 156 |
+
|
| 157 |
+
def queries(self, states: torch.Tensor) -> torch.Tensor:
|
| 158 |
+
split: torch.Tensor = self.query_norm(self._split(self.query(states)))
|
| 159 |
+
return split
|
| 160 |
+
|
| 161 |
+
def read(self, states: torch.Tensor, memory: Memory) -> torch.Tensor:
|
| 162 |
+
return self._merge(masked_attention(self.queries(states), memory))
|
| 163 |
+
|
| 164 |
+
def read_with_weights(
|
| 165 |
+
self, states: torch.Tensor, memory: Memory
|
| 166 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 167 |
+
weights = attention_weights(self.queries(states), memory)
|
| 168 |
+
return self._merge(weights.to(memory.value.dtype) @ memory.value), weights
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
class AttentionBlock(nn.Module):
|
| 172 |
+
"""states + Attention(norm(states), norm(memory)); self-attention when memory is states."""
|
| 173 |
+
|
| 174 |
+
def __init__(self, config: MimirConfig) -> None:
|
| 175 |
+
super().__init__()
|
| 176 |
+
self.query_norm = Norm(config.width)
|
| 177 |
+
self.memory_norm = Norm(config.width)
|
| 178 |
+
self.attention = Attention(config, zero_output=True)
|
| 179 |
+
|
| 180 |
+
def memory(self, states: torch.Tensor, mask: torch.Tensor) -> Memory:
|
| 181 |
+
return self.attention.memory(self.memory_norm(states), mask)
|
| 182 |
+
|
| 183 |
+
def read(self, states: torch.Tensor, memory: Memory) -> torch.Tensor:
|
| 184 |
+
return states + self.attention.read(self.query_norm(states), memory)
|
| 185 |
+
|
| 186 |
+
def forward(
|
| 187 |
+
self, states: torch.Tensor, memory: torch.Tensor, memory_mask: torch.Tensor
|
| 188 |
+
) -> torch.Tensor:
|
| 189 |
+
return self.read(states, self.memory(memory, memory_mask))
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
class FeedForwardBlock(nn.Module):
|
| 193 |
+
"""states + SwiGLU(norm(states))."""
|
| 194 |
+
|
| 195 |
+
def __init__(self, config: MimirConfig) -> None:
|
| 196 |
+
super().__init__()
|
| 197 |
+
self.norm = Norm(config.width)
|
| 198 |
+
self.gate_up = nn.Linear(config.width, 2 * config.feedforward_hidden, bias=False)
|
| 199 |
+
self.down = nn.Linear(config.feedforward_hidden, config.width, bias=False)
|
| 200 |
+
nn.init.zeros_(self.down.weight)
|
| 201 |
+
|
| 202 |
+
def forward(self, states: torch.Tensor) -> torch.Tensor:
|
| 203 |
+
gate, up = self.gate_up(self.norm(states)).chunk(2, dim=-1)
|
| 204 |
+
update: torch.Tensor = self.down(nn.functional.silu(gate) * up)
|
| 205 |
+
return states + update
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
@dataclass(frozen=True, slots=True)
|
| 209 |
+
class TypedValues:
|
| 210 |
+
kind: torch.Tensor
|
| 211 |
+
number: torch.Tensor
|
| 212 |
+
year: torch.Tensor
|
| 213 |
+
month: torch.Tensor
|
| 214 |
+
day: torch.Tensor
|
| 215 |
+
second: torch.Tensor
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def signed_log(values: torch.Tensor) -> torch.Tensor:
|
| 219 |
+
return values.sign() * values.abs().log1p()
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
def days_from_civil(year: torch.Tensor, month: torch.Tensor, day: torch.Tensor) -> torch.Tensor:
|
| 223 |
+
"""Days since 1970-01-01 in the proleptic Gregorian calendar (Hinnant's algorithm)."""
|
| 224 |
+
shifted = year - (month <= FEBRUARY).long()
|
| 225 |
+
era = torch.div(shifted, 400, rounding_mode="floor")
|
| 226 |
+
year_of_era = shifted - era * 400
|
| 227 |
+
month_index = (month + 9) % 12
|
| 228 |
+
day_of_year = torch.div(153 * month_index + 2, 5, rounding_mode="floor") + day - 1
|
| 229 |
+
day_of_era = (
|
| 230 |
+
year_of_era * 365
|
| 231 |
+
+ torch.div(year_of_era, 4, rounding_mode="floor")
|
| 232 |
+
- torch.div(year_of_era, 100, rounding_mode="floor")
|
| 233 |
+
+ day_of_year
|
| 234 |
+
)
|
| 235 |
+
return era * 146_097 + day_of_era - 719_468
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
def piecewise_linear(values: torch.Tensor, edges: torch.Tensor) -> torch.Tensor:
|
| 239 |
+
"""[n] values over T+1 edges -> [n, T]; the first bin is open below, the last above."""
|
| 240 |
+
low, high = edges[:-1], edges[1:]
|
| 241 |
+
width = high - low
|
| 242 |
+
safe = torch.where(width > 0, width, torch.ones_like(width))
|
| 243 |
+
fraction = (values[:, None] - low) / safe
|
| 244 |
+
fraction = torch.where(width > 0, fraction, (values[:, None] >= high).to(values.dtype))
|
| 245 |
+
bins = edges.shape[0] - 1
|
| 246 |
+
first = torch.arange(bins, device=values.device) == 0
|
| 247 |
+
last = torch.arange(bins, device=values.device) == bins - 1
|
| 248 |
+
fraction = torch.where(first, fraction, fraction.clamp(min=0))
|
| 249 |
+
return torch.where(last, fraction, fraction.clamp(max=1))
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
class TypedValueEncoder(nn.Module):
|
| 253 |
+
"""Number bins, day bins and 4 date cycles -> MLP -> encoder width; zero at initialisation."""
|
| 254 |
+
|
| 255 |
+
def __init__(
|
| 256 |
+
self,
|
| 257 |
+
config: MimirConfig,
|
| 258 |
+
number_edges: npt.NDArray[np.float64] | None = None,
|
| 259 |
+
day_edges: npt.NDArray[np.float64] | None = None,
|
| 260 |
+
) -> None:
|
| 261 |
+
super().__init__()
|
| 262 |
+
for name, edges in (("number_edges", number_edges), ("day_edges", day_edges)):
|
| 263 |
+
if edges is None:
|
| 264 |
+
continue
|
| 265 |
+
if edges.shape != (config.value_bins + 1,) or np.any(np.diff(edges) < 0):
|
| 266 |
+
message = f"{name} of shape {edges.shape} for {config.value_bins} sorted bins"
|
| 267 |
+
raise ValueError(message)
|
| 268 |
+
missing = np.zeros(config.value_bins + 1, dtype=np.float64)
|
| 269 |
+
self.number_edges: torch.Tensor
|
| 270 |
+
self.day_edges: torch.Tensor
|
| 271 |
+
self.register_buffer(
|
| 272 |
+
"number_edges",
|
| 273 |
+
torch.from_numpy(number_edges if number_edges is not None else missing).float(),
|
| 274 |
+
)
|
| 275 |
+
self.register_buffer(
|
| 276 |
+
"day_edges",
|
| 277 |
+
torch.from_numpy(day_edges if day_edges is not None else missing).float(),
|
| 278 |
+
)
|
| 279 |
+
features = 2 * config.value_bins + 2 * CYCLES
|
| 280 |
+
self.hidden = nn.Linear(features, config.width, bias=False)
|
| 281 |
+
self.output = nn.Linear(config.width, config.encoder_width, bias=False)
|
| 282 |
+
nn.init.zeros_(self.output.weight)
|
| 283 |
+
|
| 284 |
+
def features(self, values: TypedValues) -> torch.Tensor:
|
| 285 |
+
is_number = values.kind == NUMBER
|
| 286 |
+
is_date = values.kind == DATE
|
| 287 |
+
number = torch.nan_to_num(values.number.float(), nan=0.0, posinf=0.0, neginf=0.0)
|
| 288 |
+
number_part = piecewise_linear(signed_log(number), self.number_edges)
|
| 289 |
+
days = days_from_civil(values.year, values.month.clamp(min=1), values.day.clamp(min=1))
|
| 290 |
+
day_part = piecewise_linear(days.float(), self.day_edges)
|
| 291 |
+
weekday = (days + EPOCH_WEEKDAY) % 7
|
| 292 |
+
angles = (
|
| 293 |
+
2
|
| 294 |
+
* math.pi
|
| 295 |
+
* torch.stack(
|
| 296 |
+
[
|
| 297 |
+
(values.month.float() - 1) / 12,
|
| 298 |
+
(values.day.float() - 1) / 31,
|
| 299 |
+
weekday.float() / 7,
|
| 300 |
+
values.second.float() / SECONDS_PER_DAY,
|
| 301 |
+
],
|
| 302 |
+
dim=-1,
|
| 303 |
+
)
|
| 304 |
+
)
|
| 305 |
+
cycles = torch.cat([angles.sin(), angles.cos()], dim=-1)
|
| 306 |
+
return torch.cat(
|
| 307 |
+
[
|
| 308 |
+
number_part * is_number[:, None],
|
| 309 |
+
day_part * is_date[:, None],
|
| 310 |
+
cycles * is_date[:, None],
|
| 311 |
+
],
|
| 312 |
+
dim=-1,
|
| 313 |
+
)
|
| 314 |
+
|
| 315 |
+
def forward(self, values: TypedValues) -> torch.Tensor:
|
| 316 |
+
encoded: torch.Tensor = self.output(nn.functional.silu(self.hidden(self.features(values))))
|
| 317 |
+
return encoded
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
class StateMemory(nn.Module):
|
| 321 |
+
"""Compress a record's chunk tokens into question-conditioned latents Z."""
|
| 322 |
+
|
| 323 |
+
def __init__(self, config: MimirConfig) -> None:
|
| 324 |
+
super().__init__()
|
| 325 |
+
self.latents = nn.Parameter(torch.empty(config.latents, config.width))
|
| 326 |
+
nn.init.orthogonal_(self.latents)
|
| 327 |
+
self.question = nn.Linear(config.width, config.width, bias=False)
|
| 328 |
+
self.read = AttentionBlock(config)
|
| 329 |
+
self.read_feedforward = FeedForwardBlock(config)
|
| 330 |
+
self.mix = AttentionBlock(config)
|
| 331 |
+
self.mix_feedforward = FeedForwardBlock(config)
|
| 332 |
+
|
| 333 |
+
def forward(
|
| 334 |
+
self, question: torch.Tensor, tokens: torch.Tensor, token_mask: torch.Tensor
|
| 335 |
+
) -> torch.Tensor:
|
| 336 |
+
latents: torch.Tensor = self.latents + self.question(question)[:, None]
|
| 337 |
+
latents = self.read_feedforward(self.read(latents, tokens, token_mask))
|
| 338 |
+
every = torch.ones(latents.shape[:2], dtype=torch.bool, device=latents.device)
|
| 339 |
+
memory: torch.Tensor = self.mix_feedforward(self.mix(latents, latents, every))
|
| 340 |
+
return memory
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
class CandidateProcessor(nn.Module):
|
| 344 |
+
"""Candidates as a set: each reads the question, then all attend to all, with no positions."""
|
| 345 |
+
|
| 346 |
+
def __init__(self, config: MimirConfig) -> None:
|
| 347 |
+
super().__init__()
|
| 348 |
+
self.read_question = AttentionBlock(config)
|
| 349 |
+
self.interact = AttentionBlock(config)
|
| 350 |
+
self.feedforward = FeedForwardBlock(config)
|
| 351 |
+
|
| 352 |
+
def forward(
|
| 353 |
+
self,
|
| 354 |
+
candidates: torch.Tensor,
|
| 355 |
+
candidate_mask: torch.Tensor,
|
| 356 |
+
question: torch.Tensor,
|
| 357 |
+
question_mask: torch.Tensor,
|
| 358 |
+
) -> torch.Tensor:
|
| 359 |
+
candidates = self.read_question(candidates, question, question_mask)
|
| 360 |
+
candidates = self.interact(candidates, candidates, candidate_mask)
|
| 361 |
+
refined: torch.Tensor = self.feedforward(candidates)
|
| 362 |
+
return refined
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
@dataclass(frozen=True, slots=True)
|
| 366 |
+
class Context:
|
| 367 |
+
"""The fixed memories every iteration reads, already projected."""
|
| 368 |
+
|
| 369 |
+
recall: Memory
|
| 370 |
+
tokens: Memory
|
| 371 |
+
candidate_state: Memory
|
| 372 |
+
candidate_mask: torch.Tensor
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
@dataclass(frozen=True, slots=True)
|
| 376 |
+
class Iteration:
|
| 377 |
+
workspace: torch.Tensor
|
| 378 |
+
candidates: torch.Tensor
|
| 379 |
+
evidence: torch.Tensor
|
| 380 |
+
gap_weights: torch.Tensor
|
| 381 |
+
|
| 382 |
+
|
| 383 |
+
def _every(states: torch.Tensor) -> torch.Tensor:
|
| 384 |
+
return torch.ones(states.shape[:2], dtype=torch.bool, device=states.device)
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
class ReasonerCell(nn.Module):
|
| 388 |
+
"""The shared reasoning cell over workspace slots, applied once per iteration."""
|
| 389 |
+
|
| 390 |
+
def __init__(self, config: MimirConfig) -> None:
|
| 391 |
+
super().__init__()
|
| 392 |
+
self.recall = AttentionBlock(config)
|
| 393 |
+
self.slot_norm = Norm(config.width)
|
| 394 |
+
self.token_norm = Norm(config.width)
|
| 395 |
+
self.evidence_norm = Norm(config.width)
|
| 396 |
+
self.gap = Attention(config, zero_output=False)
|
| 397 |
+
self.relation = nn.Linear(3 * config.width, len(RELATIONS), bias=False)
|
| 398 |
+
nn.init.zeros_(self.relation.weight)
|
| 399 |
+
self.support = nn.Linear(config.width, config.width, bias=False)
|
| 400 |
+
self.contradict = nn.Linear(config.width, config.width, bias=False)
|
| 401 |
+
nn.init.zeros_(self.support.weight)
|
| 402 |
+
nn.init.zeros_(self.contradict.weight)
|
| 403 |
+
self.workspace_feedforward = FeedForwardBlock(config)
|
| 404 |
+
self.read_candidates = AttentionBlock(config)
|
| 405 |
+
self.candidates_read = AttentionBlock(config)
|
| 406 |
+
self.interact = AttentionBlock(config)
|
| 407 |
+
self.candidate_feedforward = FeedForwardBlock(config)
|
| 408 |
+
|
| 409 |
+
def context(
|
| 410 |
+
self,
|
| 411 |
+
memory: torch.Tensor,
|
| 412 |
+
question: torch.Tensor,
|
| 413 |
+
question_mask: torch.Tensor,
|
| 414 |
+
tokens: torch.Tensor,
|
| 415 |
+
token_mask: torch.Tensor,
|
| 416 |
+
candidate_mask: torch.Tensor,
|
| 417 |
+
) -> Context:
|
| 418 |
+
recall = torch.cat([memory, question], dim=1)
|
| 419 |
+
state = torch.cat([memory, tokens], dim=1)
|
| 420 |
+
return Context(
|
| 421 |
+
recall=self.recall.memory(recall, torch.cat([_every(memory), question_mask], dim=1)),
|
| 422 |
+
tokens=self.gap.memory(self.token_norm(tokens), token_mask),
|
| 423 |
+
candidate_state=self.candidates_read.memory(
|
| 424 |
+
state, torch.cat([_every(memory), token_mask], dim=1)
|
| 425 |
+
),
|
| 426 |
+
candidate_mask=candidate_mask,
|
| 427 |
+
)
|
| 428 |
+
|
| 429 |
+
def forward(
|
| 430 |
+
self,
|
| 431 |
+
workspace: torch.Tensor,
|
| 432 |
+
candidates: torch.Tensor,
|
| 433 |
+
evidence: torch.Tensor,
|
| 434 |
+
context: Context,
|
| 435 |
+
) -> Iteration:
|
| 436 |
+
own = torch.cat([workspace, evidence], dim=1)
|
| 437 |
+
workspace = self.recall.read(
|
| 438 |
+
workspace, self.recall.memory(own, _every(own)).extend(context.recall)
|
| 439 |
+
)
|
| 440 |
+
query = self.slot_norm(workspace)
|
| 441 |
+
found, gap_weights = self.gap.read_with_weights(query, context.tokens)
|
| 442 |
+
found_norm = self.evidence_norm(found)
|
| 443 |
+
relation = self.relation(torch.cat([query, found_norm, query * found_norm], dim=-1))
|
| 444 |
+
weights = relation.float().softmax(dim=-1).to(workspace.dtype)
|
| 445 |
+
workspace = (
|
| 446 |
+
workspace
|
| 447 |
+
+ weights[..., 0:1] * self.support(found_norm)
|
| 448 |
+
+ weights[..., 1:2] * self.contradict(found_norm)
|
| 449 |
+
)
|
| 450 |
+
evidence = torch.cat([evidence, found], dim=1)
|
| 451 |
+
workspace = self.workspace_feedforward(workspace)
|
| 452 |
+
workspace = self.read_candidates(workspace, candidates, context.candidate_mask)
|
| 453 |
+
own = torch.cat([workspace, evidence], dim=1)
|
| 454 |
+
candidates = self.candidates_read.read(
|
| 455 |
+
candidates,
|
| 456 |
+
self.candidates_read.memory(own, _every(own)).extend(context.candidate_state),
|
| 457 |
+
)
|
| 458 |
+
candidates = self.interact(candidates, candidates, context.candidate_mask)
|
| 459 |
+
candidates = self.candidate_feedforward(candidates)
|
| 460 |
+
return Iteration(workspace, candidates, evidence, gap_weights)
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
class Reasoner(nn.Module):
|
| 464 |
+
"""Workspace slots seeded by the schema and the question, then the cell once per iteration."""
|
| 465 |
+
|
| 466 |
+
def __init__(self, config: MimirConfig) -> None:
|
| 467 |
+
super().__init__()
|
| 468 |
+
self.iterations = config.iterations
|
| 469 |
+
self.slots = nn.Parameter(torch.empty(config.slots, config.width))
|
| 470 |
+
nn.init.orthogonal_(self.slots)
|
| 471 |
+
self.schemas = nn.Embedding(len(DECISION_TYPES), config.width)
|
| 472 |
+
self.question = nn.Linear(config.width, config.width, bias=False)
|
| 473 |
+
self.cell = ReasonerCell(config)
|
| 474 |
+
|
| 475 |
+
def forward(
|
| 476 |
+
self,
|
| 477 |
+
question_mean: torch.Tensor,
|
| 478 |
+
decision_type: torch.Tensor,
|
| 479 |
+
candidates: torch.Tensor,
|
| 480 |
+
context: Context,
|
| 481 |
+
) -> list[Iteration]:
|
| 482 |
+
seed = self.schemas(decision_type) + self.question(question_mean)
|
| 483 |
+
workspace = self.slots + seed[:, None]
|
| 484 |
+
evidence = workspace.new_zeros((workspace.shape[0], 0, workspace.shape[2]))
|
| 485 |
+
iterations: list[Iteration] = []
|
| 486 |
+
for _ in range(self.iterations):
|
| 487 |
+
step = self.cell(workspace, candidates, evidence, context)
|
| 488 |
+
iterations.append(step)
|
| 489 |
+
workspace, candidates, evidence = step.workspace, step.candidates, step.evidence
|
| 490 |
+
return iterations
|
| 491 |
+
|
| 492 |
+
|
| 493 |
+
@dataclass(frozen=True, slots=True)
|
| 494 |
+
class Readout:
|
| 495 |
+
utilities: torch.Tensor
|
| 496 |
+
abstain: torch.Tensor
|
| 497 |
+
ordinal_score: torch.Tensor
|
| 498 |
+
thresholds: torch.Tensor
|
| 499 |
+
histogram_logits: torch.Tensor
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
def readout_mlp(inputs: int, width: int, outputs: int) -> nn.Sequential:
|
| 503 |
+
return nn.Sequential(
|
| 504 |
+
Norm(inputs),
|
| 505 |
+
nn.Linear(inputs, width, bias=False),
|
| 506 |
+
nn.SiLU(),
|
| 507 |
+
nn.Linear(width, outputs),
|
| 508 |
+
)
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
class DecisionReadout(nn.Module):
|
| 512 |
+
def __init__(self, config: MimirConfig) -> None:
|
| 513 |
+
super().__init__()
|
| 514 |
+
width = config.width
|
| 515 |
+
self.utility = readout_mlp(width, width, 1)
|
| 516 |
+
self.abstain = readout_mlp(width, width, 1)
|
| 517 |
+
self.ordinal_score = readout_mlp(width, width, 1)
|
| 518 |
+
self.threshold = readout_mlp(2 * width, width, 1)
|
| 519 |
+
self.histogram = readout_mlp(width, width, config.histogram_bins)
|
| 520 |
+
|
| 521 |
+
def forward(self, pooled: torch.Tensor, candidates: torch.Tensor) -> Readout:
|
| 522 |
+
"""`pooled` is the workspace averaged over its slots."""
|
| 523 |
+
pairs = torch.cat([candidates[:, :-1], candidates[:, 1:]], dim=-1)
|
| 524 |
+
raw = self.threshold(pairs).squeeze(-1)
|
| 525 |
+
steps = nn.functional.softplus(raw[:, 1:])
|
| 526 |
+
thresholds = torch.cat([raw[:, :1], raw[:, :1] + steps.cumsum(dim=1)], dim=1)
|
| 527 |
+
return Readout(
|
| 528 |
+
utilities=self.utility(candidates).squeeze(-1),
|
| 529 |
+
abstain=self.abstain(pooled).squeeze(-1),
|
| 530 |
+
ordinal_score=self.ordinal_score(pooled).squeeze(-1),
|
| 531 |
+
thresholds=thresholds,
|
| 532 |
+
histogram_logits=self.histogram(pooled),
|
| 533 |
+
)
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
@dataclass(frozen=True, slots=True)
|
| 537 |
+
class HeadInputs:
|
| 538 |
+
"""Encoder states per record: state keys, question tokens and pooled candidates."""
|
| 539 |
+
|
| 540 |
+
tokens: torch.Tensor
|
| 541 |
+
token_mask: torch.Tensor
|
| 542 |
+
question: torch.Tensor
|
| 543 |
+
question_mask: torch.Tensor
|
| 544 |
+
candidates: torch.Tensor
|
| 545 |
+
candidate_mask: torch.Tensor
|
| 546 |
+
decision_type: torch.Tensor
|
| 547 |
+
|
| 548 |
+
|
| 549 |
+
@dataclass(frozen=True, slots=True)
|
| 550 |
+
class DepthOutput:
|
| 551 |
+
"""One depth's decision; `workspace` is the slot-averaged workspace the readout reads."""
|
| 552 |
+
|
| 553 |
+
readout: Readout
|
| 554 |
+
evidence_scores: torch.Tensor
|
| 555 |
+
workspace: torch.Tensor
|
| 556 |
+
|
| 557 |
+
|
| 558 |
+
class DecisionHead(nn.Module):
|
| 559 |
+
def __init__(
|
| 560 |
+
self,
|
| 561 |
+
config: MimirConfig,
|
| 562 |
+
number_edges: npt.NDArray[np.float64] | None = None,
|
| 563 |
+
day_edges: npt.NDArray[np.float64] | None = None,
|
| 564 |
+
) -> None:
|
| 565 |
+
super().__init__()
|
| 566 |
+
self.config = config
|
| 567 |
+
self.projection = nn.Linear(config.encoder_width, config.width, bias=False)
|
| 568 |
+
self.roles = nn.Embedding(3, config.width)
|
| 569 |
+
self.typed_values = TypedValueEncoder(config, number_edges, day_edges)
|
| 570 |
+
self.state_memory = StateMemory(config)
|
| 571 |
+
self.candidate_processor = CandidateProcessor(config)
|
| 572 |
+
self.reasoner = Reasoner(config)
|
| 573 |
+
self.readout = DecisionReadout(config)
|
| 574 |
+
|
| 575 |
+
def _project(self, states: torch.Tensor, role: int) -> torch.Tensor:
|
| 576 |
+
projected: torch.Tensor = self.projection(states)
|
| 577 |
+
return projected + self.roles.weight[role]
|
| 578 |
+
|
| 579 |
+
def forward(self, inputs: HeadInputs) -> list[DepthOutput]:
|
| 580 |
+
tokens = self._project(inputs.tokens, STATE_ROLE)
|
| 581 |
+
question = self._project(inputs.question, QUESTION_ROLE)
|
| 582 |
+
candidates = self._project(inputs.candidates, CANDIDATE_ROLE)
|
| 583 |
+
weight = inputs.question_mask[..., None].to(question.dtype)
|
| 584 |
+
question_mean = (question * weight).sum(dim=1) / weight.sum(dim=1).clamp(min=1)
|
| 585 |
+
memory = self.state_memory(question_mean, tokens, inputs.token_mask)
|
| 586 |
+
candidates = self.candidate_processor(
|
| 587 |
+
candidates, inputs.candidate_mask, question, inputs.question_mask
|
| 588 |
+
)
|
| 589 |
+
context = self.reasoner.cell.context(
|
| 590 |
+
memory,
|
| 591 |
+
question,
|
| 592 |
+
inputs.question_mask,
|
| 593 |
+
tokens,
|
| 594 |
+
inputs.token_mask,
|
| 595 |
+
inputs.candidate_mask,
|
| 596 |
+
)
|
| 597 |
+
iterations = self.reasoner(question_mean, inputs.decision_type, candidates, context)
|
| 598 |
+
outputs: list[DepthOutput] = []
|
| 599 |
+
for step in iterations:
|
| 600 |
+
pooled = step.workspace.mean(dim=1)
|
| 601 |
+
outputs.append(
|
| 602 |
+
DepthOutput(
|
| 603 |
+
readout=self.readout(pooled, step.candidates),
|
| 604 |
+
evidence_scores=step.gap_weights.mean(dim=(1, 2)),
|
| 605 |
+
workspace=pooled,
|
| 606 |
+
)
|
| 607 |
+
)
|
| 608 |
+
return outputs
|
| 609 |
+
|
| 610 |
+
|
| 611 |
+
def padded_dense_masks(
|
| 612 |
+
attention_mask: torch.Tensor, sliding_window: int
|
| 613 |
+
) -> dict[str, torch.Tensor]:
|
| 614 |
+
positions = torch.arange(attention_mask.shape[1], device=attention_mask.device)
|
| 615 |
+
keys = attention_mask.bool()[:, None, None, :]
|
| 616 |
+
near = (positions[:, None] - positions[None, :]).abs() <= sliding_window
|
| 617 |
+
return {FULL_ATTENTION: keys, SLIDING_ATTENTION: keys & near}
|
| 618 |
+
|
| 619 |
+
|
| 620 |
+
def _pool_candidates(hidden: torch.Tensor, text_mask: torch.Tensor) -> torch.Tensor:
|
| 621 |
+
"""Each candidate row's mean state over its own text tokens."""
|
| 622 |
+
weight = text_mask[..., None].to(hidden.dtype)
|
| 623 |
+
return (hidden * weight).sum(dim=1) / weight.sum(dim=1).clamp(min=1)
|
| 624 |
+
|
| 625 |
+
|
| 626 |
+
def _mean_question(
|
| 627 |
+
question: torch.Tensor, chunk_record: torch.Tensor, question_length: torch.Tensor
|
| 628 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 629 |
+
"""Question positions 1.. of every chunk, averaged over the chunks of each record."""
|
| 630 |
+
positions = torch.arange(question.shape[1], device=question.device)
|
| 631 |
+
per_chunk = (positions < question_length[:, None]).to(question.dtype)
|
| 632 |
+
records = torch.arange(chunk_record.max().item() + 1, device=question.device)
|
| 633 |
+
owner = (chunk_record[None, :] == records[:, None]).to(question.dtype)
|
| 634 |
+
summed = torch.einsum("rc,cqd->rqd", owner, question * per_chunk[..., None])
|
| 635 |
+
counts = owner @ per_chunk
|
| 636 |
+
return summed / counts.clamp(min=1)[..., None], counts > 0
|
| 637 |
+
|
| 638 |
+
|
| 639 |
+
@dataclass
|
| 640 |
+
class MimirModelOutput(ModelOutput):
|
| 641 |
+
"""Every depth's readouts stacked first, plus the final pooled workspace."""
|
| 642 |
+
|
| 643 |
+
utilities: torch.Tensor | None = None
|
| 644 |
+
thresholds: torch.Tensor | None = None
|
| 645 |
+
abstain: torch.Tensor | None = None
|
| 646 |
+
ordinal_score: torch.Tensor | None = None
|
| 647 |
+
histogram_logits: torch.Tensor | None = None
|
| 648 |
+
evidence: torch.Tensor | None = None
|
| 649 |
+
workspace: torch.Tensor | None = None
|
| 650 |
+
|
| 651 |
+
|
| 652 |
+
class MimirModel(PreTrainedModel):
|
| 653 |
+
"""The decision model behind `AutoModel`: the stock encoder plus the head.
|
| 654 |
+
|
| 655 |
+
The encoder lives under `self.encoder`, the head under `self.head`. Forward takes
|
| 656 |
+
the 21 flat named tensors the release graph reads and returns every depth's
|
| 657 |
+
readouts. The batch must hold at least one candidate row, and the question states
|
| 658 |
+
are `question_cap` wide whatever the chunk width, exactly like the exported path
|
| 659 |
+
the graph was cut from.
|
| 660 |
+
"""
|
| 661 |
+
|
| 662 |
+
config_class = MimirConfig
|
| 663 |
+
config: MimirConfig
|
| 664 |
+
base_model_prefix = "mimir"
|
| 665 |
+
_supports_sdpa = True
|
| 666 |
+
|
| 667 |
+
def __init__(self, config: MimirConfig) -> None:
|
| 668 |
+
super().__init__(config)
|
| 669 |
+
self.encoder = ModernBertModel(config)
|
| 670 |
+
self.head = DecisionHead(config)
|
| 671 |
+
self.post_init()
|
| 672 |
+
self.encoder.set_attn_implementation("sdpa")
|
| 673 |
+
|
| 674 |
+
def _init_weights(self, module: nn.Module) -> None:
|
| 675 |
+
# Constructors already initialise every head weight (default, zero or
|
| 676 |
+
# orthogonal, exactly like training); the checkpoint overwrites them all.
|
| 677 |
+
# The encoder ran its own init at construction; leave it alone here.
|
| 678 |
+
if isinstance(module, Norm) and isinstance(module.weight, torch.nn.Parameter):
|
| 679 |
+
nn.init.ones_(module.weight)
|
| 680 |
+
|
| 681 |
+
def get_input_embeddings(self) -> nn.Module:
|
| 682 |
+
return self.encoder.get_input_embeddings()
|
| 683 |
+
|
| 684 |
+
def set_input_embeddings(self, value: nn.Module) -> None:
|
| 685 |
+
self.encoder.set_input_embeddings(value)
|
| 686 |
+
|
| 687 |
+
def _encode(
|
| 688 |
+
self,
|
| 689 |
+
input_ids: torch.Tensor,
|
| 690 |
+
mask: torch.Tensor,
|
| 691 |
+
typed: TypedValues,
|
| 692 |
+
typed_chunk: torch.Tensor,
|
| 693 |
+
typed_position: torch.Tensor,
|
| 694 |
+
*,
|
| 695 |
+
inject: bool,
|
| 696 |
+
) -> torch.Tensor:
|
| 697 |
+
positions = torch.arange(input_ids.shape[1], device=input_ids.device)
|
| 698 |
+
positions = positions.expand(input_ids.shape[0], -1)
|
| 699 |
+
masks = padded_dense_masks(mask.long(), int(self.config.sliding_window))
|
| 700 |
+
injection: torch.Tensor | None = None
|
| 701 |
+
injection_layer = -1
|
| 702 |
+
if inject and typed.kind.numel():
|
| 703 |
+
values = self.head.typed_values(typed)
|
| 704 |
+
hidden = values.new_zeros((*input_ids.shape, values.shape[-1]))
|
| 705 |
+
hidden = hidden.index_put(
|
| 706 |
+
(typed_chunk, typed_position), values, accumulate=True
|
| 707 |
+
)
|
| 708 |
+
injection = hidden
|
| 709 |
+
injection_layer = self.config.injection_layer
|
| 710 |
+
layer_types = self.encoder.config.layer_types
|
| 711 |
+
if layer_types is None:
|
| 712 |
+
message = "encoder config names no layer types"
|
| 713 |
+
raise ValueError(message)
|
| 714 |
+
hidden = self.encoder.embeddings(input_ids=input_ids)
|
| 715 |
+
rotary = {
|
| 716 |
+
kind: self.encoder.rotary_emb(hidden, positions, kind) for kind in set(layer_types)
|
| 717 |
+
}
|
| 718 |
+
for index, (layer, kind) in enumerate(zip(self.encoder.layers, layer_types, strict=True)):
|
| 719 |
+
if injection is not None and index == injection_layer:
|
| 720 |
+
hidden = hidden + injection.to(hidden.dtype)
|
| 721 |
+
hidden = layer(hidden, attention_mask=masks[kind], position_embeddings=rotary[kind])
|
| 722 |
+
output: torch.Tensor = self.encoder.final_norm(hidden)
|
| 723 |
+
return output
|
| 724 |
+
|
| 725 |
+
def forward(
|
| 726 |
+
self,
|
| 727 |
+
chunk_ids: torch.Tensor,
|
| 728 |
+
chunk_mask: torch.Tensor,
|
| 729 |
+
chunk_record: torch.Tensor,
|
| 730 |
+
question_length: torch.Tensor,
|
| 731 |
+
key_chunk: torch.Tensor,
|
| 732 |
+
key_position: torch.Tensor,
|
| 733 |
+
key_mask: torch.Tensor,
|
| 734 |
+
candidate_ids: torch.Tensor,
|
| 735 |
+
candidate_mask: torch.Tensor,
|
| 736 |
+
candidate_text_mask: torch.Tensor,
|
| 737 |
+
candidate_index: torch.Tensor,
|
| 738 |
+
candidate_present: torch.Tensor,
|
| 739 |
+
decision_type: torch.Tensor,
|
| 740 |
+
typed_kind: torch.Tensor,
|
| 741 |
+
typed_number: torch.Tensor,
|
| 742 |
+
typed_year: torch.Tensor,
|
| 743 |
+
typed_month: torch.Tensor,
|
| 744 |
+
typed_day: torch.Tensor,
|
| 745 |
+
typed_second: torch.Tensor,
|
| 746 |
+
typed_chunk: torch.Tensor,
|
| 747 |
+
typed_position: torch.Tensor,
|
| 748 |
+
return_dict: bool | None = None,
|
| 749 |
+
**kwargs: Any,
|
| 750 |
+
) -> MimirModelOutput | tuple[torch.Tensor, ...]:
|
| 751 |
+
if candidate_ids.shape[0] == 0:
|
| 752 |
+
message = "the batch holds no candidate row; the exported path needs at least one"
|
| 753 |
+
raise ValueError(message)
|
| 754 |
+
question_cap = self.config.question_cap
|
| 755 |
+
typed = TypedValues(
|
| 756 |
+
kind=typed_kind,
|
| 757 |
+
number=typed_number,
|
| 758 |
+
year=typed_year,
|
| 759 |
+
month=typed_month,
|
| 760 |
+
day=typed_day,
|
| 761 |
+
second=typed_second,
|
| 762 |
+
)
|
| 763 |
+
hidden = self._encode(
|
| 764 |
+
chunk_ids, chunk_mask.bool(), typed, typed_chunk, typed_position, inject=True
|
| 765 |
+
)
|
| 766 |
+
question = nn.functional.pad(hidden, (0, 0, 0, question_cap + 1))[:, 1 : 1 + question_cap]
|
| 767 |
+
candidates = self._encode(
|
| 768 |
+
candidate_ids,
|
| 769 |
+
candidate_mask.bool(),
|
| 770 |
+
typed,
|
| 771 |
+
typed_chunk,
|
| 772 |
+
typed_position,
|
| 773 |
+
inject=False,
|
| 774 |
+
)
|
| 775 |
+
pooled = _pool_candidates(candidates, candidate_text_mask.bool())
|
| 776 |
+
question, question_mask = _mean_question(question, chunk_record, question_length)
|
| 777 |
+
tokens = hidden[key_chunk, key_position]
|
| 778 |
+
if pooled.shape[0]:
|
| 779 |
+
selected = pooled[candidate_index]
|
| 780 |
+
else:
|
| 781 |
+
selected = pooled.new_zeros((*candidate_index.shape, pooled.shape[-1]))
|
| 782 |
+
inputs = HeadInputs(
|
| 783 |
+
tokens=tokens,
|
| 784 |
+
token_mask=key_mask.bool(),
|
| 785 |
+
question=question,
|
| 786 |
+
question_mask=question_mask,
|
| 787 |
+
candidates=selected,
|
| 788 |
+
candidate_mask=candidate_present.bool(),
|
| 789 |
+
decision_type=decision_type,
|
| 790 |
+
)
|
| 791 |
+
outputs = self.head(inputs)
|
| 792 |
+
per_depth: dict[str, list[torch.Tensor]] = {
|
| 793 |
+
"utilities": [],
|
| 794 |
+
"thresholds": [],
|
| 795 |
+
"abstain": [],
|
| 796 |
+
"ordinal_score": [],
|
| 797 |
+
"histogram_logits": [],
|
| 798 |
+
"evidence": [],
|
| 799 |
+
}
|
| 800 |
+
for output in outputs:
|
| 801 |
+
readout = output.readout
|
| 802 |
+
per_depth["utilities"].append(readout.utilities.float())
|
| 803 |
+
per_depth["thresholds"].append(readout.thresholds.float())
|
| 804 |
+
per_depth["abstain"].append(readout.abstain.float())
|
| 805 |
+
per_depth["ordinal_score"].append(readout.ordinal_score.float())
|
| 806 |
+
per_depth["histogram_logits"].append(readout.histogram_logits.float())
|
| 807 |
+
per_depth["evidence"].append(output.evidence_scores.float())
|
| 808 |
+
stacked = {name: torch.stack(values) for name, values in per_depth.items()}
|
| 809 |
+
utilities = stacked["utilities"]
|
| 810 |
+
thresholds = stacked["thresholds"]
|
| 811 |
+
abstain = stacked["abstain"]
|
| 812 |
+
ordinal_score = stacked["ordinal_score"]
|
| 813 |
+
histogram_logits = stacked["histogram_logits"]
|
| 814 |
+
evidence = stacked["evidence"]
|
| 815 |
+
workspace = outputs[-1].workspace.float()
|
| 816 |
+
result = MimirModelOutput(
|
| 817 |
+
utilities=utilities,
|
| 818 |
+
thresholds=thresholds,
|
| 819 |
+
abstain=abstain,
|
| 820 |
+
ordinal_score=ordinal_score,
|
| 821 |
+
histogram_logits=histogram_logits,
|
| 822 |
+
evidence=evidence,
|
| 823 |
+
workspace=workspace,
|
| 824 |
+
)
|
| 825 |
+
if return_dict is False:
|
| 826 |
+
return (
|
| 827 |
+
utilities,
|
| 828 |
+
thresholds,
|
| 829 |
+
abstain,
|
| 830 |
+
ordinal_score,
|
| 831 |
+
histogram_logits,
|
| 832 |
+
evidence,
|
| 833 |
+
workspace,
|
| 834 |
+
)
|
| 835 |
+
return result
|
| 836 |
+
|
| 837 |
+
|
| 838 |
+
__all__ = ["INPUTS", "MimirModel", "MimirModelOutput"]
|
transformers/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|