@matchbox-ai/train 0.2.1 → 0.3.0

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 (57) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{define-pipeline-D6I-jAE_.js → define-pipeline-DEkjmOte.js} +2 -1
  3. package/dist/define-pipeline-DEkjmOte.js.map +1 -0
  4. package/dist/index.js +2 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/load-project.d.ts +1 -0
  7. package/dist/load-project.d.ts.map +1 -1
  8. package/dist/models/presets.d.ts +2 -0
  9. package/dist/models/presets.d.ts.map +1 -1
  10. package/dist/models/sequence/export-parity.d.ts +16 -0
  11. package/dist/models/sequence/export-parity.d.ts.map +1 -0
  12. package/dist/models/sequence/fit-sequence.d.ts +25 -3
  13. package/dist/models/sequence/fit-sequence.d.ts.map +1 -1
  14. package/dist/models/sequence/prepare-supervision.d.ts +3 -3
  15. package/dist/models/sequence/prepare-supervision.d.ts.map +1 -1
  16. package/dist/models/sequence/run-sequence.d.ts +9 -1
  17. package/dist/models/sequence/run-sequence.d.ts.map +1 -1
  18. package/dist/models/sequence/types.d.ts +2 -0
  19. package/dist/models/sequence/types.d.ts.map +1 -1
  20. package/dist/native/fit.d.ts +4 -2
  21. package/dist/native/fit.d.ts.map +1 -1
  22. package/dist/pipeline/define-pipeline.d.ts +1 -0
  23. package/dist/pipeline/define-pipeline.d.ts.map +1 -1
  24. package/dist/project/artifact.d.ts +21 -1
  25. package/dist/project/artifact.d.ts.map +1 -1
  26. package/dist/project/config.d.ts +2 -0
  27. package/dist/project/config.d.ts.map +1 -1
  28. package/dist/project/index.js +1 -1
  29. package/dist/{project-BR13wXHr.js → project-CgNwV9Dj.js} +6 -4
  30. package/dist/project-CgNwV9Dj.js.map +1 -0
  31. package/dist/{run-PB_jiKnw.js → run-MgK9OCQv.js} +3 -3
  32. package/dist/{run-PB_jiKnw.js.map → run-MgK9OCQv.js.map} +1 -1
  33. package/dist/run.d.ts +9 -1
  34. package/dist/run.d.ts.map +1 -1
  35. package/dist/{sequence-DGoGU7kG.js → sequence-NevJFVwZ.js} +90 -37
  36. package/dist/sequence-NevJFVwZ.js.map +1 -0
  37. package/dist/train.d.ts +9 -1
  38. package/dist/train.d.ts.map +1 -1
  39. package/docs/contributing.md +36 -0
  40. package/docs/reference/configuration.md +11 -11
  41. package/docs/reference/pipeline.md +28 -0
  42. package/docs/reference/supervision.md +8 -1
  43. package/docs/reference/training.md +2 -0
  44. package/docs/research/sequence-context.json +12632 -0
  45. package/docs/research/sequence-context.md +66 -0
  46. package/package.json +3 -3
  47. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  48. package/prebuilds/darwin-x64/node.napi.node +0 -0
  49. package/prebuilds/linux-arm64/node.napi.glibc.node +0 -0
  50. package/prebuilds/linux-arm64/node.napi.musl.node +0 -0
  51. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  52. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  53. package/prebuilds/win32-arm64/node.napi.node +0 -0
  54. package/prebuilds/win32-x64/node.napi.node +0 -0
  55. package/dist/define-pipeline-D6I-jAE_.js.map +0 -1
  56. package/dist/project-BR13wXHr.js.map +0 -1
  57. package/dist/sequence-DGoGU7kG.js.map +0 -1
