roudone commited on
Commit
4341c1a
·
verified ·
1 Parent(s): 2a4e414

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +132 -140
README.md CHANGED
@@ -1,3 +1,4 @@
 
1
  ---
2
  license: cc-by-nc-4.0
3
  language:
@@ -14,106 +15,100 @@ tags:
14
 
15
  # PabJev-4b
16
 
17
- 基础模型:**qwen3.5 4b**。本仓库发布 short150 best(**step 150**)的独立 merged 推理包,包含完整 backbone、FP32 pointer head、tokenizer/processor、双向注意力运行时、HTTP 服务、JevBench 数据与评测代码。
18
 
19
- > 这是 **decision/pooling 模型**,不是文本生成模型。它读取 `state + choice/noul/score questions`,返回每个候选的完整概率分布;不提供 `/v1/chat/completions`,也不应使用普通文本生成 pipeline 代替本包服务。
20
 
21
- ## 1. 模型与发布契约
22
-
23
- | 项目 | 发布值 |
24
- |---|---|
25
- | checkpoint | short150 best,step 150 |
26
- | 基础模型展示名称 | **qwen3.5 4b** |
27
- | backbone | merged、BF16、不量化,3 个 safetensors 分片 / 723 个张量 |
28
- | pointer head | FP32,4 个张量,head_dim=256 |
29
- | backbone 结构 | 32 层:8 层 full attention + 24 层 Gated DeltaNet linear attention |
30
- | 注意力语义 | full-attention 层双向;linear-attention/GDN 层保持因果 recurrent |
31
- | 读出 | 每个 `</opt>` 与最终 `<decide>` 的 hidden states,经 pointer head + softmax |
32
- | 温度 | **T=1.0**;独立校准后仍选择 raw,不应用拟合温度 |
33
- | 典型硬件 | 单张 NVIDIA A800-SXM4-80GB,tensor_parallel_size=1 |
34
- | 参考运行时 | Python 3.12、PyTorch 2.13.0+cu130、Transformers 5.19.0、vLLM 0.30.0 |
35
 
36
- 启动时 `vllm_plugin.py` 会断言 8+24 层结构以及 8 个 full-attention 层全部进入 `ENCODER_ONLY` 双向路径。为避免静默改变模型语义,服务固定:BF16、无 KV/权重量化、禁用 chunked prefill、禁用 prefix cache、`use_non_causal=true`、T=1。不同引擎或自行删除这些设置不保证得到本 README 的结果。
37
 
38
- ### 为什么是这个 checkpoint
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- 2026-10-24 最新的同协议 vLLM/JevBench 对比中,short150 step-150 的总 Accuracy、noul、Intelligence 和综合参考分均为候选第一,并被保留为当前在线服务。step-100 的 Calibration 更高,但那是“Calibration 优先”的另一选型口径。完整证据见 `reference_results/checkpoint_comparison/`。
41
 
42
- ## 2. 参考结果(JevBench 231 条)
43
 
44
- 单张 A800、并发 1、231/231 概率有效、0 invalid、0 timeout:
45
 
46
- | 指标 | 结果 |
47
  |---|---:|
48
- | **Overall Accuracy** | **0.883117(204/231)** |
49
- | choice Accuracy | 0.892086(124/139) |
50
- | noul Accuracy | 0.864865(64/74) |
51
- | score Accuracy(argmax) | 0.888889(16/18) |
52
  | easy / standard / hard / judge Accuracy | 1.000000 / 0.972222 / 0.808511 / 0.588235 |
53
- | Intelligence | **51.3356** |
54
- | Calibration | **90.7539** |
55
- | ECE / fidelity | 0.071062 / 0.886139 |
56
- | 请求阶段 wall time / QPS | 16.311 s / 14.1621 |
57
- | 相对训练日志的 Accuracy、三题型 Accuracy、Intelligence 差值 | 均为 0 |
58
 
59
- 并发 1 两次全量复测的预测标签与完整概率逐项一致,`probability_max_abs=0.0`。并发 4 的参考吞吐为 23.3873 QPS,但一道边界题翻转;严格精度回归请使用并发 1。详见 `docs/CALIBRATION.md`、`docs/VALIDATION.md` 和 `reference_results/`。
60
 
61
- ## 3. 文件布局
 
 
62
 
