dsh-memu-memory 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/AGENTS.md +4 -1
  2. package/README.md +12 -16
  3. package/README.zh.md +13 -17
  4. package/docs/client-conventions.md +2 -0
  5. package/docs/contributing.md +7 -6
  6. package/docs/emotion-model-spec.md +2 -2
  7. package/docs/env-and-commands.md +63 -1
  8. package/docs/host-api.md +19 -0
  9. package/docs/memory-semantics.md +10 -1
  10. package/docs/troubleshooting.md +77 -3
  11. package/lib/activity-log.js +1 -1
  12. package/lib/binding-diagnostics.js +1 -1
  13. package/lib/client.js +223 -19
  14. package/lib/cycle.js +9 -1
  15. package/lib/embedding-catalog.js +416 -138
  16. package/lib/embedding-download.js +36 -11
  17. package/lib/freshness.js +97 -0
  18. package/lib/graph.js +244 -2
  19. package/lib/inject.js +218 -11
  20. package/lib/local-embedding-manager.js +3 -2
  21. package/lib/local-embedding-protocol.js +40 -3
  22. package/lib/local-embedding-worker.js +36 -6
  23. package/lib/local-vector-service.js +18 -4
  24. package/lib/memory.js +83 -17
  25. package/lib/memu.js +15 -7
  26. package/lib/private.js +25 -5
  27. package/lib/rpc.js +17 -3
  28. package/lib/salient-wake.js +402 -0
  29. package/lib/state.js +173 -1
  30. package/package.json +3 -2
  31. package/scripts/drive-session.mjs +864 -0
  32. package/scripts/mock-llm.mjs +903 -0
  33. package/scripts/simulate-injection.mjs +298 -0
  34. package/tests/client-render.test.mjs +69 -2
  35. package/tests/consolidation-fork.test.mjs +14 -1
  36. package/tests/drive-session.test.mjs +152 -0
  37. package/tests/embedding-catalog.test.mjs +116 -8
  38. package/tests/embedding-download.test.mjs +97 -2
  39. package/tests/embedding-runtime.test.mjs +21 -13
  40. package/tests/entity-merge.test.mjs +261 -0
  41. package/tests/fixtures/mock-llm/reply.txt +1 -0
  42. package/tests/freshness.test.mjs +140 -0
  43. package/tests/help-page.test.mjs +4 -4
  44. package/tests/injection-chain.test.mjs +176 -0
  45. package/tests/injection-rollback.test.mjs +230 -0
  46. package/tests/local-embedding-env.test.mjs +51 -0
  47. package/tests/local-embedding-manager.test.mjs +18 -0
  48. package/tests/local-embedding-protocol.test.mjs +28 -2
  49. package/tests/local-embedding-worker.test.mjs +94 -0
  50. package/tests/mock-llm.test.mjs +225 -0
  51. package/tests/open-loop-date.test.mjs +406 -0
  52. package/tests/salient-wake.test.mjs +362 -0
  53. package/tests/settings-plumbing.test.mjs +76 -0
  54. package/tests/sidebar.test.mjs +5 -1
  55. package/tests/simulate-injection.test.mjs +76 -0
  56. package/tests/stubs/dsh-schedule.js +105 -0
  57. package/tests/vector-profile.test.mjs +28 -4
  58. package/tests/webui-auth.test.mjs +4 -0
@@ -68,6 +68,247 @@ const BGE_COMMIT_TIME = '2025-07-22T11:41:37.000Z'
68
68
  const BAAI_REPO = 'BAAI/bge-small-zh-v1.5'
69
69
  const BAAI_POOLING_REVISION = '8399f11f8da998fe932df2684586c92024219d05'
70
70
 
