helmo commited on
Commit
b04d205
·
verified ·
1 Parent(s): 10f9243

DecidaBERT-large-v2: model, inference code, eval results

Browse files
.eval_results/typed-decisions.yaml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - dataset:
2
+ id: LocalLLaMA/typed-decisions
3
+ task_id: accuracy
4
+ value: 0.7835
5
+ date: "2026-11-14"
6
+ source:
7
+ url: https://huggingface.co/datasets/LocalLLaMA/typed-decisions
8
+ name: "Typed Decisions benchmark, self-run with the benchmark scorer"
9
+ notes: "Model was fitted/fine-tuned on this benchmark's train split; not comparable with zero-shot rows."
10
+ - dataset:
11
+ id: LocalLLaMA/typed-decisions
12
+ task_id: kl_from_gold
13
+ value: 0.0861
14
+ date: "2026-11-14"
15
+ source:
16
+ url: https://huggingface.co/datasets/LocalLLaMA/typed-decisions
17
+ name: "Typed Decisions benchmark, self-run with the benchmark scorer"
18
+ notes: "Model was fitted/fine-tuned on this benchmark's train split; not comparable with zero-shot rows."
19
+ - dataset:
20
+ id: LocalLLaMA/typed-decisions
21
+ task_id: brier
22
+ value: 0.0473
23
+ date: "2026-11-14"
24
+ source:
25
+ url: https://huggingface.co/datasets/LocalLLaMA/typed-decisions
26
+ name: "Typed Decisions benchmark, self-run with the benchmark scorer"
27
+ notes: "Model was fitted/fine-tuned on this benchmark's train split; not comparable with zero-shot rows."
28
+ - dataset:
29
+ id: LocalLLaMA/typed-decisions
30
+ task_id: ece
31
+ value: 0.1435
32
+ date: "2026-11-14"
33
+ source:
34
+ url: https://huggingface.co/datasets/LocalLLaMA/typed-decisions
35
+ name: "Typed Decisions benchmark, self-run with the benchmark scorer"
36
+ notes: "Model was fitted/fine-tuned on this benchmark's train split; not comparable with zero-shot rows."
README.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: text-classification
5
+ base_model: answerdotai/ModernBERT-large
6
+ language:
7
+ - en
8
+ tags:
9
+ - decision-model
10
+ - system-one
11
+ - typed-decisions
12
+ - modernbert
13
+ - calibration
14
+ - probabilistic-classification
15
+ - long-context
16
+ datasets:
17
+ - LocalLLaMA/typed-decisions
18
+ ---
19
+
20
+ # DecidaBERT-large-v2
21
+
22
+ **A one-forward-pass decision model with an 8,192-token context.** It reads a piece of state and a set of typed
23
+ questions and returns a probability distribution for every question at once. No tokens are generated.
24
+
25
+ It takes the `POST /v1/systemone` request shape: `noul` (yes or no), `choice` (one of N labels) and `score` (an
26
+ ordered rubric). It is the successor of [DecidaBERT-large](https://huggingface.co/helmo/DecidaBERT-large).
27
+
28
+ ## Results
29
+
30
+ ### Typed Decisions test split (400 cases, 2,000 questions), scored as for DecidaBERT-large
31
+
32
+ A prediction is right when its top answer equals the gold label. Intervals are 95% Wilson intervals. Both models
33
+ were fitted on the benchmark's `train` split (**specialist mode**); the test split was never used for training,
34
+ calibration or choosing a checkpoint.
35
+
36
+ | question type | questions | DecidaBERT-large | **DecidaBERT-large-v2** | v2 95% interval | random guess |
37
+ |---|---|---|---|---|---|
38
+ | choice | 600 | 0.722 | **0.747** | 0.710 to 0.780 | 0.233 |
39
+ | score | 800 | 0.694 | **0.759** | 0.728 to 0.787 | 0.244 |
40
+ | yes/no (`noul`) | 600 | 0.830 | **0.868** | 0.839 to 0.893 | 0.500 |
41
+ | **all** | 2,000 | 0.743 (0.723 to 0.762) | **0.788** | **0.770 to 0.805** | |
42
+
43
+ For `score` questions v2 is within one level of the gold level 97.6% of the time (v1: 95.5%).
44
+
45
+ ### Benchmark metrics (the benchmark's own scorer)
46
+
47
+ | Accuracy ↑ | KL from gold ↓ | Brier ↓ | ECE ↓ |
48
+ |---|---|---|---|
49
+ | 0.7835 | 0.0861 | 0.0473 | 0.1435 |
50
+
51
+ The two accuracy figures differ only in how ties are read: the benchmark's scorer takes the most likely option of
52
+ the gold distribution, the table above takes the gold `label`. The test predictions are in
53
+ `eval/typed-decisions/predictions.jsonl` so both can be re-derived.
54
+
55
+ ### Confidence
56
+
57
+ `probabilities` is the raw distribution (the one scored above): it follows the gold distributions closely, which
58
+ are soft, so the top answer's probability reads low (mean 0.64 while the top answer is right 79% of the time).
59
+ Every answer therefore also carries a `confidence`: the top answer's probability after a per-type temperature
60
+ fitted on held-out `train` cases. On the test split its calibration error is **0.023** (raw: 0.144), so a
61
+ `confidence` of 0.8 means right about 80% of the time; use it for thresholds and routing.
62
+
63
+ ## How it works
64
+
65
+ - **Backbone:** [ModernBERT-large](https://huggingface.co/answerdotai/ModernBERT-large) (395M parameters, 28 layers),
66
+ bidirectional, context 8,192 tokens (v1: trained at 512, up to 2,048).
67
+ - **One pass for all questions:** the state is read once; every question and its options follow it in the same
68
+ sequence, so a request with many questions costs one forward pass, not one per question.
69
+ - **Readout:** a marker token per option (and one per yes/no question); three small heads (yes/no, choice, score)
70
+ map the marker states to scores; a softmax (or sigmoid) gives the distribution.
71
+ - **Training data:** decision records from multiple domains of IT and software work (below), balanced by design,
72
+ then the `train` split of LocalLLaMA/typed-decisions. A targeted weight edit was applied before the last stage.
73
+ **No test split of any benchmark was used for training.**
74
+
75
+ | Domain group | Records | Tasks |
76
+ |---|---|---|
77
+ | Gating and classification | 6,834 | 11 |
78
+ | Routing and selection | 6,834 | 9 |
79
+ | Agent control flow (go / no-go) | 6,833 | 9 |
80
+ | Ranking and scoring | 6,833 | 8 |
81
+ | Verification | 6,833 | 9 |
82
+ | Operational engineering | 6,833 | 14 |
83
+ | **Total** | **41,000** | **60** |
84
+ | LocalLLaMA/typed-decisions `train` | 1,000 | 4 workflows |
85
+
86
+ Coverage: 38 roles (developers, SREs, SOC analysts, IT technicians, architects and more), 48 settings and 24
87
+ formats (logs, diffs, alerts, tickets, agent traces, configs, metrics tables and more); 165,952 questions, of which
88
+ 44% yes/no, 30% choice and 26% score.
89
+
90
+ ## Files
91
+
92
+ | File | What it is |
93
+ |---|---|
94
+ | `model.safetensors`, `config.json` | encoder and decision heads (FP32), encoder config |
95
+ | `decision_config.json` | context and token budgets, confidence temperatures |
96
+ | `tokenizer.json`, `tokenizer_config.json` | tokenizer |
97
+ | `decidabert_v2/` | inference code |
98
+ | `decision_server.py` | a `/v1/systemone` server |
99
+ | `eval/typed-decisions/predictions.jsonl` | test-split predictions |
100
+
101
+ ## Usage
102
+
103
+ ```python
104
+ import sys
105
+ from huggingface_hub import snapshot_download
106
+
107
+ path = snapshot_download("helmo/DecidaBERT-large-v2")
108
+ sys.path.insert(0, path)
109
+ from decidabert_v2 import load
110
+
111
+ model = load(path)
112
+ answers = model.predict(
113
+ "Alert: 41 failed SSH logins for root from one external IP in 3 minutes, then one success.",
114
+ {
115
+ "disposition": {"type": "choice", "instructions": "How should the alert be handled?",
116
+ "criteria": {"close": "Benign, close it.", "investigate": "Open an investigation.",
117
+ "contain": "Isolate the host now."}},
118
+ "true_positive": {"type": "noul", "instructions": "Is this a real attack?"},
119
+ "severity": {"type": "score", "instructions": "How severe is it?", "criteria": ["Low", "Medium", "High", "Critical"]},
120
+ },
121
+ )
122
+ ```
123
+
124
+ ### `/v1/systemone` server
125
+
126
+ ```sh
127
+ pip install torch transformers safetensors fastapi uvicorn huggingface_hub
128
+ huggingface-cli download helmo/DecidaBERT-large-v2 --local-dir DecidaBERT-large-v2
129
+ cd DecidaBERT-large-v2 && PORT=8000 python decision_server.py
130
+ ```
131
+
132
+ ## Limits
133
+
134
+ - English only. Best when the state describes the situation in words; raw numbers are read less reliably.
135
+ - Fitted on the benchmark's `train` split: its numbers there belong with other fitted models, not zero-shot ones.
136
+ - The gold labels of the benchmark are a teacher model's averaged answers, so scores measure agreement with that
137
+ teacher.
config.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformers_version": "5.23.0",
3
+ "architectures": [
4
+ "ModernBertModel"
5
+ ],
6
+ "output_hidden_states": false,
7
+ "return_dict": true,
8
+ "dtype": "float32",
9
+ "chunk_size_feed_forward": 0,
10
+ "is_encoder_decoder": false,
11
+ "id2label": {
12
+ "0": "LABEL_0",
13
+ "1": "LABEL_1"
14
+ },
15
+ "label2id": {
16
+ "LABEL_0": 0,
17
+ "LABEL_1": 1
18
+ },
19
+ "problem_type": null,
20
+ "vocab_size": 50368,
21
+ "hidden_size": 1024,
22
+ "intermediate_size": 2624,
23
+ "num_hidden_layers": 28,
24
+ "num_attention_heads": 16,
25
+ "hidden_activation": "gelu",
26
+ "max_position_embeddings": 8192,
27
+ "initializer_range": 0.02,
28
+ "initializer_cutoff_factor": 2.0,
29
+ "norm_eps": 1e-05,
30
+ "norm_bias": false,
31
+ "pad_token_id": 50283,
32
+ "eos_token_id": 50282,
33
+ "bos_token_id": 50281,
34
+ "cls_token_id": 50281,
35
+ "sep_token_id": 50282,
36
+ "attention_bias": false,
37
+ "attention_dropout": 0.0,
38
+ "layer_types": [
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
+ "sliding_attention",
65
+ "sliding_attention",
66
+ "full_attention"
67
+ ],
68
+ "rope_parameters": {
69
+ "sliding_attention": {
70
+ "rope_type": "default",
71
+ "rope_theta": 10000.0
72
+ },
73
+ "full_attention": {
74
+ "rope_type": "default",
75
+ "rope_theta": 160000.0
76
+ }
77
+ },
78
+ "local_attention": 128,
79
+ "embedding_dropout": 0.0,
80
+ "mlp_bias": false,
81
+ "mlp_dropout": 0.0,
82
+ "decoder_bias": true,
83
+ "classifier_pooling": "mean",
84
+ "classifier_dropout": 0.0,
85
+ "classifier_bias": false,
86
+ "classifier_activation": "gelu",
87
+ "deterministic_flash_attn": false,
88
+ "sparse_prediction": false,
89
+ "sparse_pred_ignore_index": -100,
90
+ "tie_word_embeddings": true,
91
+ "global_attn_every_n_layers": 3,
92
+ "gradient_checkpointing": false,
93
+ "layer_norm_eps": 1e-05,
94
+ "model_type": "modernbert",
95
+ "position_embedding_type": "absolute",
96
+ "output_attentions": false
97
+ }
decidabert_v2/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .model import DecidaBERTv2, load
2
+
3
+ __all__ = ["DecidaBERTv2", "load"]
decidabert_v2/__pycache__/__init__.cpython-313.pyc ADDED
Binary file (302 Bytes). View file
 
decidabert_v2/__pycache__/model.cpython-313.pyc ADDED
Binary file (14.4 kB). View file
 
decidabert_v2/model.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """DecidaBERT-large-v2 inference: one state plus typed questions in, one probability distribution per question out,
2
+ from a single forward pass of a ModernBERT-large encoder (8,192-token context). No generated text.
3
+
4
+ from decidabert_v2 import load
5
+ model = load("helmo/DecidaBERT-large-v2") # or a local folder
6
+ model.predict(state, questions) # {qid: {"type", ..., "probabilities", "confidence"}}
7
+
8
+ Layout: [CLS] state [SEP] q1 [SEP] q2 [SEP] ... Each question is "<type> question: <instructions>" (plus yes/no
9
+ criteria when given), then a [MASK] marker read by the yes/no head, then for choice and score one [MASK] marker per
10
+ option or level followed by its text, read by the choice or score head. Every question is answered from the same
11
+ single read of the state. If a request is longer than the context, the end of the state is cut first.
12
+
13
+ `probabilities` are the model's raw distribution (the one scored on the typed-decisions benchmark). `confidence` is
14
+ the probability of the top answer after a per-type temperature fitted on held-out data, so that it tracks how often
15
+ the top answer is right (see decision_config.json).
16
+ """
17
+ from __future__ import annotations
18
+
19
+ import json
20
+ import math
21
+ import os
22
+ from typing import Any
23
+
24
+ import numpy as np
25
+ import torch
26
+ from torch import nn
27
+
28
+ TYPES = {"choice": 0, "score": 1}
29
+
30
+
31
+ def _question_text(q: dict) -> str:
32
+ ins = q.get("instructions", "")
33
+ ins = ins if isinstance(ins, str) else json.dumps(ins, ensure_ascii=False)
34
+ t = f"{q['type']} question: {ins}"
35
+ c = q.get("criteria")
36
+ if q["type"] == "noul" and isinstance(c, dict):
37
+ if c.get("true"):
38
+ t += f" | yes means: {c['true']}"
39
+ if c.get("false"):
40
+ t += f" | no means: {c['false']}"
41
+ return t
42
+
43
+
44
+ def _options(q: dict) -> tuple[list[str], list[str]]:
45
+ c = q.get("criteria")
46
+ if q["type"] == "choice":
47
+ if isinstance(c, list): # bare labels are accepted, as in the System One API
48
+ c = {str(x): "" for x in c}
49
+ return list(c), [f"{k.replace('_', ' ')}: {v}" if v else k.replace("_", " ") for k, v in c.items()]
50
+ if q["type"] == "score":
51
+ levels = list(c.values()) if isinstance(c, dict) else list(c)
52
+ return [str(i) for i in range(len(levels))], [f"level {i}: {v}" for i, v in enumerate(levels)]
53
+ return [], []
54
+
55
+
56
+ class Layout:
57
+ def __init__(self, tok, max_len: int, head_max: int, opt_max: int):
58
+ self.tok, self.max_len, self.head_max, self.opt_max = tok, max_len, head_max, opt_max
59
+ self.CLS, self.SEP, self.MASK, self.PAD = tok.cls_token_id, tok.sep_token_id, tok.mask_token_id, tok.pad_token_id
60
+
61
+ def _ids(self, text: str) -> list[int]:
62
+ return self.tok(text, add_special_tokens=False)["input_ids"]
63
+
64
+ def encode(self, state: Any, questions: dict) -> tuple[list[int], list, list, bool]:
65
+ state = state if isinstance(state, str) else json.dumps(state, ensure_ascii=False)
66
+ st = self._ids(state)
67
+ qs = []
68
+ for qid, q in questions.items():
69
+ keys, texts = _options(q)
70
+ qs.append({"qid": qid, "type": q["type"], "head": self._ids(" " + _question_text(q)), "keys": keys,
71
+ "opts": [self._ids(" " + t) for t in texts]})
72
+ cap = self.opt_max
73
+ while True:
74
+ qpart, marks = [], []
75
+ for q in qs:
76
+ ids = q["head"][:self.head_max]
77
+ qmark = len(qpart) + len(ids)
78
+ ids = ids + [self.MASK]
79
+ offs = []
80
+ for j in range(len(q["keys"])):
81
+ offs.append(len(qpart) + len(ids))
82
+ ids = ids + [self.MASK] + q["opts"][j][:cap]
83
+ ids = ids + [self.SEP]
84
+ marks.append((q, qmark, offs))
85
+ qpart += ids
86
+ room = self.max_len - 2 - len(qpart)
87
+ if room >= 256 or cap <= 8:
88
+ break
89
+ cap //= 2
90
+ state_ids = st[:max(0, room)]
91
+ base = 2 + len(state_ids)
92
+ ids = ([self.CLS] + state_ids + [self.SEP] + qpart)[:self.max_len]
93
+ noul, groups = [], []
94
+ for q, qmark, offs in marks:
95
+ if q["type"] == "noul":
96
+ if base + qmark < len(ids):
97
+ noul.append((base + qmark, q["qid"]))
98
+ elif offs and base + offs[-1] < len(ids):
99
+ groups.append(([base + o for o in offs], TYPES[q["type"]], q["qid"], q["keys"]))
100
+ return ids, noul, groups, len(state_ids) < len(st)
101
+
102
+
103
+ def _head(d: int) -> nn.Sequential:
104
+ return nn.Sequential(nn.Linear(d, d), nn.GELU(), nn.LayerNorm(d), nn.Linear(d, 1))
105
+
106
+
107
+ class DecidaBERTv2(nn.Module):
108
+ def __init__(self, encoder, layout: Layout, temperature: dict[str, float]):
109
+ super().__init__()
110
+ self.encoder, self.layout, self.temperature = encoder, layout, temperature
111
+ d = encoder.config.hidden_size
112
+ self.noul_head, self.choice_head, self.score_head = _head(d), _head(d), _head(d)
113
+
114
+ @torch.no_grad()
115
+ def predict(self, state: Any, questions: dict) -> dict[str, dict]:
116
+ """Answer every question about `state` in one forward pass (System One answer shape)."""
117
+ dev = next(self.parameters()).device
118
+ ids, noul, groups, truncated = self.layout.encode(state, questions)
119
+ x = torch.tensor([ids], device=dev)
120
+ h = self.encoder(input_ids=x, attention_mask=torch.ones_like(x)).last_hidden_state[0]
121
+ out: dict[str, dict] = {}
122
+ for pos, qid in noul:
123
+ z = float(self.noul_head(h[pos]).squeeze(-1))
124
+ p = 1 / (1 + math.exp(-z))
125
+ pc = 1 / (1 + math.exp(-z / self.temperature["noul"]))
126
+ out[qid] = {"type": "noul", "noul": p, "confidence": max(pc, 1 - pc)}
127
+ for poss, ty, qid, keys in groups:
128
+ hd = self.choice_head if ty == 0 else self.score_head
129
+ z = hd(h[poss]).squeeze(-1).float().cpu().numpy()
130
+ p = np.exp(z - z.max()); p /= p.sum()
131
+ zt = z / self.temperature["choice" if ty == 0 else "score"]
132
+ pt = np.exp(zt - zt.max()); pt /= pt.sum()
133
+ probs = {k: float(v) for k, v in zip(keys, p)}
134
+ if ty == 0:
135
+ out[qid] = {"type": "choice", "choice": keys[int(p.argmax())], "probabilities": probs, "confidence": float(pt.max())}
136
+ else:
137
+ legend = questions[qid]["criteria"]
138
+ legend = list(legend.values()) if isinstance(legend, dict) else list(legend)
139
+ out[qid] = {"type": "score", "score": float((np.arange(len(p)) * p).sum()), "probabilities": probs,
140
+ "legend": {str(i): str(c) for i, c in enumerate(legend)}, "confidence": float(pt.max())}
141
+ if truncated:
142
+ for a in out.values():
143
+ a["truncated_state"] = True
144
+ return out
145
+
146
+
147
+ def load(path: str = "helmo/DecidaBERT-large-v2", device: str | None = None) -> DecidaBERTv2:
148
+ """Load from a local folder or a Hugging Face repo id."""
149
+ from safetensors.torch import load_file
150
+ from transformers import AutoConfig, AutoModel, AutoTokenizer
151
+ if not os.path.isdir(path):
152
+ from huggingface_hub import snapshot_download
153
+ path = snapshot_download(path)
154
+ device = device or ("cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu")
155
+ dc = json.load(open(os.path.join(path, "decision_config.json")))
156
+ cfg = AutoConfig.from_pretrained(path)
157
+ enc = AutoModel.from_config(cfg, attn_implementation="sdpa")
158
+ tok = AutoTokenizer.from_pretrained(path)
159
+ m = DecidaBERTv2(enc, Layout(tok, dc["max_len"], dc["head_max_tokens"], dc["option_max_tokens"]), dc["confidence_temperature"])
160
+ missing, unexpected = m.load_state_dict(load_file(os.path.join(path, "model.safetensors")), strict=False)
161
+ assert not unexpected and not [k for k in missing if not k.startswith("layout")], (missing, unexpected)
162
+ return m.float().to(device).eval()
decision_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_len": 8192,
3
+ "head_max_tokens": 256,
4
+ "option_max_tokens": 96,
5
+ "confidence_temperature": {
6
+ "noul": 0.44,
7
+ "choice": 0.51,
8
+ "score": 0.38
9
+ },
10
+ "confidence_note": "per-type temperature applied only to the reported confidence (top answer), fitted on held-out train cases to the gold label; probabilities are left raw",
11
+ "readout": "one [MASK] marker per option (choice/score) and per yes/no question; heads noul/choice/score"
12
+ }
decision_server.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A minimal `POST /v1/systemone` server for DecidaBERT-large-v2.
2
+
3
+ pip install torch transformers safetensors fastapi uvicorn huggingface_hub
4
+ PORT=8000 python decision_server.py
5
+
6
+ POST /v1/systemone {"state": ..., "questions": {qid: {"type", "instructions", "criteria"}}}
7
+ POST /v1/systemone/batch {"requests": [ {"state", "questions"}, ... ]}
8
+ """
9
+ import os
10
+ import time
11
+
12
+ import uvicorn
13
+ from fastapi import FastAPI
14
+ from pydantic import BaseModel
15
+
16
+ from decidabert_v2 import load
17
+
18
+ MODEL = load(os.environ.get("MODEL_PATH", os.path.dirname(os.path.abspath(__file__))))
19
+ app = FastAPI(title="DecidaBERT-large-v2")
20
+
21
+
22
+ class Request(BaseModel):
23
+ state: object
24
+ questions: dict
25
+ model: str | None = None
26
+
27
+
28
+ class Batch(BaseModel):
29
+ requests: list[Request]
30
+ model: str | None = None
31
+
32
+
33
+ def _answer(r: Request) -> dict:
34
+ t0 = time.perf_counter()
35
+ answers = MODEL.predict(r.state, r.questions)
36
+ return {"model": "DecidaBERT-large-v2", "answers": answers, "latency_ms": round((time.perf_counter() - t0) * 1000, 1)}
37
+
38
+
39
+ @app.post("/v1/systemone")
40
+ def systemone(r: Request) -> dict:
41
+ return _answer(r)
42
+
43
+
44
+ @app.post("/v1/systemone/batch")
45
+ def batch(b: Batch) -> dict:
46
+ return {"responses": [_answer(r) for r in b.requests]}
47
+
48
+
49
+ if __name__ == "__main__":
50
+ uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8000)))
eval/typed-decisions/predictions.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33a6ad9d6a6a1007024983720b25b0385511b4acb523c4f7c87ab5afc410719a
3
+ size 1591778708
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "clean_up_tokenization_spaces": true,
4
+ "cls_token": "[CLS]",
5
+ "is_local": false,
6
+ "local_files_only": false,
7
+ "mask_token": "[MASK]",
8
+ "model_input_names": [
9
+ "input_ids",
10
+ "attention_mask"
11
+ ],
12
+ "model_max_length": 8192,
13
+ "pad_token": "[PAD]",
14
+ "sep_token": "[SEP]",
15
+ "tokenizer_class": "TokenizersBackend",
16
+ "unk_token": "[UNK]"
17
+ }