63
  ```text
64
  PabJev-4b/
65
- ├── backbone/ # BF16 config + 3 个 merged 权重分片 + processor 配置
66
  ├── tokenizer/ # tokenizer.json/config + chat template
67
  ├── pointer_head.safetensors # FP32 q/k pointer head
68
- ├── model_manifest.json # step、LoRA 血缘、dtype、attention、temperature 契约
69
- ├── service/ # 启动/请求/评测/自检,及 step-150 checkpoint_state.json
70
- ├── jevbench/ # 原 231 条 easy/hard/original JSONL
71
- ├── examples/ # 请求 JSON 与三条自定义 JSONL 示例
72
- ├── reference_results/ # 最佳模型实测与温度校准聚合结果
73
- ├── docs/ # 数据格式、校准与验收说明
74
- ├── wheels/ # 可选的同 ABI 预编译 kernel wheels + 许可证
75
  ├── requirements.txt / setup_env.sh
76
- └── SHA256SUMS # 发布文件完整性哈希
77
  ```
78
 
79
- merged 权重已自包含,**不需要**原基座目录、LoRA adapter、optimizer、scheduler、RNG 或训练仓库。根目录采用自定义 bundle 布局,请使用随包运行时,不要把根目录直接当作普通生成式 Transformers checkpoint。
80
 
81
- ## 4. 从 Hugging Face 下载
82
 
83
- 将 `YOUR_HF_USERNAME` 替换为实际发布账号:
84
 
85
  ```bash
86
- export HF_REPO_ID="YOUR_HF_USERNAME/PabJev-4b"
87
  python3.12 -m pip install "huggingface_hub==2.2.0"
88
  hf download "$HF_REPO_ID" --local-dir PabJev-4b
89
  cd PabJev-4b
90
  ```
91
 
92
- 也可使用 Git LFS:
93
-
94
- ```bash
95
- git lfs install
96
- git clone "https://huggingface.co/$HF_REPO_ID"
97
- cd PabJev-4b
98
- ```
99
 
100
- ## 5. 安装可复现环境
101
 
102
- ### 推荐配置
103
 
104
- - Linux x86_64;Python/CPython **3.12**;
105
- - NVIDIA 驱动支持 **CUDA 13.0**;参考 GPU 为 A800 80GB;
106
- - 至少约 10GB 模型文件空间,另需 Python/vLLM 依赖空间;
107
- - 安装过程需要联网下载 pip 依赖。随包 wheels 仅适配 CPython 3.12 + Linux x86_64 + PyTorch 2.13 + CUDA 13 ABI。
108
 
109
- 一条命令创建 `.venv`、安装固定版本、检查 GPU/权重并运行 CPU 自检:
110
 
111
  ```bash
112
  bash setup_env.sh
113
  source .venv/bin/activate
114
  ```
115
 
116
- 等效分步检查:
117
 
118
  ```bash
119
  python3.12 -m venv .venv
@@ -129,63 +124,65 @@ python service/verify_bundle.py --full
129
  python service/selftest.py
130
  ```
131
 
132
- `verify_bundle.py --full` 会检查 3 个分片及 index/header、723 个 backbone 张量、4 个 FP32 pointer 张量、tokenizer/processor、step-150 和 8+24 双向注意力契约,并核对核心文件 SHA256。
133
 
134
- 若在另一 ABI 上从源码构建 kernel,可尝试:
135
 
136
  ```bash
137
  USE_BUNDLED_WHEELS=0 bash setup_env.sh
138
  ```
139
 
140
- 这需要兼容的 nvcc/编译工具链;不同 CUDA、GPU、kernel 或依赖版本的数值与性能不保证一致。不要用量化或降低精度来强行复现参考分数。
141
 
142
- ## 6. 部署模型
 
 
143
 
144
- 在包根目录、已激活环境后执行:
145
 
146
  ```bash
147
  GPU_ID=0 bash service/start.sh
148
  ```
149
 
150
- 默认端点:
151
 
152
- - 业务 API:`http://127.0.0.1:18100/v1/systemone`(`/predict` 为别名);
153
- - 健康检查:`http://127.0.0.1:18100/health`;
154
- - 内部 vLLM pooling:`127.0.0.1:30000`,只监听本机,不应直接暴露。
155
 
156
- 启动会验证权重,启动 vLLM 与 SystemOne API,执行带完整概率的 smoke test,并对短文本、长文本、score 和多问题路径做 warmup;无需重新合并权重。常用参数:
157
 
158
  ```bash
159
  GPU_ID=0 \
160
  JEV_PORT=18100 VLLM_PORT=30000 \
161
- GPU_UTIL=0.85 MAX_NUM_SEQS=64 MAX_BATCHED_TOKENS=32768 \
162
  bash service/start.sh
163
  ```
164
 