71
+ // 核实证据(2026-11-02):两条新条目同样只走 ModelScope 直连(huggingface.co 超时、
72
+ // hf-mirror 重定向回 huggingface.co 后不可达)。revision 取仓库 HEAD commit;逐文件
73
+ // bytes/sha256 取自 ModelScope 文件清单,并与实际下载字节、图头解析结果复核一致。
74
+ const MINIML_REVISION = '5f19c574ce6bbb065d51869c525840f8a975dcc4'
75
+ const MINIML_COMMIT_TIME = '2025-07-22T19:48:27.000Z'
76
+ const MINIML_POOLING_REVISION = '524b52f1d626e9a5a16462e141fc9dffc25d5aeb'
77
+ const E5_REVISION = '252d0dcb679dda2c7b6fd5bbfed15df3c7feaebf'
78
+ const E5_COMMIT_TIME = '2025-07-22T22:49:03.000Z'
79
+ const E5_POOLING_REVISION = 'bdd905ef05181adf3ebbfaac5cd5bd4ed9a58760'
80
+
81
+ // 核实证据(2026-11-02):Qwen3-Embedding 的 ONNX 导出只在 huggingface 系(n24q02m 的仓库
82
+ // 与基座 Qwen 的仓库在 ModelScope 上都没有对应条目)。本机 huggingface.co 连不上,
83
+ // hf-mirror.com 通(它重定向到自己的 resolve-cache,不经过 huggingface.co),所以
84
+ // 默认走 hf-mirror;两个 provider pin 同一个 commit,逐文件 sha256 与 HF 的 LFS oid 对过。
85
+ const QWEN_EXPORT_REPO = 'n24q02m/Qwen3-Embedding-0.6B-ONNX'
86
+ const QWEN_REVISION = 'dc873d64d6143f27ad68dadbd1f0d9a4371b994e'
87
+ const QWEN_COMMIT_TIME = '2026-02-18T17:28:18.000Z'
88
+ const QWEN_BASE_REPO = 'Qwen/Qwen3-Embedding-0.6B'
89
+ const QWEN_BASE_REVISION = '97b0c614be4d77ee51c0cef4e5f07c00f9eb65b3'
90
+ // 官方默认 query prompt(config_sentence_transformers.json 的 prompts.query),document 侧
91
+ // 官方明确「No need to add instruction for retrieval documents」→ 非对称,走角色通道。
92
+ const QWEN_QUERY_PROMPT = 'Instruct: Given a web search query, retrieve relevant passages that answer the query\nQuery:'
93
+ // 两个 provider 都是同一个 commit 的同一份内容;每写一个文件都要过 sha256,所以
94
+ // 允许见证制品在任一 provider 上取,而不是把源站整条封掉。
95
+ const QWEN_MIRROR_PROVIDERS = ['hf-mirror', 'huggingface']
96
+
97
+ // 三个模型 pin 的是同一棵受管 ONNX 运行时树:安装事实只写一次,条目里展开复用。
98
+ // 指纹只看 engine/abi/version/os/arch 五个字段(§14.8),note 不参与,所以共享常量
99
+ // 不会把某个模型的运行时事实悄悄改成另一个模型的。
100
+ const PINNED_ONNX_RUNTIME = Object.freeze({
101
+ engine: 'onnxruntime-node',
102
+ version: '1.31.1',
103
+ abi: 'napi-v6',
104
+ os: 'win32',
105
+ arch: 'x64',
106
+ verified: true,
107
+ tokenizer: { name: '@huggingface/tokenizers', version: '0.2.0', license: 'Apache-2.0', sha256: 'f6b9849b58de625c4fd79583242dd4506914b92082f9af17719d39416658ef24' },
108
+ packages: [
109
+ { name: 'onnxruntime-node', version: '1.31.1', license: 'MIT', sha256: '41aedb3e877786245ab4dc0f533cda63f7d971b5c5fec171eafca9fb9572a8d5' },
110
+ { name: 'onnxruntime-common', version: '1.31.1', license: 'MIT', sha256: 'c8e59240260cd3d230f1417765e0dbe098323ef65a5785991059de1bd5d7cde0' },
111
+ ],
112
+ // 受管安装事实(2026-10-30):三个 npm tarball 本轮真实下载并核对 sha256/bytes;
113
+ // 解包后的最小运行时树跑通真实 /v1/embeddings 推理(512 维、worker ready ≈559ms)。
114
+ // 只允许从这些 URL 下载并按下面的 hash 校验;没有 hash 或没有该平台原生库一律拒绝安装。
115
+ install: {
116
+ scope: 'per-user-managed',
117
+ layout: 'node_modules',
118
+ postinstall: 'never-run',
119
+ verifiedAt: '2026-10-30T03:45:00.000Z',
120
+ verifiedOn: 'win32-x64',
121
+ platforms: {
122
+ 'win32-x64': 'smoke-verified',
123
+ 'win32-arm64': 'artifact-pinned',
124
+ 'linux-x64': 'artifact-pinned',
125
+ 'linux-arm64': 'artifact-pinned',
126
+ 'darwin-arm64': 'artifact-pinned',
127
+ },
128
+ evidence: 'npm tarball sha256 与 registry integrity 双向一致;解包最小树真实推理通过;原生库逐文件 sha256 取自同一棵已核实树',
129
+ },
130
+ artifacts: [
131
+ {
132
+ name: 'onnxruntime-node', version: '1.31.1', license: 'MIT',
133
+ url: 'https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-1.31.1.tgz',
134
+ bytes: 115391311,
135
+ sha256: 'd7a3de2b1bba92614abc74af909cc0ba4f4dd5347735418794edeb58cfef2d22',
136
+ integrity: 'sha512-ijnSghbDHVWaQ2nDPmVccPlCHI8kH1Mx1aJ4a/qzRP16bBcVs4E3EqZQKZCkhWnbqN1tuQWxagimFtDpbPYYQw==',
137
+ extract: ['package.json', 'README.md', 'dist', 'lib', 'bin/napi-v6/<platform>'],
138
+ },
139
+ {
140
+ name: 'onnxruntime-common', version: '1.31.1', license: 'MIT',
141
+ url: 'https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.31.1.tgz',
142
+ bytes: 72322,
143
+ sha256: '967acac0c2a22122461e526aeda07305da7289d94f276920d8a6919483f07bfc',
144
+ integrity: 'sha512-F+nnYNiQtmNJ95V6R/isBJqiVpdANCrsMEg1OaF+Bkbl3GAtzWLR7Ng17Ld0QtYtYJyotOHPJzOQn1Y6PLZjpg==',
145
+ extract: ['package.json', 'README.md', 'dist', 'lib'],
146
+ },
147
+ {
148
+ name: '@huggingface/tokenizers', version: '0.2.0', license: 'Apache-2.0',
149
+ url: 'https://registry.npmjs.org/@huggingface/tokenizers/-/tokenizers-0.2.0.tgz',
150
+ bytes: 87011,
151
+ sha256: '2800014c83b8186b2e4210c20672f1fb65a12cef85d7e95e0f2003e022611b4a',
152
+ integrity: 'sha512-LidMHe1FpcSYH4vcSjXooda34pC0M8m1gmDOv7SQi6Iv+ib1zX7J3sHBCC9/3FPCkn2k1b55FneVqMRxrr99pg==',
153
+ extract: ['package.json', 'README.md', 'LICENSE', 'dist', 'types'],
154
+ },
155
+ ],
156
+ // 解包后的 package.json 事实(字节数 + sha256):用于确认解出来的就是 pin 住的版本。
157
+ packageFiles: [
158
+ { package: 'onnxruntime-node', bytes: 1593, sha256: '41aedb3e877786245ab4dc0f533cda63f7d971b5c5fec171eafca9fb9572a8d5' },
159
+ { package: 'onnxruntime-common', bytes: 977, sha256: 'c8e59240260cd3d230f1417765e0dbe098323ef65a5785991059de1bd5d7cde0' },
160
+ { package: '@huggingface/tokenizers', bytes: 1965, sha256: 'f6b9849b58de625c4fd79583242dd4506914b92082f9af17719d39416658ef24' },
161
+ ],
162
+ // 判分/加载必需的原生库逐文件 hash。没有列出原生库的平台不得安装(不允许猜)。
163
+ native: {
164
+ 'win32-x64': [
165
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/x64/onnxruntime_binding.node', bytes: 358200, sha256: '8d9f996ff7dcc60c4899aa87aa7abe07d806f9c314882f44a001d0fd8a23d16f' },
166
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/x64/onnxruntime.dll', bytes: 31736672, sha256: 'beb6e1edba0e74c132453fe4df113da2ea2b99ef8ea7dfc25696a872efd11c45' },
167
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/x64/DirectML.dll', bytes: 18527544, sha256: 'd16be72fa002dd610cca93e376f0ef44865dfce43de4b7bf9738af22534f7a9d' },
168
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/x64/dxcompiler.dll', bytes: 17986400, sha256: '430eed027979399769a325b60319aca4e4afa4daebe475d3c763dcf2a0190a72' },
169
+ ],
170
+ 'win32-arm64': [
171
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/onnxruntime_binding.node', bytes: 504160, sha256: '6f34d4635793371c85e5260dbdc0864c2ef62ccfcb1f439afa3501ba6f8d530d' },
172
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/onnxruntime.dll', bytes: 32835936, sha256: '14d1cd398fa5bc8b5c61bdfba899f17b40550012ec2884955ce656a5d8a8ff77' },
173
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/DirectML.dll', bytes: 18444600, sha256: '4bb0639eb23a02de2c5f1eddd117f13330819f55b556e8c75068b68ad1a3516e' },
174
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/dxcompiler.dll', bytes: 22285624, sha256: '4a77bcadf4d437ad50d10517bb0b4a5a4c2fc84b1fde4d1cf5a5abe9e2dce431' },
175
+ ],
176
+ 'linux-x64': [
177
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node', bytes: 519712, sha256: 'e3a108803b8bd33c8e9691b52921c37bede7a6886251aa41219f053d268ee231' },
178
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1', bytes: 47552704, sha256: 'f19a4da48c4c65e0cdccff82354482f657fa91a3455b66174195b94ca55b0e6f' },
179
+ ],
180
+ 'linux-arm64': [
181
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/onnxruntime_binding.node', bytes: 551752, sha256: '5d943f6bf8f65c40213bac636f19bcb227ee1d188417c4b6a6f70062579cfb84' },
182
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/libonnxruntime.so.1', bytes: 25266408, sha256: '152fb7d2f4f06acc5a38627fbca3e56ba2a9b984cb060d2ac500ac272afbb9ba' },
183
+ ],
184
+ 'darwin-arm64': [
185
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64/onnxruntime_binding.node', bytes: 323512, sha256: '95ab5698fbcb34d035ea98266156ad5a06b76d0ee739ea42d660df6901df390a' },
186
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64/libonnxruntime.1.dylib', bytes: 45331560, sha256: '9a362365243b56da98a2ad65128a32d6f8066d1f39ce697e0fce997adf0586dc' },
187
+ { path: 'node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64/libonnxruntime.1.31.1.dylib', bytes: 45331560, sha256: '9a362365243b56da98a2ad65128a32d6f8066d1f39ce697e0fce997adf0586dc' },
188
+ ],
189
+ },
190
+ })
191
+
192
+ // Qwen3-Embedding 的两种量化各是一张卡片:int8 与 int4+fp16 的权重存储方式不同,
193
+ // 落出来的向量空间也不同(§14.8 里 quantization 进指纹),所以必须分条目、分 DB,
194
+ // 而不是一个条目两个文件让用户以为可以混用。
195
+ function qwen3Card(variant) {
196
+ const int8 = variant === 'int8'
197
+ const graphPath = int8 ? 'onnx/model_quantized.onnx' : 'onnx/model_q4f16.onnx'
198
+ const graphBytes = int8 ? 600223343 : 541820311
199
+ const graphSha = int8
200
+ ? '76dc4f417876e48b2fae7f325cb052f46099c890e6a7c1b60f91ff5027d751ef'
201
+ : '2db238eb6122ce336c9de62df9c08113a4da7f41514298885a379451e952178e'
202
+ const activation = int8 ? 'float32' : 'float16'
203
+ return {
204
+ id: `qwen3-embedding-0.6b-${variant}`,
205
+ displayName: `Qwen3-Embedding-0.6B (${variant} ONNX)`,
206
+ summary: int8
207
+ ? 'Qwen3 0.6B 多语言检索模型(1024 维、last-token pooling + L2),默认下载的就是这份 int8。受管 ORT CPU 实测:图加载 2.06 s、短句一次编码 91 ms、380 字 437 ms、1520 字 4.29 s——比 BGE/MiniLM/e5 慢一到两个数量级,换来的是跨 100+ 语言与代码检索。查询侧带官方 Instruct 前缀(非对称 → 需要角色通道),实测加/不加前缀的同句余弦只有 0.8284;同一份 recall-bench 草稿上带前缀 R@1 0.6970 / MRR 0.8359,不带前缀 0.6667 / 0.8081(33 条可答样本,差一个样本,不当结论,但方向与官方说明一致)。'
208
+ : '与 int8 卡片同一份 0.6B 权重的 int4 变体(float16 激活 + com.microsoft.MatMulNBits,block_size=128),制品 542 MB vs 600 MB。受管 ORT CPU 实测反而更慢:加载 11.4 s、短句 110 ms、380 字 870 ms、1520 字 5.86 s,且依赖 com.microsoft 私有算子域。在这份合成草稿上它没有变差(带前缀 R@1 0.7273 / MRR 0.8510,int8 是 0.6970 / 0.8359)——33 个样本的差距不足以排序两个变体的质量,能当依据的是实测到的加载慢 5.5 倍与贡献算子依赖。向量空间与 int8 卡片不同,切换 = 重建。',
209
+ languages: ['zh', 'en', 'multilingual'],
210
+ tier: int8 ? 'preferred' : 'optional',
211
+ availability: 'available',
212
+ pendingReasons: [],
213
+ parameters: int8 ? 595776975 : 599217221,
214
+ parameterSource: int8
215
+ ? '图内 initializer 元素合计 595,776,975(int8 440,402,116 + uint8 155,309,057 + float32 65,802,不含 int64/bool 位置与掩码表);官方模型卡 0.6B'
216
+ : '图内 initializer 元素合计 599,217,221(float16 158,815,301 + int4 按 uint8 打包 ×2 = 440,401,920);与 int8 变体同一份 0.6B 权重,存储方式不同所以计数略有出入',
217
+ dimension: 1024,
218
+ // 制品侧 config.max_position_embeddings=32768(tokenizer model_max_length 131072),
219
+ // 这里按实测延迟取 4096:1520 字已经 4.3 s,按 32k 跑一条长记忆会直接顶到 worker 的
220
+ // 120 s 请求超时。分窗是指纹字段,所以它是刻意的策略而不是「没核实」。
221
+ maxTokens: 4096,
222
+ // 因果 LM:官方 1_Pooling pooling_mode_lasttoken=true,其余全 false。
223
+ pooling: 'last',
224
+ normalization: 'l2',
225
+ prefixes: { query: QWEN_QUERY_PROMPT, document: '' },
226
+ quantization: int8
227
+ ? {
228
+ weights: 'qint8',
229
+ scheme: 'dynamic-per-tensor',
230
+ reduceRange: null,
231
+ source: '导出仓库 README 声明 onnxruntime.quantization.quantize_dynamic(QInt8);图侧核实 196/196 个 MatMulInteger 的 scale/zero_point 都是 rank-0 标量、per-channel scale 向量 0 个,另有 DynamicQuantizeLinear 112 个 → 激活动态量化 + 权重 per-tensor,和 BGE/MiniLM/e5 的 per-channel 不是同一个空间',
232
+ }
233
+ : {
234
+ weights: 'uint4-nbits',
235
+ scheme: 'block-wise-int4-block128-fp16-activations',
236
+ reduceRange: null,
237
+ source: 'README 声明 MatMulNBitsQuantizer(block_size=128, symmetric) + FP16 cast;图侧核实 com.microsoft.MatMulNBits 196 个、打包权重形状 [out, blocks, 64](blocks×128 = 输入维、64 字节 = 128 个 nibble),其余 initializer 为 float16;opset 21 + com.microsoft v1',
238
+ },
239
+ runtime: {
240
+ ...PINNED_ONNX_RUNTIME,
241
+ note: int8
242
+ ? '受管 ORT 1.31.1 CPU 真实加载/推理已核实(2026-11-02,win32-x64):1024 维、单位范数、重复编码余弦 1.0。'
243
+ : '受管 ORT 1.31.1 CPU 真实加载/推理已核实(2026-11-02,win32-x64),但依赖 com.microsoft 贡献算子域;加载 11.4 s,仍在 worker 60 s ready 预算内。',
244
+ },
245
+ license: {
246
+ base: { id: 'apache-2.0', source: 'hf-mirror 元数据 Qwen/Qwen3-Embedding-0.6B cardData.license = apache-2.0(2026-11-02 只读核对)' },
247
+ onnxExport: { id: 'apache-2.0', source: 'n24q02m/Qwen3-Embedding-0.6B-ONNX 的 README front-matter license: apache-2.0(2026-11-02 核对下载字节)' },
248
+ },
249
+ verification: {
250
+ status: 'verified',
251
+ method: 'sha256+onnx-header+onnxruntime-inference',
252
+ checkedAt: '2026-11-02T08:55:00.000Z',
253
+ scope: `逐文件 bytes/sha256 与 HF 文件树声明一致(LFS 制品直接对 lfs.oid 的 sha256)+ ONNX 图头(opset 21、input_ids/attention_mask 两个 int64 输入、last_hidden_state ${activation}[1,sequence_length,1024]、自包含、固定 batch=1 导出)+ 基座 1_Pooling/2_Normalize 的 pooling 与归一化事实 + 受管 ORT CPU 真实推理与延迟测量`,
254
+ evidence: int8
255
+ ? '2026-11-02 实测(.tmp-model-adapt-20261102/qwen3*):onnx/model_quantized.onnx 600,223,343 B 的 sha256 与 HF LFS oid 76dc4f41…逐字节一致;加载 2057 ms、首帧 91 ms、380 字 437 ms、1520 字 4286 ms、单位范数 1.0、重复编码余弦 1.0;instruct 前缀漂移余弦 0.8284;42 条 recall-bench 草稿的 33 条可答样本上带前缀 R@1 0.6970 / R@3 0.9697 / MRR 0.8359、裸文本 0.6667 / 0.9394 / 0.8081;真机五路互切(MiniLM→本卡→q4f16→e5→BGE)各 6/6 条重建、0 失败、中英查询均召回'
256
+ : '2026-11-02 实测(.tmp-model-adapt-20261102/qwen3*):onnx/model_q4f16.onnx 541,820,311 B 的 sha256 与 HF LFS oid 2db238eb…逐字节一致;加载 11401 ms、首帧 110 ms、380 字 870 ms、1520 字 5863 ms、单位范数 1.0、重复编码余弦 1.0;instruct 前缀漂移余弦 0.8203;同一份草稿带前缀 R@1 0.7273 / R@3 0.9697 / MRR 0.8510、裸文本 0.6667 / 0.9394 / 0.8081;真机五路互切里作为 g3 完成重建并召回',
257
+ notVerified: [
258
+ 'modelscope 上没有该导出仓库与基座仓库的对应条目(只读核对 record not found)',
259
+ `huggingface.co 源站本机不可达:同一 commit 的同一批文件只在 hf-mirror 上做过逐字节复核`,
260
+ '与 PyTorch 基座(float32/bfloat16)向量的数值等价性——本包不做参考实现比对,只保证同一制品重复编码一致',
261
+ ],
262
+ },
263
+ sources: {
264
+ 'hf-mirror': { repo: QWEN_EXPORT_REPO, revision: QWEN_REVISION, revisionVerified: true, commitTime: QWEN_COMMIT_TIME },
265
+ huggingface: { repo: QWEN_EXPORT_REPO, revision: QWEN_REVISION, revisionVerified: false, commitTime: QWEN_COMMIT_TIME, note: '与 hf-mirror pin 同一个 commit;本机连不上 huggingface.co,所以未独立复核,但逐文件 sha256 是硬校验' },
266
+ },
267
+ witness: {
268
+ provider: 'hf-mirror',
269
+ repo: QWEN_BASE_REPO,
270
+ revision: QWEN_BASE_REVISION,
271
+ path: '1_Pooling/config.json',
272
+ bytes: 313,
273
+ sha256: '37bf193fa101f19101bfad9c31d3eb0f786e247b7b1e5cb7f007d730eed1ddbd',
274
+ purpose: 'pooling 事实来源:pooling_mode_lasttoken=true 且 cls/mean/max/weightedmean 全 false、word_embedding_dimension=1024、include_prompt=true;同仓库 modules.json 含 2_Normalize(L2),config_sentence_transformers.json 的 prompts.query 给出官方 Instruct 前缀且 prompts.document 为空',
275
+ },
276
+ graph: {
277
+ path: graphPath,
278
+ opset: 21,
279
+ producer: int8 ? 'onnx.quantize' : 'pytorch',
280
+ producerVersion: int8 ? '0.1.0' : '2.10.0+cu128',
281
+ selfContained: true,
282
+ externalData: [],
283
+ inputs: [
284
+ { name: 'input_ids', dtype: 'int64', shape: ['batch_size', 'sequence_length'] },
285
+ { name: 'attention_mask', dtype: 'int64', shape: ['batch_size', 'sequence_length'] },
286
+ ],
287
+ // batch 维是字面量 1(导出时固定),所以一次只能喂一行。
288
+ outputs: [{ name: 'last_hidden_state', dtype: activation, shape: [1, 'sequence_length', 1024] }],
289
+ },
290
+ files: [
291
+ { path: 'config.json', role: 'config', bytes: 1416, sha256: '88014d4dd5f874bf4050a57e76029ffdb42bead2c0c9253b4eb21bc65da8a5d9' },
292
+ { path: 'tokenizer.json', role: 'tokenizer', bytes: 11423701, sha256: '93623af029cdc69b87f2864d3b2cc2424fdf16684f15e139b5b9d08ec34ced91' },
293
+ { path: 'tokenizer_config.json', role: 'tokenizer-config', bytes: 349, sha256: 'bc3e7cb4dad833a185d4bfbb4880562dc9b0cb101c47b8985078122a122d553a' },
294
+ { path: graphPath, role: 'graph', bytes: graphBytes, sha256: graphSha },
295
+ { path: 'README.md', role: 'notice', bytes: 2226, sha256: 'a5b65f56517933cc8b6724293b73e7123531569df121ae3ebe597dd8dd571a3f' },
296
+ {
297
+ path: '1_Pooling/config.json',
298
+ role: 'pooling-config',
299
+ bytes: 313,
300
+ sha256: '37bf193fa101f19101bfad9c31d3eb0f786e247b7b1e5cb7f007d730eed1ddbd',
301
+ origin: {
302
+ provider: 'hf-mirror',
303
+ providers: QWEN_MIRROR_PROVIDERS,
304
+ repo: QWEN_BASE_REPO,
305
+ revision: QWEN_BASE_REVISION,
306
+ },
307
+ },
308
+ ],
309
+ }
310
+ }
311
+
71
312
  const rawCatalog = [
72
313
  {
73
314
  id: 'bge-small-zh-v1.5-int8',
@@ -91,96 +332,8 @@ const rawCatalog = [
91
332
  source: 'quantize_config.json(per_channel=true, reduce_range=true, weight_type=QInt8) + 图内 MatMulInteger/DynamicQuantizeLinear',
92
333
  },
93
334
  runtime: {
94
- engine: 'onnxruntime-node',
95
- version: '1.31.1',
96
- abi: 'napi-v6',
97
- os: 'win32',
98
- arch: 'x64',
99
- verified: true,
100
- tokenizer: { name: '@huggingface/tokenizers', version: '0.2.0', license: 'Apache-2.0', sha256: 'f6b9849b58de625c4fd79583242dd4506914b92082f9af17719d39416658ef24' },
101
- packages: [
102
- { name: 'onnxruntime-node', version: '1.31.1', license: 'MIT', sha256: '41aedb3e877786245ab4dc0f533cda63f7d971b5c5fec171eafca9fb9572a8d5' },
103
- { name: 'onnxruntime-common', version: '1.31.1', license: 'MIT', sha256: 'c8e59240260cd3d230f1417765e0dbe098323ef65a5785991059de1bd5d7cde0' },
104
- ],
335
+ ...PINNED_ONNX_RUNTIME,
105
336
  note: '隔离目录真实 ORT CPU 加载/推理 smoke 已核实;仅允许固定版本,不隐式下载。',
106
- // 受管安装事实(2026-10-30):三个 npm tarball 本轮真实下载并核对 sha256/bytes;
107
- // 解包后的最小运行时树跑通真实 /v1/embeddings 推理(512 维、worker ready ≈559ms)。
108
- // 只允许从这些 URL 下载并按下面的 hash 校验;没有 hash 或没有该平台原生库一律拒绝安装。
109
- install: {
110
- scope: 'per-user-managed',
111
- layout: 'node_modules',
112
- postinstall: 'never-run',
113
- verifiedAt: '2026-10-30T03:45:00.000Z',
114
- verifiedOn: 'win32-x64',
115
- platforms: {
116
- 'win32-x64': 'smoke-verified',
117
- 'win32-arm64': 'artifact-pinned',
118
- 'linux-x64': 'artifact-pinned',
119
- 'linux-arm64': 'artifact-pinned',
120
- 'darwin-arm64': 'artifact-pinned',
121
- },
122
- evidence: 'npm tarball sha256 与 registry integrity 双向一致;解包最小树真实推理通过;原生库逐文件 sha256 取自同一棵已核实树',
123
- },
124
- artifacts: [
125
- {
126
- name: 'onnxruntime-node', version: '1.31.1', license: 'MIT',
127
- url: 'https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-1.31.1.tgz',
128
- bytes: 115391311,
129
- sha256: 'd7a3de2b1bba92614abc74af909cc0ba4f4dd5347735418794edeb58cfef2d22',
130
- integrity: 'sha512-ijnSghbDHVWaQ2nDPmVccPlCHI8kH1Mx1aJ4a/qzRP16bBcVs4E3EqZQKZCkhWnbqN1tuQWxagimFtDpbPYYQw==',
131
- extract: ['package.json', 'README.md', 'dist', 'lib', 'bin/napi-v6/<platform>'],
132
- },
133
- {
134
- name: 'onnxruntime-common', version: '1.31.1', license: 'MIT',
135
- url: 'https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.31.1.tgz',
136
- bytes: 72322,
137
- sha256: '967acac0c2a22122461e526aeda07305da7289d94f276920d8a6919483f07bfc',
138
- integrity: 'sha512-F+nnYNiQtmNJ95V6R/isBJqiVpdANCrsMEg1OaF+Bkbl3GAtzWLR7Ng17Ld0QtYtYJyotOHPJzOQn1Y6PLZjpg==',
139
- extract: ['package.json', 'README.md', 'dist', 'lib'],
140
- },
141
- {
142
- name: '@huggingface/tokenizers', version: '0.2.0', license: 'Apache-2.0',
143
- url: 'https://registry.npmjs.org/@huggingface/tokenizers/-/tokenizers-0.2.0.tgz',
144
- bytes: 87011,
145
- sha256: '2800014c83b8186b2e4210c20672f1fb65a12cef85d7e95e0f2003e022611b4a',
146
- integrity: 'sha512-LidMHe1FpcSYH4vcSjXooda34pC0M8m1gmDOv7SQi6Iv+ib1zX7J3sHBCC9/3FPCkn2k1b55FneVqMRxrr99pg==',
147
- extract: ['package.json', 'README.md', 'LICENSE', 'dist', 'types'],
148
- },
149
- ],
150
- // 解包后的 package.json 事实(字节数 + sha256):用于确认解出来的就是 pin 住的版本。
151
- packageFiles: [
152
- { package: 'onnxruntime-node', bytes: 1593, sha256: '41aedb3e877786245ab4dc0f533cda63f7d971b5c5fec171eafca9fb9572a8d5' },
153
- { package: 'onnxruntime-common', bytes: 977, sha256: 'c8e59240260cd3d230f1417765e0dbe098323ef65a5785991059de1bd5d7cde0' },
154
- { package: '@huggingface/tokenizers', bytes: 1965, sha256: 'f6b9849b58de625c4fd79583242dd4506914b92082f9af17719d39416658ef24' },
155
- ],
156
- // 判分/加载必需的原生库逐文件 hash。没有列出原生库的平台不得安装(不允许猜)。
157
- native: {
158
- 'win32-x64': [
159
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/x64/onnxruntime_binding.node', bytes: 358200, sha256: '8d9f996ff7dcc60c4899aa87aa7abe07d806f9c314882f44a001d0fd8a23d16f' },
160
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/x64/onnxruntime.dll', bytes: 31736672, sha256: 'beb6e1edba0e74c132453fe4df113da2ea2b99ef8ea7dfc25696a872efd11c45' },
161
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/x64/DirectML.dll', bytes: 18527544, sha256: 'd16be72fa002dd610cca93e376f0ef44865dfce43de4b7bf9738af22534f7a9d' },
162
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/x64/dxcompiler.dll', bytes: 17986400, sha256: '430eed027979399769a325b60319aca4e4afa4daebe475d3c763dcf2a0190a72' },
163
- ],
164
- 'win32-arm64': [
165
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/onnxruntime_binding.node', bytes: 504160, sha256: '6f34d4635793371c85e5260dbdc0864c2ef62ccfcb1f439afa3501ba6f8d530d' },
166
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/onnxruntime.dll', bytes: 32835936, sha256: '14d1cd398fa5bc8b5c61bdfba899f17b40550012ec2884955ce656a5d8a8ff77' },
167
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/DirectML.dll', bytes: 18444600, sha256: '4bb0639eb23a02de2c5f1eddd117f13330819f55b556e8c75068b68ad1a3516e' },
168
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/dxcompiler.dll', bytes: 22285624, sha256: '4a77bcadf4d437ad50d10517bb0b4a5a4c2fc84b1fde4d1cf5a5abe9e2dce431' },
169
- ],
170
- 'linux-x64': [
171
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node', bytes: 519712, sha256: 'e3a108803b8bd33c8e9691b52921c37bede7a6886251aa41219f053d268ee231' },
172
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1', bytes: 47552704, sha256: 'f19a4da48c4c65e0cdccff82354482f657fa91a3455b66174195b94ca55b0e6f' },
173
- ],
174
- 'linux-arm64': [
175
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/onnxruntime_binding.node', bytes: 551752, sha256: '5d943f6bf8f65c40213bac636f19bcb227ee1d188417c4b6a6f70062579cfb84' },
176
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/libonnxruntime.so.1', bytes: 25266408, sha256: '152fb7d2f4f06acc5a38627fbca3e56ba2a9b984cb060d2ac500ac272afbb9ba' },
177
- ],
178
- 'darwin-arm64': [
179
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64/onnxruntime_binding.node', bytes: 323512, sha256: '95ab5698fbcb34d035ea98266156ad5a06b76d0ee739ea42d660df6901df390a' },
180
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64/libonnxruntime.1.dylib', bytes: 45331560, sha256: '9a362365243b56da98a2ad65128a32d6f8066d1f39ce697e0fce997adf0586dc' },
181
- { path: 'node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64/libonnxruntime.1.31.1.dylib', bytes: 45331560, sha256: '9a362365243b56da98a2ad65128a32d6f8066d1f39ce697e0fce997adf0586dc' },
182
- ],
183
- },
184
337
  },
185
338
  license: {
186
339
  base: { id: 'mit', source: 'ModelScope BAAI/bge-small-zh-v1.5 的 License 字段 = mit(2026-10-30 只读核对)' },
@@ -243,71 +396,169 @@ const rawCatalog = [
243
396
  {
244
397
  id: 'all-minilm-l6-v2-int8',
245
398
  displayName: 'all-MiniLM-L6-v2 (int8 ONNX)',
246
- summary: '英文句子相似度小模型;不是中文模型的等价替代(§14.4)。',
399
+ summary: '英文句子相似度小模型(384 维,mean pooling + L2)。中文能跑但明显弱于另外两个:同一份 recall-bench 草稿 33 条可答样本上 R@1 0.5455 / MRR@3 0.7525,BGE 是 0.6667 / 0.8106。它不是中文模型的等价替代,适合英文语料或只想装 23 MB 制品的场合。',
247
400
  languages: ['en'],
248
401
  tier: 'optional',
249
- availability: 'pending',
250
- pendingReasons: [
251
- 'ONNX 制品尺寸/hash 未核实(本包只核实首个 BGE 制品)',
252
- '官方 wrapper 常用上限 256,不能按底座 512 推定,需在 config/tokenizer/实际输出三处确认',
253
- 'huggingface/hf-mirror 在本机不可达,未取得固定 commit',
254
- ],
255
- parameters: 22000000,
256
- parameterSource: '约 22M(§14.4 候选值,未复核)',
402
+ availability: 'available',
403
+ pendingReasons: [],
404
+ parameters: 22565376,
405
+ parameterSource: '实测图内 initializer 元素合计 22,565,376(uint8 11,917,824 + int8 10,616,832 + float32 30,720);官方模型页标 22.7M',
257
406
  dimension: 384,
258
- maxTokens: null,
407
+ // 底座 config.max_position_embeddings=512、tokenizer model_max_length=512、图输出第三维=384
408
+ // 三处一致;sentence_bert_config.json 的 max_seq_length=256 只是 SB wrapper 的窗口。
409
+ // 分窗按制品本身取 512,和 BGE 同窗,切换模型不会顺带改分窗口径。
410
+ maxTokens: 512,
259
411
  pooling: 'mean',
260
412
  normalization: 'l2',
261
413
  prefixes: { query: '', document: '' },
262
- quantization: { weights: 'qint8', scheme: 'unknown', reduceRange: null, source: '未核实' },
263
- runtime: { engine: 'onnxruntime-node', version: null, abi: 'napi-v6', os: 'win32', arch: 'x64', verified: false, note: '同 BGE:ORT 未实测' },
414
+ quantization: {
415
+ weights: 'qint8',
416
+ scheme: 'dynamic-per-channel',
417
+ reduceRange: null,
418
+ source: '仓库未随附 quant_config.json;方案取自图本身:MatMulInteger(36)+DynamicQuantizeLinear(24),39/39 个 int8/uint8 二维权重都存在长度=输出通道数的一维 float32 scale,长度 1 的标量 scale=0',
419
+ },
420
+ runtime: { ...PINNED_ONNX_RUNTIME, note: '同一棵受管 ORT 1.31.1 CPU 树真实推理已核实(2026-11-02):384 维、单位范数、重复编码余弦 1.0。' },
264
421
  license: {
265
- base: { id: 'apache-2.0', source: 'ModelScope Xenova/all-MiniLM-L6-v2 的 License = apache-2.0(2026-10-30 只读核对)' },
266
- onnxExport: { id: 'undeclared', source: 'ONNX 导出未单独声明许可' },
422
+ base: { id: 'apache-2.0', source: 'ModelScope Xenova/all-MiniLM-L6-v2 元数据 License=apache-2.0(2026-11-02 只读核对)' },
423
+ onnxExport: { id: 'apache-2.0', source: '导出仓库 README front-matter license: apache-2.0(2026-11-02 核对下载字节)' },
424
+ },
425
+ verification: {
426
+ status: 'verified',
427
+ method: 'sha256+onnx-header+onnxruntime-inference',
428
+ checkedAt: '2026-11-02T08:00:00.000Z',
429
+ scope: '逐文件 bytes/sha256 与 ModelScope 文件清单双向一致 + ONNX 图头(opset 11、3 个 int64 输入、last_hidden_state float32[batch,seq,384]、自包含 22,661,632 initializer 字节)+ vocab.txt 行数 30522=config.vocab_size + 受管 ORT CPU 真实推理',
430
+ evidence: '2026-11-02 实测(.tmp-model-adapt-20261102):8 个文件 sha256 全部与清单一致;worker 单次编码 7ms、单位范数 1.0、重复编码余弦 1.0、>512 token 长文截断可用;42 条 recall-bench 草稿 33 条可答样本 R@1 0.5455 / R@3 1.0000 / MRR@3 0.7525',
431
+ notVerified: ['huggingface/hf-mirror 上的对应 commit(本机不可达)'],
267
432
  },
268
- verification: { status: 'unverified', method: null, checkedAt: null, scope: '仅候选条目;没有可下载制品', evidence: null, notVerified: ['全部制品'] },
269
433
  sources: {
270
- modelscope: { repo: 'Xenova/all-MiniLM-L6-v2', revision: null, revisionVerified: false, note: '候选来源,未固定 commit' },
271
- 'hf-mirror': { repo: 'Xenova/all-MiniLM-L6-v2', revision: null, revisionVerified: false, note: '未核实' },
272
- huggingface: { repo: 'sentence-transformers/all-MiniLM-L6-v2', revision: null, revisionVerified: false, note: '未核实' },
434
+ modelscope: { repo: 'Xenova/all-MiniLM-L6-v2', revision: MINIML_REVISION, revisionVerified: true, commitTime: MINIML_COMMIT_TIME },
435
+ 'hf-mirror': { repo: 'Xenova/all-MiniLM-L6-v2', revision: null, revisionVerified: false, note: 'hf-mirror.com 本机不可达,commit 未核实;不生成 URL' },
436
+ huggingface: { repo: 'sentence-transformers/all-MiniLM-L6-v2', revision: null, revisionVerified: false, note: 'huggingface.co 本机不可达,commit 未核实;不生成 URL' },
273
437
  },
274
- graph: null,
275
- files: [],
438
+ witness: {
439
+ provider: 'modelscope',
440
+ repo: 'sentence-transformers/all-MiniLM-L6-v2',
441
+ revision: MINIML_POOLING_REVISION,
442
+ path: '1_Pooling/config.json',
443
+ bytes: 190,
444
+ sha256: '4be450dde3b0273bb9787637cfbd28fe04a7ba6ab9d36ac48e92b11e350ffc23',
445
+ purpose: 'pooling 事实来源:pooling_mode_mean_tokens=true、cls/max=false、word_embedding_dimension=384;同仓库 modules.json 含 2_Normalize(L2),sentence_bert_config.json max_seq_length=256',
446
+ },
447
+ graph: {
448
+ path: 'onnx/model_quantized.onnx',
449
+ opset: 11,
450
+ producer: 'onnx.quantize',
451
+ producerVersion: '0.1.0',
452
+ selfContained: true,
453
+ externalData: [],
454
+ inputs: [
455
+ { name: 'input_ids', dtype: 'int64', shape: ['batch_size', 'sequence_length'] },
456
+ { name: 'attention_mask', dtype: 'int64', shape: ['batch_size', 'sequence_length'] },
457
+ { name: 'token_type_ids', dtype: 'int64', shape: ['batch_size', 'sequence_length'] },
458
+ ],
459
+ outputs: [{ name: 'last_hidden_state', dtype: 'float32', shape: ['batch_size', 'sequence_length', 384] }],
460
+ },
461
+ files: [
462
+ { path: 'config.json', role: 'config', bytes: 650, sha256: '7135149f7cffa1a573466c6e4d8423ed73b62fd2332c575bf738a0d033f70df7' },
463
+ { path: 'tokenizer.json', role: 'tokenizer', bytes: 711661, sha256: 'da0e79933b9ed51798a3ae27893d3c5fa4a201126cef75586296df9b4d2c62a0' },
464
+ { path: 'tokenizer_config.json', role: 'tokenizer-config', bytes: 366, sha256: '9261e7d79b44c8195c1cada2b453e55b00aeb81e907a6664974b4d7776172ab3' },
465
+ { path: 'special_tokens_map.json', role: 'special-tokens', bytes: 125, sha256: 'b6d346be366a7d1d48332dbc9fdf3bf8960b5d879522b7799ddba59e76237ee3' },
466
+ { path: 'vocab.txt', role: 'vocab', bytes: 231508, sha256: '07eced375cec144d27c900241f3e339478dec958f92fddbc551f295c992038a3' },
467
+ { path: 'onnx/model_quantized.onnx', role: 'graph', bytes: 22972370, sha256: 'afdb6f1a0e45b715d0bb9b11772f032c399babd23bfc31fed1c170afc848bdb1' },
468
+ { path: 'README.md', role: 'notice', bytes: 1767, sha256: '63ea99bf681a2e9eda4f6a537d5ed8fda95d1677111656da37e9cfd080c3af02' },
469
+ {
470
+ path: '1_Pooling/config.json',
471
+ role: 'pooling-config',
472
+ bytes: 190,
473
+ sha256: '4be450dde3b0273bb9787637cfbd28fe04a7ba6ab9d36ac48e92b11e350ffc23',
474
+ origin: { provider: 'modelscope', repo: 'sentence-transformers/all-MiniLM-L6-v2', revision: MINIML_POOLING_REVISION },
475
+ },
476
+ ],
276
477
  },
277
478
  {
278
479
  id: 'multilingual-e5-small',
279
- displayName: 'multilingual-e5-small(待适配,初版不启用)',
280
- summary: '多语言(约 118M),需要 query/passage 前缀;当前请求通道无 role 字段,不能靠文本猜角色(§14.4)。',
480
+ displayName: 'multilingual-e5-small (int8 ONNX)',
481
+ summary: '多语言检索模型(118M 参数、int8 制品 ≈118 MB、384 维,mean pooling + L2)。要 query/passage 前缀:worker 通过 model 字段的角色后缀拿到 role,绝不按文本猜角色。同一份 recall-bench 草稿上 R@1 0.6667 / R@3 1.0000 / MRR@3 0.8182,中文与 BGE 同级、英文 paraphrase 余弦 0.91/0.93(BGE 0.65/0.64);代价是制品比 BGE 大 4.8 倍、推理慢一倍左右。',
281
482
  languages: ['zh', 'en', 'multilingual'],
282
- tier: 'deferred',
283
- availability: 'pending',
284
- pendingReasons: [
285
- '需要 query/passage 前缀,当前请求通道无 role 字段,不能安全启用',
286
- '长度/量化/许可证制品均未核实',
287
- '约 118M,int8 理论约 118 MB,不是 22–24M 级',
288
- ],
289
- parameters: 118000000,
290
- parameterSource: '§14.4 E5 作者模型表',
483
+ tier: 'optional',
484
+ availability: 'available',
485
+ pendingReasons: [],
486
+ parameters: 117505920,
487
+ parameterSource: '实测图内 initializer 元素合计 117,505,920(uint8 96,211,584 + int8 21,233,664 + float32 60,672);官方模型页标 118M',
291
488
  dimension: 384,
292
- maxTokens: null,
489
+ // 底座 config.max_position_embeddings=512、tokenizer model_max_length=512、
490
+ // sentence_bert_config.json max_seq_length=512 三处一致。
491
+ maxTokens: 512,
293
492
  pooling: 'mean',
294
493
  normalization: 'l2',
494
+ // 非对称前缀 = query 与 document 落在两个不同的读法上,必须靠角色通道区分(§14.4)。
295
495
  prefixes: { query: 'query: ', document: 'passage: ' },
296
- quantization: { weights: 'qint8', scheme: 'unknown', reduceRange: null, source: '未核实' },
297
- runtime: { engine: 'onnxruntime-node', version: null, abi: 'napi-v6', os: 'win32', arch: 'x64', verified: false, note: '同 BGE:ORT 未实测' },
496
+ quantization: {
497
+ weights: 'qint8',
498
+ scheme: 'dynamic-per-channel',
499
+ reduceRange: true,
500
+ source: 'quant_config.json(per_channel=true, reduce_range=true, weight_type=QInt8) + 图内 MatMulInteger(72)/DynamicQuantizeLinear(48);75/75 个 int8/uint8 二维权重都存在长度=输出通道数的一维 float32 scale',
501
+ },
502
+ runtime: { ...PINNED_ONNX_RUNTIME, note: '同一棵受管 ORT 1.31.1 CPU 树真实推理已核实(2026-11-02):XLM-R Unigram 分词可用、384 维、单位范数。' },
298
503
  license: {
299
- base: { id: 'unverified', source: '模型卡许可未核实(§14.4/§14.12)' },
300
- onnxExport: { id: 'undeclared', source: '无已核实导出' },
504
+ base: { id: 'mit', source: 'ModelScope intfloat/multilingual-e5-small 元数据 License=mit(2026-11-02 只读核对)' },
505
+ onnxExport: { id: 'undeclared', source: 'ModelScope Xenova/multilingual-e5-small 的 README front-matter 只有 base_model/library_name,未声明 license(2026-11-02 核对下载字节)' },
506
+ },
507
+ verification: {
508
+ status: 'verified',
509
+ method: 'sha256+onnx-header+onnxruntime-inference',
510
+ checkedAt: '2026-11-02T08:00:00.000Z',
511
+ scope: '逐文件 bytes/sha256 与 ModelScope 文件清单双向一致 + ONNX 图头(opset 11、3 个 int64 输入、last_hidden_state float32[batch,seq,384]、自包含 117,687,936 initializer 字节)+ tokenizer.json Unigram 词表 250002 + 受管 ORT CPU 真实推理与前缀 A/B',
512
+ evidence: '2026-11-02 实测(.tmp-model-adapt-20261102):8 个文件 sha256 全部与清单一致;单次编码 6ms、单位范数 1.0、重复编码余弦 1.0;前缀 A/B(33 条可答样本)asym R@1 0.6667/MRR 0.8182/分离度 0.1230、sym-passage 0.6364/0.8030/0.0867、sym-query 0.6667/0.8157/0.1155、无前缀 0.6364/0.8030/0.1139;query: 与 passage: 同文余弦 0.9811',
513
+ notVerified: ['huggingface/hf-mirror 上的对应 commit(本机不可达)', 'intfloat 官方仓库里 470 MB fp32 onnx/model.onnx 与本报告使用的 int8 导出数值等价性'],
301
514
  },
302
- verification: { status: 'unverified', method: null, checkedAt: null, scope: '仅目录占位;初版不启用', evidence: null, notVerified: ['全部制品'] },
303
515
  sources: {
304
- modelscope: { repo: 'intfloat/multilingual-e5-small', revision: null, revisionVerified: false, note: '候选来源,未固定 commit' },
305
- 'hf-mirror': { repo: 'intfloat/multilingual-e5-small', revision: null, revisionVerified: false, note: '未核实' },
306
- huggingface: { repo: 'intfloat/multilingual-e5-small', revision: null, revisionVerified: false, note: '未核实' },
516
+ modelscope: { repo: 'Xenova/multilingual-e5-small', revision: E5_REVISION, revisionVerified: true, commitTime: E5_COMMIT_TIME },
517
+ 'hf-mirror': { repo: 'Xenova/multilingual-e5-small', revision: null, revisionVerified: false, note: 'hf-mirror.com 本机不可达,commit 未核实;不生成 URL' },
518
+ huggingface: { repo: 'intfloat/multilingual-e5-small', revision: null, revisionVerified: false, note: 'huggingface.co 本机不可达,commit 未核实;不生成 URL' },
519
+ },
520
+ witness: {
521
+ provider: 'modelscope',
522
+ repo: 'intfloat/multilingual-e5-small',
523
+ revision: E5_POOLING_REVISION,
524
+ path: '1_Pooling/config.json',
525
+ bytes: 200,
526
+ sha256: '987f7a67a38fa564c849bb5d277c52ab9088a84368fc0be31a354125aebb12a0',
527
+ purpose: 'pooling 事实来源:pooling_mode_mean_tokens=true、cls/max=false、word_embedding_dimension=384;同仓库 modules.json 含 2_Normalize(L2),sentence_bert_config.json max_seq_length=512',
528
+ },
529
+ graph: {
530
+ path: 'onnx/model_quantized.onnx',
531
+ opset: 11,
532
+ producer: 'onnx.quantize',
533
+ producerVersion: '0.1.0',
534
+ selfContained: true,
535
+ externalData: [],
536
+ inputs: [
537
+ { name: 'input_ids', dtype: 'int64', shape: ['batch_size', 'sequence_length'] },
538
+ { name: 'attention_mask', dtype: 'int64', shape: ['batch_size', 'sequence_length'] },
539
+ { name: 'token_type_ids', dtype: 'int64', shape: ['batch_size', 'sequence_length'] },
540
+ ],
541
+ outputs: [{ name: 'last_hidden_state', dtype: 'float32', shape: ['batch_size', 'sequence_length', 384] }],
307
542
  },
308
- graph: null,
309
- files: [],
543
+ files: [
544
+ { path: 'config.json', role: 'config', bytes: 658, sha256: 'cb99455288675345e1a4f411438d5d0adbba5fbd3a67ea4fb03c015433b996c1' },
545
+ { path: 'tokenizer.json', role: 'tokenizer', bytes: 17082730, sha256: '0b44a9d7b51c3c62626640cda0e2c2f70fdacdc25bbbd68038369d14ebdf4c39' },
546
+ { path: 'tokenizer_config.json', role: 'tokenizer-config', bytes: 443, sha256: 'a1d6bc8734a6f635dc158508bef000f8e2e5a759c7d92f984b2c86e5ff53425b' },
547
+ { path: 'special_tokens_map.json', role: 'special-tokens', bytes: 167, sha256: 'd05497f1da52c5e09554c0cd874037a083e1dc1b9cfd48034d1c717f1afc07a7' },
548
+ { path: 'quant_config.json', role: 'quantization', bytes: 674, sha256: '59d175f15264115f18c698d76e443b5d49fc6c8c599911c421405ef4f236e87d' },
549
+ { path: 'onnx/model_quantized.onnx', role: 'graph', bytes: 118308185, sha256: 'f80102d3f2a1229f387d3c81909990d8945513e347b0eab049f7de3c6f98c193' },
550
+ { path: 'README.md', role: 'notice', bytes: 1077, sha256: '561a19594636657fe033f8b4427a7743b5f6f3a12f16cecc5f286feca0453245' },
551
+ {
552
+ path: '1_Pooling/config.json',
553
+ role: 'pooling-config',
554
+ bytes: 200,
555
+ sha256: '987f7a67a38fa564c849bb5d277c52ab9088a84368fc0be31a354125aebb12a0',
556
+ origin: { provider: 'modelscope', repo: 'intfloat/multilingual-e5-small', revision: E5_POOLING_REVISION },
557
+ },
558
+ ],
310
559
  },
560
+ qwen3Card('int8'),
561
+ qwen3Card('q4f16'),
311
562
  ]
312
563
 
313
564
  /**
@@ -397,6 +648,19 @@ export function getEmbeddingModel(id) {
397
648
  return catalog.find(entry => entry.id === id) || null
398
649
  }
399
650
 
651
+ /**
652
+ * 非对称前缀(query ≠ document)= 同一个模型对两种输入有两种读法,请求通道必须带上角色,
653
+ * 否则 worker 只能按文本猜——§14.4 明确不许猜。这里只从前缀派生,不另设开关:前缀本身在
654
+ * 指纹里,所以「要不要角色通道」和「这个向量空间是什么」永远来自同一份事实。
655
+ */
656
+ export function prefixesRequireRole(entry) {
657
+ const prefixes = entry?.prefixes
658
+ return !!prefixes
659
+ && typeof prefixes.query === 'string'
660
+ && typeof prefixes.document === 'string'
661
+ && prefixes.query !== prefixes.document
662
+ }
663
+
400
664
  // ---------------------------------------------------------------- ONNX 图头
401
665
 
402
666
  function readVarint(buffer, offset) {
@@ -578,13 +842,17 @@ export function validateEmbeddingManifest(manifest) {
578
842
 
579
843
  if (!Number.isFinite(manifest.parameters) || manifest.parameters <= 0) error('PARAMETERS_INVALID', 'parameters must be a positive number')
580
844
  if (!Number.isInteger(manifest.dimension) || manifest.dimension < 1 || manifest.dimension > 8192) error('DIMENSION_INVALID', 'dimension must be an integer in 1..8192')
581
- if (!(manifest.maxTokens === null || (Number.isInteger(manifest.maxTokens) && manifest.maxTokens >= 32 && manifest.maxTokens <= 8192))) {
582
- error('MAX_TOKENS_INVALID', 'maxTokens must be null (unverified) or an integer in 32..8192')
845
+ if (!(manifest.maxTokens === null || (Number.isInteger(manifest.maxTokens) && manifest.maxTokens >= 32 && manifest.maxTokens <= 32768))) {
846
+ error('MAX_TOKENS_INVALID', 'maxTokens must be null (unverified) or an integer in 32..32768')
583
847
  }
584
- if (!['cls', 'mean', 'max'].includes(manifest.pooling)) error('POOLING_INVALID', 'pooling must be cls/mean/max')
848
+ // 'last' = 因果 LM 的最后一个非 pad token(Qwen3-Embedding 这一类);'max' 仍是
849
+ // 目录允许声明但执行侧未实现,所以没有任何 available 条目使用它。
850
+ if (!['cls', 'mean', 'max', 'last'].includes(manifest.pooling)) error('POOLING_INVALID', 'pooling must be cls/mean/max/last')
585
851
  if (!['l2', 'none'].includes(manifest.normalization)) error('NORMALIZATION_INVALID', 'normalization must be l2/none')
586
852
  if (!isPlainObject(manifest.prefixes) || typeof manifest.prefixes.query !== 'string' || typeof manifest.prefixes.document !== 'string') {
587
853
  error('PREFIXES_INVALID', 'prefixes.query/document must be strings (empty is allowed)')
854
+ } else if (manifest.prefixes.query !== manifest.prefixes.document) {
855
+ warn('PREFIX_ASYMMETRIC', 'query/document prefixes differ, so this model reads the same text two ways: serving it needs an explicit role channel and role-less requests must be refused')
588
856
  }
589
857
 
590
858
  const sources = manifest.sources
@@ -645,6 +913,10 @@ export function validateEmbeddingManifest(manifest) {
645
913
  const origin = file.origin
646
914
  if (!isPlainObject(origin) || !PROVIDERS[origin.provider] || typeof origin.repo !== 'string' || !/^[0-9a-f]{40}$/.test(String(origin.revision))) {
647
915
  error('FILE_ORIGIN_INVALID', `file ${file.path} origin must pin provider/repo/revision`)
916
+ } else if (origin.providers !== undefined
917
+ && (!Array.isArray(origin.providers) || !origin.providers.length
918
+ || !origin.providers.every(id => PROVIDERS[id]) || !origin.providers.includes(origin.provider))) {
919
+ error('FILE_ORIGIN_INVALID', `file ${file.path} origin.providers must be a non-empty list of known providers that includes origin.provider`)
648
920
  }
649
921
  }
650
922
  }
@@ -652,9 +924,11 @@ export function validateEmbeddingManifest(manifest) {
652
924
  if (manifest.availability === 'available' && graphs.length !== 1) error('GRAPH_MISSING', 'exactly one file must have role graph')
653
925
  for (const graphFile of graphs) if (!String(graphFile.path || '').endsWith('.onnx')) error('GRAPH_NOT_ONNX', `graph file must be .onnx: ${graphFile.path}`)
654
926
 
655
- if (manifest.totalBytes !== undefined) {
656
- const actual = files.reduce((sum, file) => sum + (Number.isFinite(file.bytes) ? file.bytes : 0), 0)
657
- if (manifest.totalBytes !== actual) error('TOTAL_BYTES_MISMATCH', `totalBytes ${manifest.totalBytes} does not equal the sum of files ${actual}`)
927
+ // 目录构建器会给每条都补 totalBytes,而手写清单里那个「恰好等于文件之和」的值
928
+ // 本来就是同一份事实——只有对不上才是错误。否则加一条条目就得假装没写它。
929
+ const actual = files.reduce((sum, file) => sum + (Number.isFinite(file.bytes) ? file.bytes : 0), 0)
930
+ if (manifest.totalBytes !== undefined && manifest.totalBytes !== actual) {
931
+ error('TOTAL_BYTES_MISMATCH', `totalBytes ${manifest.totalBytes} does not equal the sum of files ${actual}`)
658
932
  }
659
933
  }
660
934
 
@@ -731,7 +1005,11 @@ export function resolveEmbeddingSources(idOrEntry, options = {}) {
731
1005
  let blocked = null
732
1006
  for (const file of files) {
733
1007
  const origin = file.origin
734
- if (origin && origin.provider !== providerId) {
1008
+ // 见证制品默认绑死它被核实的那个 provider。镜像站族(hf-mirror / huggingface 是同一
1009
+ // commit 的同一份内容)可以由 origin.providers 显式声明多个合法来源,否则换源会被
1010
+ // 这条规则整条封掉;无论哪个来源,落盘都要过同一个 sha256。
1011
+ const allowedProviders = origin && Array.isArray(origin.providers) && origin.providers.length ? origin.providers : [origin?.provider]
1012
+ if (origin && !allowedProviders.includes(providerId)) {
735
1013
  blocked = { provider: providerId, reason: 'origin-provider-mismatch', path: file.path, originProvider: origin.provider }
736
1014
  break
737
1015
  }