@@ -0,0 +1,66 @@
1
+ # Character encoding and context
2
+
3
+ A wider local window improved lexical recognition on the frozen test corpus, but whole-input abstention still prevents this model from being a useful lexer. Case preservation alone did not improve aggregate validation accuracy. Neither setting changes the default pipeline.
4
+
5
+ These are framework-local experiments with Burn, measured on September 16, 2026. They are separate from the [published-package consumer](https://github.com/alexpatow/matchbox-lexer). The [machine-readable evidence](sequence-context.json) contains dataset hashes, per-class metrics, confusion matrices, document counts, loss histories, training timings, and browser samples. Generated weights remain outside Git.
6
+
7
+ ## Method
8
+
9
+ Each experiment uses all 4,174 training records and 12,245,739 supervised Unicode code points from `full-clean-v1`. Vocabulary is fitted on training data only. The frozen validation set contains 336 records and 750,030 scored non-whitespace code points. The final test set contains 1,915 records and 1,446,363 scored non-whitespace code points.
10
+
11
+ The reference model uses published 0.2.2 weights. The two new models change one authored setting each. All use the same embedding-window MLP, eight-dimensional embeddings, 16 hidden units, Adam learning rate 0.005, batch size 128, seed 42, and 55 epochs. Increasing the context window also increases the first linear layer's parameter count. Casing and context were not combined in this experiment.
12
+
13
+ The context-four configuration was selected using validation, then evaluated once on the frozen test set. Its settings were not adjusted after that evaluation. Accuracy is character-weighted; styled macro F1 averages the eight non-plain labels equally. Diagnostic predictions bypass application acceptance, so these scores do not measure successful parser output.
14
+
15
+ ## Validation
16
+
17
+ | Configuration | Parameters | Artifact bytes | Token accuracy | Accepted inputs |
18
+ | ------------------------ | ---------: | -------------: | -------------: | --------------: |
19
+ | Lowercase, radius 1 | 12,625 | 77,516 | 59.86% | 0 / 336 |
20
+ | Preserved case, radius 1 | 13,081 | 80,189 | 59.43% | 0 / 336 |
21
+ | Lowercase, radius 4 | 13,393 | 81,595 | 61.58% | 0 / 336 |
22
+
23
+ Paired document bootstrap intervals use 2,000 resamples with seed 4231. The accuracy difference for case preservation is -0.43 percentage points, with a 95% interval of -1.28 to +0.24 points. The difference for radius four is +1.72 points, with an interval of -1.81 to +5.58 points. These intervals describe document sampling uncertainty, not variation across training seeds. The validation ranking alone is weak evidence of general improvement.
24
+
25
+ ## Frozen test
26
+
27
+ | Metric | Reference, radius 1 | Selected, radius 4 |
28
+ | -------------------------------- | ------------------: | -----------------: |
29
+ | Diagnostic token accuracy | 44.89% | 58.17% |
30
+ | Diagnostic styled macro F1 | 31.29% | 46.51% |
31
+ | Accepted inputs | 115 / 1,915 | 74 / 1,915 |
32
+ | Whole-input abstention | 93.99% | 96.14% |
33
+ | Exact structured output accuracy | 5.17% | 3.13% |
34
+
35
+ Better token recognition did not improve the application contract. The selected model abstains on 551 inputs at the unchanged 512 UTF-16-unit limit, abstains on 1,284 for low recognition confidence, and abstains on six for unknown vocabulary. Its 74 accepted inputs include only 60 exact outputs. Confidence remains uncalibrated, and every token must meet the threshold before the parser returns a result.
36
+
37
+ ## Training and browser cost
38
+
39
+ Both new models trained on an 8 GB Apple M2 using native Burn CPU. Native fit includes the binding call and weight serialization; process wall time also includes preparation and validation diagnostics.
40
+
41
+ | Configuration | Native fit | Process wall time | Peak resident memory |
42
+ | ------------------------ | ---------: | ----------------: | -------------------: |
43
+ | Preserved case, radius 1 | 501.03 s | 505.76 s | 1,169,162,240 bytes |
44
+ | Lowercase, radius 4 | 585.92 s | 594.24 s | 1,437,974,528 bytes |
45
+
46
+ The historical reference ran through the full published CLI, so its total training time is not an equivalent isolated fit measurement. These runs measure local development costs, not an isolated hardware benchmark.
47
+
48
+ Browser measurements use fresh headless Chromium contexts, five warmups, and 30 calls per input length. Inputs are fixed 128- and 512-unit prefixes selected from validation. Initialization excludes JavaScript import and artifact fetch. Timing covers diagnostic token inference, including tokenization, but excludes decoding and parser acceptance.
49
+
50
+ | Configuration | Initialization | 128 units p50 / p95 | 512 units p50 / p95 |
51
+ | ------------------------ | -------------: | ------------------: | ------------------: |
52
+ | Lowercase, radius 1 | 36.5 ms | 0.2 / 0.9 ms | 0.5 / 0.7 ms |
53
+ | Preserved case, radius 1 | 29.3 ms | 0.2 / 0.5 ms | 0.6 / 0.7 ms |
54
+ | Lowercase, radius 4 | 36.4 ms | 0.3 / 3.3 ms | 0.7 / 2.5 ms |
55
+
56
+ Small samples, timer resolution, garbage collection, and initialization variability limit these timing comparisons. Artifact sizes exclude the shared WASM runtime and authored decoder.
57
+
58
+ Native and WASM agree on labels and threshold decisions for all 945,166 export-probe tokens in both new models. Maximum confidence differences remain below the existing 0.0001 tolerance. The selected model also passes parity on all 1,841,059 test tokens, including whitespace.
59
+
60
+ ## Implications
61
+
62
+ `casing: "preserve"` makes an information-preserving encoding available explicitly. It should not be enabled automatically on the assumption that it improves a task. `tokenClassifier({ contextRadius: 4 })` provides more local evidence at modest model-size cost, but a nine-character window cannot recover long-range lexical state.
63
+
64
+ The pinned [gpu-lexer architecture](https://github.com/vercel-labs/gpu-lexer/blob/1e514fd681e31d6b19296f985fb01d8fdc0ae74f/architecture.md) uses bidirectional learned state and whole-source context. This experiment does not reproduce that architecture or its training history. A materially different sequence model should have its own learning primitive rather than accumulate architecture switches in the fixed-window classifier.
65
+
66
+ See the [reproduction workflow](../contributing.md#sequence-context-experiments) and the [public context contract](../reference/pipeline.md#token-context).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matchbox-ai/train",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -47,13 +47,13 @@
47
47
  "zod": "4.6.3"
48
48
  },
49
49
  "devDependencies": {
50
- "@matchbox-ai/core": "0.2.1",
50
+ "@matchbox-ai/core": "0.3.0",
51
51
  "@types/node": "22.20.2",
52
52
  "rolldown": "1.2.8",
53
53
  "typescript": "7.0.2"
54
54
  },
55
55
  "peerDependencies": {
56
- "@matchbox-ai/core": "0.2.1"
56
+ "@matchbox-ai/core": "0.3.0"
57
57
  },
58
58
  "engines": {
59
59
  "bun": ">=1.4.2",
Binary file
Binary file
@@ -1 +0,0 @@
1
- {"version":3,"file":"define-pipeline-D6I-jAE_.js","names":[],"sources":["../src/pipeline/define-pipeline.ts"],"sourcesContent":["import { z } from \"zod\";\nexport const pipelineSchema = z.strictObject({\n prediction: z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"field-classifier\") }),\n z.strictObject({\n kind: z.literal(\"token-classifier\"),\n recipe: z.string().min(1).default(\"./recipe\"),\n decode: z.string().min(1).default(\"./decode\"),\n }),\n ]),\n acceptance: z\n .strictObject({\n minAccuracy: z.number().min(0).max(1).optional(),\n maxBytes: z.number().positive().optional(),\n })\n .optional(),\n});\nexport type Pipeline = z.infer<typeof pipelineSchema>;\nexport function definePipeline(pipeline: Pipeline): Pipeline {\n return pipelineSchema.parse(pipeline);\n}\n"],"mappings":";;AACA,MAAa,iBAAiB,EAAE,aAAa;CAC3C,YAAY,EAAE,mBAAmB,QAAQ,CACvC,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,kBAAkB,EAAE,CAAC,GACtD,EAAE,aAAa;EACb,MAAM,EAAE,QAAQ,kBAAkB;EAClC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,UAAU;EAC5C,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,UAAU;CAC9C,CAAC,CACH,CAAC;CACD,YAAY,EACT,aAAa;EACZ,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;EAC/C,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAC3C,CAAC,CAAC,CACD,SAAS;AACd,CAAC;AAED,SAAgB,eAAe,UAA8B;CAC3D,OAAO,eAAe,MAAM,QAAQ;AACtC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-BR13wXHr.js","names":[],"sources":["../src/project/entry.ts","../src/project/config.ts","../src/project/discover.ts","../src/project/artifact.ts"],"sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { basename, extname, resolve } from \"node:path\";\nasync function isFile(path: string): Promise<boolean> {\n try {\n return (await stat(path)).isFile();\n } catch (error) {\n if ([\"ENOENT\", \"ENOTDIR\"].includes((error as NodeJS.ErrnoException).code ?? \"\")) {\n return false;\n }\n throw error;\n }\n}\n/** Named task modules have one flat or directory-backed TypeScript entry point. */\nexport async function findEntry(root: string, name: string): Promise<string | undefined> {\n const base = resolve(root, name);\n const candidates = [`${base}.ts`, resolve(base, `${basename(base)}.ts`)];\n const found = (await Promise.all(candidates.map(isFile)))\n .map((exists, index) => (exists ? candidates[index] : undefined))\n .filter((path): path is string => path !== undefined);\n if (found.length > 1) {\n throw new Error(`Conflicting task entry points: ${found.join(\" and \")}. Keep only one.`);\n }\n return found[0];\n}\n/** Explicit filenames stay exact; extensionless references use the named entry convention. */\nexport async function resolveModule(root: string, reference: string): Promise<string> {\n if (extname(reference)) {\n return resolve(root, reference);\n }\n // Missing training modules are reported when imported, so artifact evaluation needs no recipe.\n return (await findEntry(root, reference)) ?? resolve(root, `${reference}.ts`);\n}\n","import { access, stat } from \"node:fs/promises\";\nimport { basename, dirname, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { z } from \"zod\";\nimport { findEntry, resolveModule } from \"./entry.js\";\nimport { pipelineSchema } from \"../pipeline/index.js\";\nexport const configSchema = z.strictObject({\n task: z.string().default(\"./parser\"),\n train: z.string().default(\"./data/train.jsonl\"),\n validation: z.string().default(\"./evals/validation.jsonl\"),\n eval: z.string().default(\"./evals/test.jsonl\"),\n output: z.string().endsWith(\".matchbox\"),\n minAccuracy: z.number().min(0).max(1).default(0.95),\n maxBytes: z.number().positive().default(64000),\n sequence: z.strictObject({ recipe: z.string(), decoder: z.string() }).optional(),\n challenges: z.string().optional(),\n});\nexport async function loadConfig(path: string) {\n const directory = (await stat(path)).isDirectory();\n const root = directory ? resolve(path) : dirname(resolve(path));\n const exists = (file: string) =>\n access(resolve(root, file)).then(\n () => true,\n () => false,\n );\n const configPath = directory ? resolve(root, \"matchbox.config.ts\") : resolve(path);\n const authored = await access(configPath).then(\n async () => (await import(pathToFileURL(configPath).href)).default,\n () => ({}),\n );\n let defaults: Record<string, unknown> = {};\n const pipelinePath = await findEntry(root, \"pipeline\");\n if (pipelinePath) {\n const pipeline = pipelineSchema.parse((await import(pathToFileURL(pipelinePath).href)).default);\n defaults = { ...pipeline.acceptance };\n if (pipeline.prediction.kind === \"token-classifier\") {\n defaults.sequence = {\n recipe: pipeline.prediction.recipe,\n decoder: pipeline.prediction.decode,\n };\n }\n } else if (!authored.sequence) {\n throw new Error(\n `Missing pipeline.ts or pipeline/pipeline.ts in ${root}. Author an explicit pipeline before training.`,\n );\n }\n const config = configSchema.parse({\n output: resolve(root, \"../../.matchbox\", basename(root), \"model.matchbox\"),\n ...defaults,\n ...authored,\n });\n if (!config.challenges && (await exists(\"evals/challenges.json\"))) {\n config.challenges = \"./evals/challenges.json\";\n }\n config.task = await resolveModule(root, config.task);\n if (config.sequence) {\n config.sequence.recipe = await resolveModule(root, config.sequence.recipe);\n config.sequence.decoder = await resolveModule(root, config.sequence.decoder);\n }\n return { config, root, pipelinePath };\n}\n","import { access, readdir, stat } from \"node:fs/promises\";\nimport { findEntry } from \"./entry.js\";\nimport { basename, dirname, resolve } from \"node:path\";\nconst exists = (path: string) =>\n access(path).then(\n () => true,\n () => false,\n );\nasync function select(root: string): Promise<string | undefined> {\n // A parser/parser.ts module directory is inside its task, not a second task.\n if (\n basename(root) === \"parser\" &&\n (await findEntry(dirname(root), \"pipeline\")) &&\n (await findEntry(dirname(root), \"parser\")) === resolve(root, \"parser.ts\")\n ) {\n return dirname(root);\n }\n if (await findEntry(root, \"parser\")) {\n return root;\n }\n if (await exists(resolve(root, \"matchbox.config.ts\"))) {\n return resolve(root, \"matchbox.config.ts\");\n }\n const tasks = await listTasks(root);\n const directory = resolve(root, \"matchbox\");\n if (tasks.length > 1) {\n throw new Error(\n `Choose a task: ${tasks.join(\", \")}. For example, matchbox-ai train ${tasks[0]}.`,\n );\n }\n return tasks.length ? resolve(directory, tasks[0]!) : undefined;\n}\nexport async function discover(target?: string, cwd = process.cwd()): Promise<string> {\n if (target && (await exists(resolve(cwd, target)))) {\n const path = resolve(cwd, target);\n if ((await stat(path)).isFile()) {\n return path;\n }\n const selected = await select(path);\n if (selected) {\n return selected;\n }\n throw new Error(`No Matchbox task found in ${path}.`);\n }\n let root = resolve(cwd);\n for (;;) {\n if (target) {\n const task = resolve(root, \"matchbox\", target);\n if (await findEntry(task, \"parser\")) {\n return task;\n }\n } else {\n const selected = await select(root);\n if (selected) {\n return selected;\n }\n }\n const parent = dirname(root);\n if (parent === root) {\n throw new Error(\n target\n ? `Task not found: ${target}.`\n : \"No Matchbox project found. Run matchbox-ai init <name>.\",\n );\n }\n root = parent;\n }\n}\n\n/** Lists conventional tasks immediately beneath an application’s matchbox directory. */\nexport async function listTasks(root: string): Promise<string[]> {\n const directory = resolve(root, \"matchbox\");\n const entries = await readdir(directory, { withFileTypes: true }).catch(() => []);\n const tasks: string[] = [];\n for (const entry of entries) {\n if (entry.isDirectory() && (await findEntry(resolve(directory, entry.name), \"parser\"))) {\n tasks.push(entry.name);\n }\n }\n return tasks.sort();\n}\n","import { readFile } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { createParser } from \"@matchbox-ai/core/runtime\";\nimport { readArtifact, tensorPredictor } from \"@matchbox-ai/core/internal\";\nimport type { SequenceDecoder } from \"@matchbox-ai/core/runtime\";\nimport type { ParserDefinition } from \"@matchbox-ai/core\";\nimport type { z } from \"zod\";\nimport { loadConfig } from \"./config.js\";\nexport async function loadArtifact(configPath: string) {\n const { config, root } = await loadConfig(configPath);\n const output = resolve(root, config.output);\n const text = await readFile(output, \"utf8\").catch(() => {\n throw new Error(`No readable model at ${output}. Run matchbox-ai train first.`);\n });\n const artifact = readArtifact(JSON.parse(text));\n const task: ParserDefinition<z.ZodType> = (\n await import(pathToFileURL(resolve(dirname(output), artifact.taskModule)).href)\n ).default;\n const decode: SequenceDecoder | undefined =\n artifact.decoderModule === null\n ? undefined\n : (await import(pathToFileURL(resolve(dirname(output), artifact.decoderModule)).href))\n .default;\n return {\n artifact,\n task,\n decode,\n parser: createParser(artifact, task, decode),\n inspect: async (input: string) => {\n const predictor = await tensorPredictor(artifact);\n try {\n if (artifact.kind === \"record-parser\") {\n return predictor.record(input);\n }\n const tokens = predictor.sequence(input);\n return { tokens, candidate: decode!(tokens, input) };\n } finally {\n predictor.dispose();\n }\n },\n output,\n config,\n root,\n };\n}\n"],"mappings":";;;;;;;;AAEA,eAAe,OAAO,MAAgC;CACpD,IAAI;EACF,QAAQ,MAAM,KAAK,IAAI,EAAA,CAAG,OAAO;C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D,IAAI;IACF,IAAI,SAAS,SAAS,iBACpB,OAAO,UAAU,OAAO,KAAK;IAE/B,MAAM,SAAS,UAAU,SAAS,KAAK;IACvC,OAAO;KAAE;KAAQ,WAAW,OAAQ,QAAQ,KAAK;IAAE;GACrD,UAAU;IACR,UAAU,QAAQ;GACpB;EACF;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sequence-DGoGU7kG.js","names":["evaluateSequence","evaluate"],"sources":["../src/native/fit.ts","../src/models/sequence/prepare-supervision.ts","../src/models/sequence/fit-sequence.ts","../src/models/sequence/run-sequence.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\ninterface NativeResult {\n parameters: number;\n weights: Uint8Array;\n loss: number[];\n}\nconst require = createRequire(import.meta.url);\nexport function predict(\n config: { vocabularySize: number; labelCount: number },\n weights: Uint8Array,\n inputs: number[][],\n): number[] {\n const native = require(\"#native\") as {\n predict(config: string, weights: Buffer, inputs: Int32Array): number[];\n };\n return native.predict(\n JSON.stringify(config),\n Buffer.from(weights),\n Int32Array.from(inputs.flat()),\n );\n}\nexport function fit(\n config: { vocabularySize: number; labelCount: number },\n inputs: number[][],\n labels: number[],\n progress?: (epoch: number, loss: number) => void,\n): Promise<NativeResult> {\n const native = require(\"#native\") as {\n fit(\n config: string,\n inputs: Int32Array,\n labels: Int32Array,\n progress: (error: Error | null, value: number[]) => void,\n ): Promise<NativeResult>;\n };\n return native.fit(\n JSON.stringify(config),\n Int32Array.from(inputs.flat()),\n Int32Array.from(labels),\n (error, value) => {\n if (!error) {\n progress?.(value[0]!, value[1]!);\n }\n },\n );\n}\n","import { tokenize, windows } from \"@matchbox-ai/core/internal\";\nimport type { DatasetExample } from \"@matchbox-ai/core\";\nimport type { SequenceRecipe } from \"./types.js\";\nexport function prepareSupervision(\n examples: readonly DatasetExample<unknown>[],\n recipe: SequenceRecipe,\n) {\n const vocabulary = [\n ...new Set(\n examples.flatMap((row) => tokenize(row.input, recipe.tokenizer).map((token) => token.key)),\n ),\n ].sort();\n const radius = 1;\n const dropout = recipe.tokenDropout ?? 0;\n if (!Number.isFinite(dropout) || dropout < 0 || dropout > 0.5) {\n throw new Error(\"tokenDropout must be between 0 and 0.5.\");\n }\n let maskingSeed = 7043;\n const random = () => {\n maskingSeed = (Math.imul(maskingSeed, 1664525) + 1013904223) >>> 0;\n return maskingSeed / 4294967296;\n };\n const inputs: number[][] = [];\n const labels: number[] = [];\n for (const example of examples) {\n const tokens = tokenize(example.input, recipe.tokenizer);\n const annotations = recipe.annotate(example, tokens);\n if (annotations.length !== tokens.length) {\n throw new Error(`Annotation length mismatch: ${example.input}`);\n }\n windows(tokens, vocabulary, radius).forEach((window, position) => {\n const label = annotations[position];\n if (label === null) {\n return;\n }\n const id = recipe.labels.indexOf(label!);\n if (id < 0) {\n throw new Error(`Unknown annotation ${label}: ${example.input}`);\n }\n inputs.push(window);\n labels.push(id);\n if (dropout > 0) {\n inputs.push(window.map((id) => (id > 1 && random() < dropout ? 1 : id)));\n labels.push(id);\n }\n });\n }\n if (recipe.labels.some((_, id) => !labels.includes(id))) {\n throw new Error(\"Every label needs supervised training examples.\");\n }\n // Mix currency/template blocks deterministically before minibatch optimization.\n maskingSeed = 9187;\n for (let index = inputs.length - 1; index > 0; index--) {\n const other = Math.floor(random() * (index + 1));\n [inputs[index], inputs[other]] = [inputs[other]!, inputs[index]!];\n [labels[index], labels[other]] = [labels[other]!, labels[index]!];\n }\n return { vocabulary, radius, dropout, inputs, labels };\n}\n","import { prepareSupervision } from \"./prepare-supervision.js\";\nimport { fit, predict } from \"../../native/index.js\";\nimport { tensorPredictor, tokenize, windows } from \"@matchbox-ai/core/internal\";\nimport type { SequenceArtifact } from \"@matchbox-ai/core/internal\";\nimport type { DatasetExample } from \"@matchbox-ai/core\";\nimport type { SequenceRecipe } from \"./types.js\";\nexport async function fitSequence(\n examples: readonly DatasetExample<unknown>[],\n recipe: SequenceRecipe,\n metadata: Pick<SequenceArtifact, \"taskModule\" | \"taskMetadata\" | \"decoderModule\">,\n probes: readonly string[] = [],\n progress?: (epoch: number, loss: number) => void,\n) {\n const { vocabulary, radius, dropout, inputs, labels } = prepareSupervision(examples, recipe);\n const result = await fit(\n { vocabularySize: vocabulary.length + 2, labelCount: recipe.labels.length },\n inputs,\n labels,\n progress,\n );\n const artifact = (weights: Uint8Array): SequenceArtifact => ({\n formatVersion: 3,\n engine: \"burn-0.21\",\n kind: \"sequence-parser\",\n architecture: \"embedding-window-mlp\",\n ...metadata,\n tokenizer: recipe.tokenizer,\n readout: recipe.readout,\n vocabulary,\n labels: [...recipe.labels],\n radius: radius as 1,\n unknownTokens: dropout > 0 ? \"predict\" : \"abstain\",\n threshold: 0.75,\n precision: \"float32\",\n weights: Buffer.from(weights).toString(\"base64\"),\n });\n const model = artifact(result.weights);\n const checked = [...examples.slice(0, 16).map((row) => row.input), ...probes];\n const portable = await tensorPredictor(model);\n let maxConfidenceError = 0;\n let labelDisagreements = 0;\n try {\n for (const input of checked) {\n const tokens = tokenize(input, recipe.tokenizer);\n if (!tokens.length) {\n continue;\n }\n const scores = predict(\n { vocabularySize: vocabulary.length + 2, labelCount: recipe.labels.length },\n result.weights,\n windows(tokens, vocabulary, radius),\n );\n portable.sequence(input).forEach((token, index) => {\n const row = scores.slice(index * recipe.labels.length, (index + 1) * recipe.labels.length);\n const confidence = Math.max(...row);\n maxConfidenceError = Math.max(maxConfidenceError, Math.abs(confidence - token.confidence));\n if (recipe.labels[row.indexOf(confidence)] !== token.label) {\n labelDisagreements++;\n }\n });\n }\n } finally {\n portable.dispose();\n }\n if (labelDisagreements || maxConfidenceError > 1e-5) {\n throw new Error(\"Burn native and WASM predictions disagree.\");\n }\n return {\n model,\n parameters: result.parameters,\n history: result.loss,\n parity: { examples: checked.length, maxConfidenceError, labelDisagreements },\n supervisedTokens: inputs.length,\n };\n}\n","import { sameOutput } from \"../../evaluation/same-output.js\";\nimport { z } from \"zod\";\nimport { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { dirname, relative, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { createParser } from \"@matchbox-ai/core/runtime\";\nimport { readSequenceArtifact, tokenize } from \"@matchbox-ai/core/internal\";\nimport type { DatasetExample } from \"@matchbox-ai/core\";\nimport type { MatchboxParser, SequenceDecoder } from \"@matchbox-ai/core/runtime\";\nimport type { loadProject } from \"../../load-project.js\";\nimport { packageModel } from \"../../packaging/package-model.js\";\nimport { fitSequence } from \"./fit-sequence.js\";\nimport { evaluateSequence as evaluate } from \"../../evaluation/evaluate-sequence.js\";\nimport type { SequenceRecipe } from \"./types.js\";\nconst hash = (value: string) => createHash(\"sha256\").update(value).digest(\"hex\");\nexport async function runSequence(\n command: \"train\" | \"eval\",\n project: Awaited<ReturnType<typeof loadProject>>,\n progress?: (epoch: number, loss: number) => void,\n) {\n const { task, config } = project;\n const root = project.root;\n const sequence = config.sequence;\n if (!sequence) {\n throw new Error(\"A sequence pipeline needs both recipe and decoder modules.\");\n }\n const savedArtifact =\n command === \"eval\"\n ? readSequenceArtifact(JSON.parse(await readFile(project.output, \"utf8\")))\n : null;\n const decoderPath = savedArtifact\n ? resolve(dirname(project.output), savedArtifact.decoderModule)\n : resolve(root, sequence.decoder);\n const decode: SequenceDecoder = (await import(pathToFileURL(decoderPath).href)).default;\n const evaluateSequence = (\n parser: MatchboxParser<unknown>,\n examples: readonly DatasetExample<unknown>[],\n ) =>\n evaluate(parser, examples, (value) => task.validateOutput(value).success).finally(() => {\n if (\"dispose\" in parser && typeof parser.dispose === \"function\") {\n parser.dispose();\n }\n });\n const parser = (artifact: unknown) => createParser(artifact, task, decode);\n if (savedArtifact) {\n return { evaluation: await evaluateSequence(parser(savedArtifact), project.evaluation) };\n }\n const recipe: SequenceRecipe = (await import(pathToFileURL(resolve(root, sequence.recipe)).href))\n .default;\n const modulePath = (path: string) => {\n const value = relative(dirname(project.output), path).replaceAll(\"\\\\\", \"/\");\n return value.startsWith(\".\") ? value : `./${value}`;\n };\n const rejections = z\n .array(z.strictObject({ input: z.string(), output: z.null() }))\n .parse(recipe.rejections ?? []);\n const training = [...project.train, ...rejections];\n const heldOut = new Set(\n [...project.validation, ...project.evaluation].map((row) => row.input.trim().toLowerCase()),\n );\n for (const example of training) {\n if (!task.validateInput(example.input).success) {\n throw new Error(`Invalid training input: ${example.input}`);\n }\n if (heldOut.has(example.input.trim().toLowerCase())) {\n throw new Error(`Training input overlaps evaluation: ${example.input}`);\n }\n const tokens = tokenize(example.input, recipe.tokenizer);\n const labels = recipe.annotate(example, tokens);\n const value = decode(\n tokens.map((token, index) => ({ ...token, label: labels[index] ?? \"O\", confidence: 1 })),\n example.input,\n );\n if (!sameOutput(value, example.output)) {\n throw new Error(\n `Training annotations do not decode to the supplied output: ${example.input}`,\n );\n }\n }\n const started = performance.now();\n const fit = await fitSequence(\n training,\n recipe,\n {\n taskMetadata: task.toJSON(),\n taskModule: modulePath(project.taskPath),\n decoderModule: modulePath(resolve(root, sequence.decoder)),\n },\n project.validation.map((row) => row.input),\n progress,\n );\n const validation = await evaluateSequence(parser(fit.model), project.validation);\n const bytes = Buffer.byteLength(JSON.stringify(fit.model));\n if (validation.exactAccuracy < config.minAccuracy || bytes > config.maxBytes) {\n throw new Error(\n `Sequence model failed validation/size requirements (${validation.exactAccuracy}, ${bytes} bytes). ${JSON.stringify(validation.failures.slice(0, 10))}`,\n );\n }\n const challenges = config.challenges\n ? z\n .array(z.strictObject({ input: z.string(), output: z.null() }))\n .min(1)\n .parse(JSON.parse(await readFile(resolve(root, config.challenges), \"utf8\")))\n : null;\n const report = {\n formatVersion: 2,\n architecture: fit.model.architecture,\n backend: \"Burn native CPU\",\n seed: 42,\n artifactSha256: hash(JSON.stringify(fit.model)),\n bytes,\n parameters: fit.parameters,\n datasetSha256: project.sources.map((source) => ({\n source: source.source,\n sha256: hash(source.text),\n })),\n examples: {\n train: project.train.length,\n rejections: recipe.rejections?.length ?? 0,\n validation: project.validation.length,\n eval: project.evaluation.length,\n },\n supervisionSha256: hash(\n JSON.stringify(\n training.map((row) => ({\n ...row,\n labels: recipe.annotate(row, tokenize(row.input, recipe.tokenizer)),\n })),\n ),\n ),\n supervisedTokens: fit.supervisedTokens,\n loss: fit.history,\n exportParity: fit.parity,\n validation,\n evaluation: await evaluateSequence(parser(fit.model), project.evaluation),\n challenges: challenges ? await evaluateSequence(parser(fit.model), challenges) : null,\n trainingMs: performance.now() - started,\n notes:\n \"Float32 weights in a Burn binary record, base64-encoded in the artifact. Validation gates export. Eval labels do not influence selection. Scores are uncalibrated.\",\n };\n await packageModel(project.output, fit.model, report);\n return { report, output: project.output };\n}\n"],"mappings":";;;;;;;;;;;AAMA,MAAM,UAAU,cAAc,YAAY,GAAG;AAC7C,SAAgB,QACd,QACA,SACA,QACU;CAIV,OAHe,QAAQ,SAGX,CAAC,CAAC,QACZ,KAAK,UAAU,MAAM,GACrB,OAAO,KAAK,OAAO,GACnB,WAAW,KAAK,OAAO,KAAK,CAAC,CAC/B;AACF;AACA,SAAgB,IACd,QACA,QACA,QACA,UACuB;CASvB,OARe,QAAQ,SAQX,CAAC,CAAC,IACZ,KAAK,UAAU,MAAM,GACrB,WAAW,KAAK,OAAO,KAAK,CAAC,GAC7B,WAAW,KAAK,MAAM,IACrB,OAAO,UAAU;EAChB,IAAI,CAAC,OACH,WAAW,MAAM,IAAK,MAAM,EAAG;CAEnC,CACF;AACF;;;AC1CA,SAAgB,mBACd,UACA,QACA;CACA,MAAM,aAAa,CACjB,GAAG,IAAI,IACL,SAAS,SAAS,QAAQ,SAAS,IAAI,OAAO,OAAO,SAAS,CAAC,CAAC,KAAK,UAAU,MAAM,GAAG,CAAC,CAC3F,CACF,CAAC,CAAC,KAAK;CACP,MAAM,SAAS;CACf,MAAM,UAAU,OAAO,gBAAgB;CACvC,IAAI,CAAC,OAAO,SAAS,OAAO,KAAK,UAAU,KAAK,UAAU,IACxD,MAAM,IAAI,MAAM,yCAAyC;CAE3D,IAAI,cAAc;CAClB,MAAM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