165
- - `GPU_ID` 只能是一张卡;复现参考结果使用空闲 80GB A800 和默认值;
166
- - `JEV_HEAD_DEVICE` 默认 cuda,pointer head 以 FP32 计算;
167
- - `logs/vllm.log`、`logs/server.log`、`run/startup.json`、`run/smoke.json` 用于排障;
168
- - 若端口已属于其他服务,脚本会拒绝启动,不会把它冒充成本模型,也不会 kill 其他目录的服务。
169
 
170
- 停止本包服务;自定义端口时要传入相同端口:
171
 
172
  ```bash
173
  bash service/stop.sh
174
- # 或
175
  JEV_PORT=18102 VLLM_PORT=30002 bash service/stop.sh
176
  ```
177
 
178
- 需要监听外部网卡时:
179
 
180
  ```bash
181
  JEV_HOST=0.0.0.0 GPU_ID=0 bash service/start.sh
182
  ```
183
 
184
- **服务本身没有鉴权。** 公网部署请自行增加 TLS、Bearer/OAuth 鉴权、请求限流、网络策略和反向代理;不要暴露内部 vLLM 端口。
185
 
186
- ## 7. 请求模型
187
 
188
- ### curl
189
 
190
  ```bash
191
  curl -sS -X POST http://127.0.0.1:18100/v1/systemone \
@@ -193,7 +190,7 @@ curl -sS -X POST http://127.0.0.1:18100/v1/systemone \
193
  -d @examples/choice.json
194
  ```
195
 
196
- 三种题型、多问题请求:
197
 
198
  ```bash
199
  curl -sS -X POST http://127.0.0.1:18100/v1/systemone \
@@ -201,7 +198,7 @@ curl -sS -X POST http://127.0.0.1:18100/v1/systemone \
201
  -d @examples/all_types.json
202
  ```
203
 
204
- ### Python
205
 
206
  ```bash
207
  python service/request.py examples/choice.json
@@ -209,7 +206,7 @@ python service/request.py examples/all_types.json \
209
  --endpoint http://127.0.0.1:18100/v1/systemone
210
  ```
211
 
212
- 响应示例(数值仅为参考,字段结构不变):
213
 
214
  ```json
215
  {
@@ -218,7 +215,10 @@ python service/request.py examples/all_types.json \
218
  "move": {
219
  "type": "choice",
220
  "choice": "left",
221
- "probabilities": {"left": 0.9999983, "forward": 0.0000017}
 
 
 
222
  }
223
  },
224
  "usage": {
@@ -229,36 +229,38 @@ python service/request.py examples/all_types.json \
229
  }
230
  ```
231
 
232
- ### 请求 schema 与限制
233
 
234
  ```json
235
  {
236
  "model": "PabJev-4b",
237
- "state": "文本,或可渲染的 JSON 内容",
238
  "questions": {
239
  "question_id": {
240
  "type": "choice | noul | score",
241
- "instructions": "问题指令",
242
- "criteria": "按题型填写"
243
  }
244
  }
245
  }
246
  ```
247
 
248
- | type | criteria | 主要返回字段 |
249
  |---|---|---|
250
- | choice | 对象,`{候选名: 说明}` | `choice` 与每个候选的 `probabilities` |
251
- | noul | 可省略;或仅含 `false`/`true` | `noul=P(true)`,以及 false/true 完整概率 |
252
- | score | 有序数组,至少 2 档 | 从 0 开始的期望档位 `score`、`legend`、各档概率 |
253
 
254
- - 每次请求 1–16 个问题;多问题会分别展开 state+question,再在一次请求中返回;
255
- - state 上限 8192 tokens;完整单行上限 12288;一次请求展开总上限 32768;
256
- - 可选单图 PNG/JPEG 输入,单图请求限一个问题;图片最大 8MiB、16MP、1024 visual tokens;远程客户端建议使用 base64 data URI,服务器本地路径仅在本机有效;
257
- - 不支持文本生成、`think_mode` 或训练字段;非法输入返回 422 JSON 错误。
258
 
259
- ## 8. 跑测 JevBench
260
 
261
- 服务启动后,在包根目录执行:
 
 
262
 
263
  ```bash
264
  python service/evaluate.py \
@@ -266,13 +268,9 @@ python service/evaluate.py \
266
  --out outputs/jevbench.json
267
  ```
268
 
269
- 默认读取包内 `jevbench/{easy,hard,original}.jsonl`,共 231 条,使用与训练一致的 scoring id 和 113/118 pseudo-sealed 划分。快速检查链路:
270
-
271
- ```bash
272
- python service/evaluate.py --max-items 2 --out outputs/smoke_eval.json
273
- ```
274
 
