ainouche-abderahmane commited on
Commit
36127db
Β·
verified Β·
1 Parent(s): adb23bc

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +121 -104
README.md CHANGED
@@ -47,27 +47,34 @@ model-index:
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
 
@@ -78,32 +85,39 @@ result = model.choose(
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
@@ -114,28 +128,41 @@ a subfolder, and only what you load is downloaded:
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
@@ -159,36 +186,44 @@ its own fast-decisions showcase. DAIR Emotion is abstention, not error β€” the m
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
 
@@ -208,47 +243,29 @@ shipped `model.onnx` already carries.
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
 
@@ -270,7 +287,7 @@ No optimiser state, no scheduler state, no RNG. Training cannot be resumed from
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
 
 
47
 
48
  # MIMIR-1
49
 
50
+ **Decisions your agents can act on.** MIMIR is an English-only, non-generative decision
51
+ model: give it a **context**, a **question** and the **options**, and it returns a typed
52
+ answer with calibrated probabilities, the parts of the context it relied on, and a
53
+ certified signal for when to act and when to escalate. It never generates text, so there
54
+ is nothing to parse and nothing to hallucinate.
55
+
56
+ **419M parameters** β€” a ModernBERT-Large encoder plus a decision head that refines one
57
+ readout per iteration over four iterations, with a certified early exit at depth 2.
58
+ Against Laya and GLiNER2.5-Decide, each run by us on identical records, it leads both on
59
+ six of ten tasks: **+54.7 points on Banking77, +42.3 on MASSIVE English, +36.3 on typed
60
+ decisions, +27.6 on prompt injections**. Where it cannot back an answer it abstains
61
+ instead of guessing. Built for the decision layer under agents: routing requests, gating
62
+ tool calls, verifying claims.
63
 
64
  ## Installation
65
 
66
+ The `mimirai` package is launched and is the way to use this model:
67
+
68
  ```bash
69
+ pip install "mimirai[local]" # CPU engine
70
+ pip install "mimirai[local-gpu]" # CUDA engine
71
+ pip install mimirai # data models and HTTP client only
72
  ```
73
 
74
+ Python 3.11 or later. `mimirai` is the package, `mimir` the import.
75
 
76
  ## Quickstart
77
 
 
 
 
 
78
  ```python
79
  from mimir import Mimir
80
 
 
85
  "Which team should handle this?",
86
  options={"billing": "Billing: payments, refunds", "security": "Security: account access"},
87
  )
88
+ print(result.status) # DECIDED
89
+ print(result.answer) # billing
90
+ print(result.probabilities) # calibrated probability of each option
91
+ print(result.certificate) # the certified threshold the decision was checked against
92
  ```
93
 
94
+ > **Three outcomes, not two.** Every call ends `DECIDED`, `ABSTAINED` or `DEFERRED`.
95
+ > `ABSTAINED` means none of the listed options is supported; `DEFERRED` means the
96
+ > certificate does not cover this call at your risk level β€” `result.deferral.reason` says
97
+ > why (`below_threshold`, `out_of_distribution` or `no_certified_threshold`). Both are
98
+ > answers, not errors: a decision layer that cannot refuse is a random generator with
99
+ > calibrated-looking outputs.
100
 
101
+ ## What it decides
 
 
 
102
 
103
+ | You ask | You get |
104
+ |---|---|
105
+ | `choose` β€” pick one option, or none | an option id, or `None` |
106
+ | multi-choice β€” pick every option that applies | the option ids that apply |
107
+ | `yes_no` β€” answer a yes/no question | `True` or `False` |
108
+ | `verify` β€” judge a claim against evidence | `supported`, `contradicted` or `not_enough_information` |
109
+ | `rank` β€” order candidates, best first | candidate ids, best first |
110
+ | `rate` β€” rate on your ordered scale | a level id |
111
+ | `estimate` β€” estimate a number in `[low, high]` | a number with an interval |
112
 
113
+ Every result carries `status`, `confidence`, `relevant_context` (the context parts behind
114
+ the answer, most relevant first), `certificate`, `deferral` and `latency_ms`. Choice,
115
+ yes/no and verify results add `abstain_probability` and a conformal `prediction_set`.
116
 
117
+ A context is a string, a list of passages, tables with typed numbers and dates, or a JSON
118
+ state β€” and `decide_many` batches many decisions while every method has an async form.
119
 
120
+ ## Load paths
121
 
122
  **This repo holds all three load paths.** The release root is the `mimirai` contract
123
  (ONNX graphs plus certified policy); the same weights ship as plain `transformers` under
 
128
  | **`Mythologic/MIMIR-1`** (this repo root) | ONNX graphs + certified policy via `mimirai` | routing, gating, verification |
129
  | **`Mythologic/MIMIR-1`, `subfolder="transformers"`** | same weights for plain `transformers` | research, custom runtimes |
130
 
131
+ ### Package mode (recommended)
132
 
133
+ `mimirai` handles chunking, typed readouts, evidence, the distance gate and the
134
+ certificate in one call, and additionally serves them over HTTP and MCP:
135
 
136
+ ```bash
137
+ mimir serve # HTTP, configured decision endpoints
138
+ mimir mcp # MCP server: configured decision tools by default
139
+ ```
140
 
141
+ Both serve the certified fp32 graph with the shipped policy, so the certificate below
142
+ applies to what they return. Adapters for eight agent frameworks, worked examples and
143
+ the full API reference are in the package repository, with a docs site.
144
 
145
+ ### Transformers mode
146
+
147
+ With no `mimirai` install (tested `transformers==5.17`):
148
+
149
+ ```python
150
+ from transformers import AutoModel, AutoTokenizer
151
+
152
+ model = AutoModel.from_pretrained(
153
+ "Mythologic/MIMIR-1", subfolder="transformers", trust_remote_code=True
154
  )
155
+ tokenizer = AutoTokenizer.from_pretrained("Mythologic/MIMIR-1", subfolder="transformers")
156
+ outputs = model(chunk_ids, chunk_mask, ...) # the 21 graph inputs, in order
157
+ outputs.utilities # [4 depths, records, candidates]: every depth's readouts
158
  ```
159
 
160
+ Load plus forward on pre-encoded batches only: text handling, calibration, the server
161
+ and MCP stay in `mimirai`. The staged modelling code holds the inference-only head
162
+ forward β€” no loss, no training machinery β€” the same computation the shipped `model.onnx`
163
+ already carries.
164
 
165
+ ## Evidence
166
 
167
  Head-to-head against Laya (`convaiinnovations/laya`) and GLiNER2.5-Decide
168
  (`fastino/GLiNER2.5-Decide`), each run by us on identical records with paired bootstrap
 
186
  "none of the listed options" on 1,792 of 2,000 records (mean abstain mass 0.656); forced
187
  to pick among the six emotions it scores 0.595, against Laya's 0.589.
188
 
189
+ ## Certificate
 
 
 
 
 
190
 
191
+ The fp32 policy ships selective thresholds proven on 95,550 held-out records at four risk
192
+ levels (origin `custom` in `policy/fp32.json`):
 
193
 
194
+ | Type | 1% risk: taken | Errors |
195
+ |---|---|---|
196
+ | binary | 6,781 of 19,319 (35.1%) | 47 (0.69%) |
197
+ | categorical | 19,947 of 54,728 (36.4%) | 166 (0.83%) |
198
+ | ranking | 1,441 of 3,863 (37.3%) | 5 (0.35%) |
199
+ | ordinal, multilabel | defer every record | β€” |
200
 
201
+ Read the table as a contract: at 1% risk the model acts on about a third of binary,
202
+ categorical and ranking calls and its error rate on the acted calls stays under the risk.
203
+ Thresholds were fit on the PyTorch model's outputs and transferred to the graph, whose
204
+ outputs match the model on every decision over 312 verification records (max relative
205
+ readout gap 6.5e-5, zero decision differences). The release also ships a 200-record
206
+ equivalence set, so any CPU hardware replays the graph and must reproduce every shipped
207
+ decision. The certified configuration is CPU, ONNX Runtime 1.30.0. Other runtimes
208
+ calibrate their own policy from their own labels:
209
 
210
  ```python
211
+ from mimir import Mimir
212
+ from mimir.core.labels import LabelledDecision
213
+ from mimir.runtime.calibrate import calibrate
214
 
215
+ model = Mimir.from_pretrained("Mythologic/MIMIR-1")
216
+ labelled: list[LabelledDecision] = [...] # your context/decision/label triples
217
+ policy = calibrate(model, labelled, risk=0.01, confidence=0.95)
 
 
 
218
  ```
219
 
220
+ The fp16 graph ships without a policy; certify it the same way.
221
+
222
+ ## Speed
223
+
224
+ About **1.7 decisions per second on an M4 CPU**, flat from 1 to 32 concurrent clients β€”
225
+ the batching absorbs concurrency rather than queueing it. GPU throughput is not measured
226
+ in this release.
227
 
228
  ## Architecture
229
 
 
243
 
244
  Training data and procedure are private.
245
 
246
+ ## FAQ
247
 
248
+ **Why is DAIR Emotion 0.080?**
249
+ Because the model refuses to guess: "none of the listed options" on 1,792 of 2,000
250
+ records. Forced to pick, it scores 0.595 β€” above both competitors. If your pipeline
251
+ needs a label on every row, read the argmax over the options; if it needs honesty, read
252
+ the abstention.
253
 
254
+ **What do I do with ABSTAINED and DEFERRED?**
255
+ Route them to a person or a stronger check. Pipelines that treat every call as an answer
256
+ turn refusals into someone else's silent default.
257
 
258
+ **Can I use a GPU?**
259
+ Yes, with the fp16 graph β€” but it ships without a policy, so calibrate your own or run
260
+ the equivalence set first. There is no CUDA certificate in this release.
261
 
262
+ **Why do ordinal and multilabel always defer?**
263
+ Their first testable thresholds fail on held-out data. Shipping them would be shipping an
264
+ unproven promise.
265
 
266
+ **How do I reproduce the numbers?**
267
+ The release carries a 200-record equivalence set: replay the graph on any CPU and every
268
+ shipped decision must match.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
 
270
  ## Files
271
 
 
287
  ## Links
288
 
289
  - Package: `mimirai` on PyPI (`https://pypi.org/project/mimirai/`), `from mimir import Mimir`
290
+ - Code: [abderahmane-ai/mimirai](https://github.com/abderahmane-ai/mimirai) on GitHub
291
 
292
  ## Licence
293