275
- 测试外部同布局的 JevBench:
276
 
277
  ```bash
278
  python service/evaluate.py \
@@ -282,7 +280,7 @@ python service/evaluate.py \
282
  --out outputs/jevbench.external.json
283
  ```
284
 
285
- 吞吐测试:
286
 
287
  ```bash
288
  python service/evaluate.py \
@@ -290,9 +288,9 @@ python service/evaluate.py \
290
  --out outputs/jevbench.c4.json
291
  ```
292
 
293
- 输出包括总体/题型/难度/family/tier Accuracy、Intelligence、Calibration、ECE、fidelity、reliability bins、延迟/QPS 和逐题完整概率。另写 `*.rows.jsonl`。每次建议新文件名;评测没有样本级 resume,同一 `--out` 会原子替换旧文件。
294
 
295
- 复测并比较:
296
 
297
  ```bash
298
  python service/evaluate.py --concurrency 1 --out outputs/jevbench.repeat.json
@@ -301,9 +299,11 @@ python service/compare_results.py \
301
  --out outputs/jevbench.compare.json
302
  ```
303
 
304
- ## 9. 换成其他同格式数据
 
 
305
 
306
- 若文件是 `my_data/test.jsonl`,`--tiers` 填文件 basename `test`:
307
 
308
  ```bash
309
  python service/evaluate.py \
@@ -314,7 +314,7 @@ python service/evaluate.py \
314
  --out outputs/test.json
315
  ```
316
 
317
- 直接跑包内三条 choice/noul/score 示例:
318
 
319
  ```bash
320
  python service/evaluate.py \
@@ -323,42 +323,34 @@ python service/evaluate.py \
323
  --out outputs/custom.json
324
  ```
325
 
326
- 多个文件使用 `--tiers dev,test`。必需字段为 `id/state/question/expected`;choice 的 expected 是候选键,noul 是 yes/no 或 true/false,score 是从 0 开始的档位索引。完整 schema、难度映射、sealed/equating 和输出说明见 **[docs/DATA_FORMAT.md](docs/DATA_FORMAT.md)**。
327
-
328
- 原 JevBench 复测不要加 `--no-pseudo-sealed`;普通自定义数据建议加上。其他目录即使恰好有 231 条,也不会误套原 JevBench 的训练 parity。
329
-
330
- ## 10. 温度校准结果
331
 
332
- **最终线上温度是 1.0。** 独立校准曾拟合出 global `T=1.27782223`、choice `1.43393793`、noul `1.27202315`、score `0.99092258`,但这些候选均未部署:它们虽改善混合 select NLL,却使 Brier 和 Calibration 退化,未通过“三项均不退化”的选择规则。
333
 
334
- | 校准 select(domain-macro) | Accuracy | NLL ↓ | Brier ↓ | ECE ↓ | Calibration ↑ |
335
- |---|---:|---:|---:|---:|---:|
336
- | **raw T=1(最终)** | 0.928301 | 0.225644 | **0.105183** | **0.023519** | **95.4508** |
337
- | global | 0.928301 | 0.217776 | 0.106195 | 0.026693 | 95.0431 |
338
- | per-type | 0.928301 | **0.215359** | 0.106267 | 0.027746 | 94.9723 |
339
 
340
- 最终 raw test:Accuracy=0.928121、NLL=0.187029、Brier=0.090812、ECE=0.017322、Calibration=96.1804。该测试集与 231 条 JevBench 不同,不能混为一项指标。完整原因、domain 差异、reliability bins 和文件索引见 **[docs/CALIBRATION.md](docs/CALIBRATION.md)**。
341
 
342
- ## 11. 上传到 Hugging Face
343
 
344
- 先检查发布文件,再上传目录内容。`YOUR_HF_USERNAME` 必须替换;不会自动执行上传:
345
 
346
- ```bash
347
- cd PabJev-4b
348
- sha256sum --check SHA256SUMS --quiet
349
- python service/verify_bundle.py --full
 
350
 
351
- export HF_REPO_ID="YOUR_HF_USERNAME/PabJev-4b"
352
- hf upload "$HF_REPO_ID" . --repo-type model
353
- ```
354
 
355
- `.gitignore` 用于排除 `.venv`、缓存、运行日志、PID 和本地新生成的 `outputs/`;当前 `hf upload` 的 preupload 流程会应用这些规则。模型 safetensors、tokenizer.json 和 wheels 的 LFS 规则见 `.gitattributes`。上传前请确认账号有权以本许可证公开分享权重。
356
 
357
- ## 12. 许可证与限制
358
 
359
- - **模型权重及其衍生权重:CC BY-NC 4.0,仅限非商业用途。** 完整文本在 `LICENSE`,上游署名与商业授权说明原样保存在 `NOTICE`;商用需要另行取得授权。
360
- - 本包服务、评测和 vendored runtime 代码:Apache-2.0,见 `licenses/Apache-2.0` 与 `third_party/`。
361
- - 随包 JevBench 数据:逐行 provenance 标注 MIT,见 `jevbench/LICENSE` 和 `NOTICE.md`。
362
- - 预编译 wheels:各自许可证和 AUTHORS 位于 `wheels/licenses/`。
363
 
364
- 本结果只证明给定 JevBench、固定环境和当前 checkpoint 的表现,不代表所有数据分布都优于其他 checkpoint。不同 GPU/kernel/批组成可能产生局部 BF16 差异;参考精度以并发 1 为准。公开服务前还应评估输入内容安全、访问控制、数据隐私和你的具体许可证义务。
 
 
1
+ ```markdown
2
  ---
3
  license: cc-by-nc-4.0
4
  language:
 
15
 
16
  # PabJev-4b
17
 
18
+ Base Model: **qwen3.5 4b**. This repository contains the complete backbone, FP32 pointer head, tokenizer/processor, bidirectional attention runtime, HTTP inference service, JevBench evaluation dataset, and evaluation harnesses.
19
 
20
+ > This is a **decision/pooling model**, not a generative language model. It takes `state + choice/noul/score questions` as input and returns complete probability distributions over candidate options. It does not expose a `/v1/chat/completions` endpoint and should **not** be used within standard autoregressive text generation pipelines.
21
 
22
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ ## 1. Model Specifications & Release Contract
25
 
26
+ | Item | Specification |
27
+ |---|---|
28
+ | Checkpoint | short150 best (step 150) |
29
+ | Base Model Identifier | **qwen3.5 4b** |
30
+ | Backbone | Merged, BF16, unquantized, 3 safetensors shards / 723 tensors |
31
+ | Pointer Head | FP32, 4 tensors, `head_dim=256` |
32
+ | Backbone Architecture | 32 layers: 8 full-attention layers + 24 Gated DeltaNet linear-attention layers |
33
+ | Attention Semantics | Full-attention layers are bidirectional; linear-attention/GDN layers remain causal/recurrent |
34
+ | Readout Strategy | Hidden states extracted at each `</opt>` and final `<decide>`, routed through pointer head + softmax |
35
+ | Temperature | **T=1.0**; retained raw after calibration (fitted temperatures rejected) |
36
+ | Reference Hardware | 1× NVIDIA A800-SXM4-80GB, `tensor_parallel_size=1` |
37
+ | Reference Runtime | Python 3.12, PyTorch 2.13.0+cu130, Transformers 5.19.0, vLLM 0.30.0 |
38
+
39
+ At startup, `vllm_plugin.py` verifies the 8+24 layer architecture and asserts that all 8 full-attention layers enter the `ENCODER_ONLY` bidirectional path. To prevent silent semantic drift, the service enforces: BF16 precision, no KV/weight quantization, chunked prefill disabled, prefix caching disabled, `use_non_causal=true`, and T=1.0. Alternative engines or modified runtime configurations will not guarantee parity with this README.
40
 
41
+ ---
42
 
43
+ ## 2. Reference Results (JevBench - 231 Items)
44
 
45
+ Tested on a single A800, concurrency 1, 231/231 valid probabilities, 0 invalid requests, 0 timeouts:
46
 
47
+ | Metric | Score |
48
  |---|---:|
49
+ | **Overall Accuracy** | **0.883117 (204/231)** |
50
+ | choice Accuracy | 0.892086 (124/139) |
51
+ | noul Accuracy | 0.864865 (64/74) |
52
+ | score Accuracy (argmax) | 0.888889 (16/18) |
53
  | easy / standard / hard / judge Accuracy | 1.000000 / 0.972222 / 0.808511 / 0.588235 |
54
+ | ECE / Fidelity | 0.071062 / 0.886139 |
55
+ | Request-phase wall time / QPS | 16.311 s / 14.1621 |
56
+ | Discrepancy vs. Training Logs (Overall, 3-Type Acc, Intelligence) | Exact match (0 delta) |
 
 
57
 
58
+ Across two full evaluations at concurrency 1, predicted labels and probability distributions match identically (`probability_max_abs=0.0`). At concurrency 4, reference throughput reaches 23.3873 QPS, though a single boundary case flips; strict benchmark reproduction requires concurrency 1. See `docs/CALIBRATION.md`, `docs/VALIDATION.md`, and `reference_results/` for details.
59
 
60
+ ---
61
+
62
+ ## 3. Repository Layout
63
 
64
  ```text
65
  PabJev-4b/
66
+ ├── backbone/ # BF16 config + 3 merged weight shards + processor configuration
67
  ├── tokenizer/ # tokenizer.json/config + chat template
68
  ├── pointer_head.safetensors # FP32 q/k pointer head
69
+ ├── model_manifest.json # Step metadata, LoRA lineage, dtype, attention & temperature contract
70
+ ├── service/ # Startup, client, evaluation, selftest, and step-150 checkpoint_state.json
71
+ ├── jevbench/ # 231 evaluation items across easy/hard/original JSONL files
72
+ ├── examples/ # Request JSON and three custom JSONL examples
73
+ ├── reference_results/ # Baseline validation and temperature calibration artifacts
74
+ ├── docs/ # Specifications for data format, calibration, and validation
75
+ ├── wheels/ # Optional pre-compiled kernel wheels matching ABI + licenses
76
  ├── requirements.txt / setup_env.sh
77
+ └── SHA256SUMS # Cryptographic release checksums
78
  ```
79
 
80
+ The merged weights are self-contained: **no** upstream base weights, LoRA adapters, optimizer states, scheduler states, RNG states, or external training codebases are required. This bundle follows a custom runtime layout—please use the included serving stack rather than standard Hugging Face pipeline loaders.
81
 
82
+ ---
83
 
84
+ ## 4. Download from Hugging Face
85
 
86
  ```bash
87
+ export HF_REPO_ID="roudone/PabJev-4b"
88
  python3.12 -m pip install "huggingface_hub==2.2.0"
89
  hf download "$HF_REPO_ID" --local-dir PabJev-4b
90
  cd PabJev-4b
91
  ```
92
 
93
+ ---
 
 
 
 
 
 
94
 
95
+ ## 5. Environment Setup & Verification
96
 
97
+ ### Recommended Environment
98
 
99
+ - Linux x86_64; Python/CPython **3.12**
100
+ - NVIDIA Driver compatible with **CUDA 13.0**; target GPU: A800 80GB
101
+ - At least 10GB disk space for model weights, plus additional space for dependencies
102
+ - Installation requires internet access. The bundled wheels target `CPython 3.12 + Linux x86_64 + PyTorch 2.13 + CUDA 13 ABI`.
103
 
104
+ Automated setup (creates `.venv`, installs locked dependencies, checks GPU/weights, and executes CPU selftests):
105
 
106
  ```bash
107
  bash setup_env.sh
108
  source .venv/bin/activate
109
  ```
110
 
111
+ Equivalent manual setup:
112
 
113
  ```bash
114
  python3.12 -m venv .venv
 
124
  python service/selftest.py
125
  ```
126
 
127
+ `verify_bundle.py --full` inspects the 3 shards, index/header, 723 backbone tensors, 4 FP32 pointer tensors, tokenizer/processor configs, step-150 metadata, 8+24 bidirectional attention assertions, and core SHA256 checksums.
128
 
129
+ To build kernels from source for other ABIs:
130
 
131
  ```bash
132
  USE_BUNDLED_WHEELS=0 bash setup_env.sh
133
  ```
134
 
135
+ *Note: Requires compatible nvcc/build tools. Numerical behavior and latency across different CUDA versions, GPUs, custom kernels, or dependency variations may deviate from the reference baseline. Do not apply quantization or lower precision when aiming to reproduce reference metrics.*
136
 
137
+ ---
138
+
139
+ ## 6. Serving & Deployment
140
 
141
+ Activate the environment from the repository root:
142
 
143
  ```bash
144
  GPU_ID=0 bash service/start.sh
145
  ```
146
 
147
+ Default endpoints:
148
 
149
+ - **Inference API**: `http://127.0.0.1:18100/v1/systemone` (alias: `/predict`)
150
+ - **Health Check**: `http://127.0.0.1:18100/health`
151
+ - **Internal vLLM Pooling**: `127.0.0.1:30000` (loopback only, do not expose externally)
152
 
153
+ The startup script verifies weights, starts vLLM and the SystemOne API, runs a full-distribution smoke test, and warms up short-context, long-context, score, and multi-question paths. Common runtime options:
154
 
155
  ```bash
156
  GPU_ID=0 \
157
  JEV_PORT=18100 VLLM_PORT=30000 \
158
+ GPU_UTIL=0.92 MAX_NUM_SEQS=64 MAX_BATCHED_TOKENS=32768 \
159
  bash service/start.sh
160
  ```
161
 
162
+ - `GPU_ID` must specify a single card; reference numbers are obtained on an idle 80GB A800.
163
+ - `JEV_HEAD_DEVICE` defaults to `cuda`; the pointer head runs in FP32.
164
+ - Inspect `logs/vllm.log`, `logs/server.log`, `run/startup.json`, and `run/smoke.json` for troubleshooting.
165
+ - The startup script checks ports before binding; it will not overwrite or kill external processes.
166
 
167
+ To stop the service (pass custom ports if overridden):
168
 
169
  ```bash
170
  bash service/stop.sh
171
+ # or
172
  JEV_PORT=18102 VLLM_PORT=30002 bash service/stop.sh
173
  ```
174
 
175
+ To expose externally:
176
 
177
  ```bash
178
  JEV_HOST=0.0.0.0 GPU_ID=0 bash service/start.sh
179
  ```
180
 
181
+ ---
182
 
183
+ ## 7. Inference & API Usage
184
 
185
+ ### Via cURL
186
 
187
  ```bash
188
  curl -sS -X POST http://127.0.0.1:18100/v1/systemone \
 
190
  -d @examples/choice.json
191
  ```
192
 
193
+ Multi-question query covering all three supported types:
194
 
195
  ```bash
196
  curl -sS -X POST http://127.0.0.1:18100/v1/systemone \
 
198
  -d @examples/all_types.json
199
  ```
200
 
201
+ ### Via Python
202
 
203
  ```bash
204
  python service/request.py examples/choice.json
 
206
  --endpoint http://127.0.0.1:18100/v1/systemone
207
  ```
208
 
209
+ Example response (probabilities are illustrative; JSON schema is fixed):
210
 
211
  ```json
212
  {
 
215
  "move": {
216
  "type": "choice",
217
  "choice": "left",
218
+ "probabilities": {
219
+ "left": 0.9999983,
220
+ "forward": 0.0000017
221
+ }
222
  }
223
  },
224
  "usage": {
 
229
  }
230
  ```
231
 
232
+ ### Request Schema & Constraints
233
 
234
  ```json
235
  {
236
  "model": "PabJev-4b",
237
+ "state": "Text or stringified JSON payload",
238
  "questions": {
239
  "question_id": {
240
  "type": "choice | noul | score",
241
+ "instructions": "Instruction prompt",
242
+ "criteria": "Per-type criteria specification"
243
  }
244
  }
245
  }
246
  ```
247
 
248
+ | Type | Criteria Format | Key Response Fields |
249
  |---|---|---|
250
+ | `choice` | Object mapping candidate names to descriptions: `{candidate: description}` | Selected `choice` and full `probabilities` distribution |
251
+ | `noul` | Optional, or limited to `false`/`true` keys | Float scalar `noul` ($P(\text{true})$), plus `false`/`true` probabilities |
252
+ | `score` | Ordered array of criteria labels (minimum 2 buckets) | Expected bucket index `score` (0-indexed), `legend`, and per-bucket probabilities |
253
 
254
+ - **Batching per request**: 1 to 16 questions. Multi-question requests expand `state + question` branches and aggregate them into a single response.
255
+ - **Token Limits**: `state` ≤ 8,192 tokens; full single branch ≤ 12,288 tokens; expanded total tokens per batch ≤ 32,768.
256
+ - **Multimodal (Vision)**: Supports single PNG/JPEG input per request, limited to a single question. Image limits: 8 MiB, 16 MP, 1,024 visual tokens. Use base64 data URIs for remote requests; local file paths only resolve locally on the server.
257
+ - **Unsupported Features**: Free-form generation, `think_mode`, and autoregressive completion parameters are rejected with HTTP 422.
258
 
259
+ ---
260
 
261
+ ## 8. JevBench Evaluation
262
+
263
+ Once the service is active, run the benchmark from the repository root:
264
 
265
  ```bash
266
  python service/evaluate.py \
 
268
  --out outputs/jevbench.json
269
  ```
270
 
271
+ By default, this evaluates the included 231 items across `jevbench/{easy,hard,original}.jsonl`, applying the training-consistent scoring IDs and 113/118 pseudo-sealed split mapping.
 
 
 
 
272
 
273
+ Evaluate an external JevBench directory:
274
 
275
  ```bash
276
  python service/evaluate.py \
 
280
  --out outputs/jevbench.external.json
281
  ```
282
 
283
+ Throughput testing:
284
 
285
  ```bash
286
  python service/evaluate.py \
 
288
  --out outputs/jevbench.c4.json
289
  ```
290
 
291
+ Evaluation outputs aggregate accuracy across tier/family/type, Intelligence, Calibration, ECE, Fidelity, reliability diagram bins, latency/QPS, and per-item outputs saved alongside `*.rows.jsonl`. New runs overwrite `--out` atomically.
292
 
293
+ Reproducibility comparison check:
294
 
295
  ```bash
296
  python service/evaluate.py --concurrency 1 --out outputs/jevbench.repeat.json
 
299
  --out outputs/jevbench.compare.json
300
  ```
301
 
302
+ ---
303
+
304
+ ## 9. Evaluating Custom Datasets
305
 
306
+ For custom datasets (e.g., `my_data/test.jsonl`), set `--tiers` to match the file basename (`test`):
307
 
308
  ```bash
309
  python service/evaluate.py \
 
314
  --out outputs/test.json
315
  ```
316
 
317
+ Evaluate the bundled custom examples:
318
 
319
  ```bash
320
  python service/evaluate.py \
 
323
  --out outputs/custom.json
324
  ```
325
 
326
+ Multiple tiers can be passed as comma-separated values: `--tiers dev,test`. Required row schema includes `id`, `state`, `question`, and `expected` (choice candidate key, boolean string `yes`/`no` or `true`/`false`, or integer bucket index). For complete specifications, see **[docs/DATA_FORMAT.md](docs/DATA_FORMAT.md)**.
 
 
 
 
327
 
328
+ Do **not** use `--no-pseudo-sealed` when replicating original JevBench splits. Always include `--no-pseudo-sealed` for generic custom datasets.
329
 
330
+ ---
 
 
 
 
331
 
332
+ ## 10. Temperature Calibration
333
 
334
+ **The deployed serving temperature is fixed at $T = 1.0$.**
335
 
336
+ Post-training calibration sweeps fitted candidate values of global $T=1.2778$, choice $T=1.4339$, noul $T=1.2720$, and score $T=0.9909$. However, these candidates were rejected: while they reduced validation NLL, they degraded Brier score and overall Calibration metrics, failing the strict "no-regression across all three metrics" deployment rule.
337
 
338
+ | Calibration Candidate (Domain-Macro) | Accuracy | NLL ↓ | Brier ↓ | ECE ↓ | Calibration ↑ |
339
+ |---|---:|---:|---:|---:|---:|
340
+ | **Raw $T=1.0$ (Deployed)** | **0.928301** | 0.225644 | **0.105183** | **0.023519** | **95.4508** |
341
+ | Global Scaling | 0.928301 | 0.217776 | 0.106195 | 0.026693 | 95.0431 |
342
+ | Per-Type Scaling | 0.928301 | **0.215359** | 0.106267 | 0.027746 | 94.9723 |
343
 
344
+ On the held-out test split, raw test scores were: Accuracy=0.928121, NLL=0.187029, Brier=0.090812, ECE=0.017322, Calibration=96.1804. *(Note: The calibration split is distinct from the 231-item JevBench evaluation set).* Complete calibration analysis and reliability diagrams are documented in **[docs/CALIBRATION.md](docs/CALIBRATION.md)**.
 
 
345
 
346
+ ---
347
 
348
+ ## 11. Licenses & Disclaimers
349
 
350
+ - **Model Weights & Derivative Weights**: **CC BY-NC 4.0 (Non-Commercial Use Only)**. Refer to `LICENSE` for the complete license text. Upstream attributions and commercial licensing instructions are preserved in `NOTICE`. Commercial deployment requires separate licensing.
351
+ - **Service Stack, Evaluation Harnesses, & Vendored Runtime**: **Apache-2.0**, provided under `licenses/Apache-2.0` and `third_party/`.
352
+ - **Bundled JevBench Dataset**: Line-by-line provenance provided under **MIT**, detailed in `jevbench/LICENSE` and `NOTICE.md`.
353
+ - **Precompiled Wheels**: Respective licenses and source origins are documented under `wheels/licenses/`.
354
 
355
+ *These benchmarks reflect performance exclusively on JevBench under the documented software/hardware stack and step-150 checkpoint; they do not imply uniform dominance across arbitrary domains. Floating-point variations in BF16 may occur across different GPU microarchitectures, kernel implementations, or dynamic batch compositions. Users must perform independent validation regarding safety, access controls, data governance, and license compliance before hosting public-facing endpoints.*
356
+ ```