@matchbox-ai/train 0.2.2 → 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.
- package/CHANGELOG.md +13 -0
- package/dist/{define-pipeline-D6I-jAE_.js → define-pipeline-DEkjmOte.js} +2 -1
- package/dist/define-pipeline-DEkjmOte.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/load-project.d.ts +1 -0
- package/dist/load-project.d.ts.map +1 -1
- package/dist/models/presets.d.ts +2 -0
- package/dist/models/presets.d.ts.map +1 -1
- package/dist/models/sequence/fit-sequence.d.ts +21 -2
- package/dist/models/sequence/fit-sequence.d.ts.map +1 -1
- package/dist/models/sequence/prepare-supervision.d.ts +3 -3
- package/dist/models/sequence/prepare-supervision.d.ts.map +1 -1
- package/dist/models/sequence/run-sequence.d.ts +5 -0
- package/dist/models/sequence/run-sequence.d.ts.map +1 -1
- package/dist/models/sequence/types.d.ts +2 -0
- package/dist/models/sequence/types.d.ts.map +1 -1
- package/dist/native/fit.d.ts +4 -2
- package/dist/native/fit.d.ts.map +1 -1
- package/dist/pipeline/define-pipeline.d.ts +1 -0
- package/dist/pipeline/define-pipeline.d.ts.map +1 -1
- package/dist/project/artifact.d.ts +21 -1
- package/dist/project/artifact.d.ts.map +1 -1
- package/dist/project/config.d.ts +2 -0
- package/dist/project/config.d.ts.map +1 -1
- package/dist/project/index.js +1 -1
- package/dist/{project-BR13wXHr.js → project-CgNwV9Dj.js} +6 -4
- package/dist/project-CgNwV9Dj.js.map +1 -0
- package/dist/{run-Y4hS_j62.js → run-MgK9OCQv.js} +3 -3
- package/dist/{run-Y4hS_j62.js.map → run-MgK9OCQv.js.map} +1 -1
- package/dist/run.d.ts +5 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/{sequence-CZLL5c0A.js → sequence-NevJFVwZ.js} +54 -30
- package/dist/sequence-NevJFVwZ.js.map +1 -0
- package/dist/train.d.ts +5 -0
- package/dist/train.d.ts.map +1 -1
- package/docs/contributing.md +22 -0
- package/docs/reference/configuration.md +11 -11
- package/docs/reference/pipeline.md +28 -0
- package/docs/reference/supervision.md +8 -1
- package/docs/research/sequence-context.json +12632 -0
- package/docs/research/sequence-context.md +66 -0
- package/package.json +3 -3
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-arm64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-arm64/node.napi.musl.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-arm64/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/dist/define-pipeline-D6I-jAE_.js.map +0 -1
- package/dist/project-BR13wXHr.js.map +0 -1
- package/dist/sequence-CZLL5c0A.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @matchbox-ai/train
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6158277: Add explicit case preservation to token recipes and configurable context radius to token classifiers. Native Burn training and WASM inference use the same serialized encoding and window shape. Existing recipes retain lowercase keys and a radius of one, and the runtime continues to read version 3 sequence artifacts.
|
|
8
|
+
|
|
9
|
+
Store training windows in packed integer arrays to limit preparation memory for larger corpora and wider contexts.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [6158277]
|
|
14
|
+
- @matchbox-ai/core@0.3.0
|
|
15
|
+
|
|
3
16
|
## 0.2.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -4,6 +4,7 @@ const pipelineSchema = z.strictObject({
|
|
|
4
4
|
prediction: z.discriminatedUnion("kind", [z.strictObject({ kind: z.literal("field-classifier") }), z.strictObject({
|
|
5
5
|
kind: z.literal("token-classifier"),
|
|
6
6
|
recipe: z.string().min(1).default("./recipe"),
|
|
7
|
+
contextRadius: z.number().int().min(1).max(16).optional(),
|
|
7
8
|
decode: z.string().min(1).default("./decode")
|
|
8
9
|
})]),
|
|
9
10
|
acceptance: z.strictObject({
|
|
@@ -17,4 +18,4 @@ function definePipeline(pipeline) {
|
|
|
17
18
|
//#endregion
|
|
18
19
|
export { pipelineSchema as n, definePipeline as t };
|
|
19
20
|
|
|
20
|
-
//# sourceMappingURL=define-pipeline-
|
|
21
|
+
//# sourceMappingURL=define-pipeline-DEkjmOte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-pipeline-DEkjmOte.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 contextRadius: z.number().int().min(1).max(16).optional(),\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,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS;EACxD,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"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as definePipeline } from "./define-pipeline-
|
|
1
|
+
import { t as definePipeline } from "./define-pipeline-DEkjmOte.js";
|
|
2
2
|
import { t as evaluateSequence } from "./evaluate-sequence-ZCwyomzQ.js";
|
|
3
3
|
import { tokenize } from "@matchbox-ai/core/internal";
|
|
4
4
|
//#region src/models/presets.ts
|
|
@@ -20,7 +20,7 @@ function tokenClassifier(options = {}) {
|
|
|
20
20
|
/** Runs the same validation, selection, and packaging pipeline as the CLI. */
|
|
21
21
|
async function train(target, options = {}) {
|
|
22
22
|
const { discover } = await import("./project/index.js");
|
|
23
|
-
const { run } = await import("./run-
|
|
23
|
+
const { run } = await import("./run-MgK9OCQv.js");
|
|
24
24
|
return run("train", await discover(target), options.onProgress);
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/models/presets.ts","../src/train.ts"],"sourcesContent":["/** Independent field classification over training values. Numeric outputs are finite classes. */\nexport function fieldClassifier() {\n return { kind: \"field-classifier\" } as const;\n}\n/** Application-owned span supervision and deterministic decoding. Paths are relative to the task directory. */\nexport function tokenClassifier(options: { recipe?: string; decode?: string } = {}) {\n return { kind: \"token-classifier\", recipe: \"./recipe\", decode: \"./decode\", ...options } as const;\n}\n","/** Runs the same validation, selection, and packaging pipeline as the CLI. */\nexport async function train(\n target: string,\n options: { onProgress?: (epoch: number, loss: number) => void } = {},\n) {\n const { discover } = await import(\"./project/index.js\");\n const { run } = await import(\"./run.js\");\n return run(\"train\", await discover(target), options.onProgress);\n}\n"],"mappings":";;;;;AACA,SAAgB,kBAAkB;CAChC,OAAO,EAAE,MAAM,mBAAmB;AACpC;;AAEA,SAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/models/presets.ts","../src/train.ts"],"sourcesContent":["/** Independent field classification over training values. Numeric outputs are finite classes. */\nexport function fieldClassifier() {\n return { kind: \"field-classifier\" } as const;\n}\n/** Application-owned span supervision and deterministic decoding. Paths are relative to the task directory. */\nexport function tokenClassifier(\n options: { recipe?: string; decode?: string; contextRadius?: number } = {},\n) {\n return { kind: \"token-classifier\", recipe: \"./recipe\", decode: \"./decode\", ...options } as const;\n}\n","/** Runs the same validation, selection, and packaging pipeline as the CLI. */\nexport async function train(\n target: string,\n options: { onProgress?: (epoch: number, loss: number) => void } = {},\n) {\n const { discover } = await import(\"./project/index.js\");\n const { run } = await import(\"./run.js\");\n return run(\"train\", await discover(target), options.onProgress);\n}\n"],"mappings":";;;;;AACA,SAAgB,kBAAkB;CAChC,OAAO,EAAE,MAAM,mBAAmB;AACpC;;AAEA,SAAgB,gBACd,UAAwE,CAAC,GACzE;CACA,OAAO;EAAE,MAAM;EAAoB,QAAQ;EAAY,QAAQ;EAAY,GAAG;CAAQ;AACxF;;;;ACRA,eAAsB,MACpB,QACA,UAAkE,CAAC,GACnE;CACA,MAAM,EAAE,aAAa,MAAM,OAAO;CAClC,MAAM,EAAE,QAAQ,MAAM,OAAO;CAC7B,OAAO,IAAI,SAAS,MAAM,SAAS,MAAM,GAAG,QAAQ,UAAU;AAChE"}
|
package/dist/load-project.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-project.d.ts","sourceRoot":"","sources":["../src/load-project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"load-project.d.ts","sourceRoot":"","sources":["../src/load-project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkD7C"}
|
package/dist/models/presets.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export declare function fieldClassifier(): {
|
|
|
6
6
|
export declare function tokenClassifier(options?: {
|
|
7
7
|
recipe?: string;
|
|
8
8
|
decode?: string;
|
|
9
|
+
contextRadius?: number;
|
|
9
10
|
}): {
|
|
11
|
+
readonly contextRadius?: number;
|
|
10
12
|
readonly kind: "token-classifier";
|
|
11
13
|
recipe: string;
|
|
12
14
|
decode: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/models/presets.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,wBAAgB,eAAe;aACpB,IAAI,EAAE,kBAAkB;EAClC;AACD,+GAA+G;AAC/G,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/models/presets.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,wBAAgB,eAAe;aACpB,IAAI,EAAE,kBAAkB;EAClC;AACD,+GAA+G;AAC/G,wBAAgB,eAAe,CAC7B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO;6BAAb,MAAM;mBAEpD,kBAAkB;;;EAClC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { SequenceArtifact } from "@matchbox-ai/core/internal";
|
|
2
2
|
import type { DatasetExample } from "@matchbox-ai/core";
|
|
3
3
|
import type { SequenceRecipe } from "./types.js";
|
|
4
|
-
export declare function fitSequence(examples: readonly DatasetExample<unknown>[], recipe: SequenceRecipe, metadata: Pick<SequenceArtifact, "taskModule" | "taskMetadata" | "decoderModule">, probes?: readonly string[], progress?: (epoch: number, loss: number) => void): Promise<{
|
|
4
|
+
export declare function fitSequence(examples: readonly DatasetExample<unknown>[], recipe: SequenceRecipe, metadata: Pick<SequenceArtifact, "taskModule" | "taskMetadata" | "decoderModule">, probes?: readonly string[], progress?: (epoch: number, loss: number) => void, contextRadius?: number): Promise<{
|
|
5
5
|
model: {
|
|
6
|
-
formatVersion: 3;
|
|
7
6
|
engine: "burn-0.21";
|
|
8
7
|
kind: "sequence-parser";
|
|
9
8
|
architecture: "embedding-window-mlp";
|
|
@@ -14,11 +13,31 @@ export declare function fitSequence(examples: readonly DatasetExample<unknown>[]
|
|
|
14
13
|
tokenizer: "characters" | "words";
|
|
15
14
|
vocabulary: string[];
|
|
16
15
|
labels: string[];
|
|
16
|
+
unknownTokens: "abstain" | "predict";
|
|
17
|
+
threshold: number;
|
|
18
|
+
precision: "float32";
|
|
19
|
+
weights: string;
|
|
20
|
+
formatVersion: 3;
|
|
17
21
|
radius: 1;
|
|
22
|
+
casing?: "lowercase" | undefined;
|
|
23
|
+
} | {
|
|
24
|
+
engine: "burn-0.21";
|
|
25
|
+
kind: "sequence-parser";
|
|
26
|
+
architecture: "embedding-window-mlp";
|
|
27
|
+
taskModule: string;
|
|
28
|
+
decoderModule: string;
|
|
29
|
+
taskMetadata: unknown;
|
|
30
|
+
readout: "all" | "last";
|
|
31
|
+
tokenizer: "characters" | "words";
|
|
32
|
+
vocabulary: string[];
|
|
33
|
+
labels: string[];
|
|
18
34
|
unknownTokens: "abstain" | "predict";
|
|
19
35
|
threshold: number;
|
|
20
36
|
precision: "float32";
|
|
21
37
|
weights: string;
|
|
38
|
+
formatVersion: 4;
|
|
39
|
+
radius: number;
|
|
40
|
+
casing: "lowercase" | "preserve";
|
|
22
41
|
};
|
|
23
42
|
parameters: number;
|
|
24
43
|
history: number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fit-sequence.d.ts","sourceRoot":"","sources":["../../../src/models/sequence/fit-sequence.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAC5C,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,cAAc,GAAG,eAAe,CAAC,EACjF,MAAM,GAAE,SAAS,MAAM,EAAO,EAC9B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI
|
|
1
|
+
{"version":3,"file":"fit-sequence.d.ts","sourceRoot":"","sources":["../../../src/models/sequence/fit-sequence.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAC5C,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,cAAc,GAAG,eAAe,CAAC,EACjF,MAAM,GAAE,SAAS,MAAM,EAAO,EAC9B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,EAChD,aAAa,SAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqElB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { DatasetExample } from "@matchbox-ai/core";
|
|
2
2
|
import type { SequenceRecipe } from "./types.js";
|
|
3
|
-
export declare function prepareSupervision(examples: readonly DatasetExample<unknown>[], recipe: SequenceRecipe): {
|
|
3
|
+
export declare function prepareSupervision(examples: readonly DatasetExample<unknown>[], recipe: SequenceRecipe, radius?: number): {
|
|
4
4
|
vocabulary: string[];
|
|
5
5
|
radius: number;
|
|
6
6
|
dropout: number;
|
|
7
|
-
inputs:
|
|
8
|
-
labels:
|
|
7
|
+
inputs: Int32Array<ArrayBuffer>;
|
|
8
|
+
labels: Int32Array<ArrayBuffer>;
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=prepare-supervision.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-supervision.d.ts","sourceRoot":"","sources":["../../../src/models/sequence/prepare-supervision.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAC5C,MAAM,EAAE,cAAc;;;;;;
|
|
1
|
+
{"version":3,"file":"prepare-supervision.d.ts","sourceRoot":"","sources":["../../../src/models/sequence/prepare-supervision.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAC5C,MAAM,EAAE,cAAc,EACtB,MAAM,SAAI;;;;;;EAkFX"}
|
|
@@ -21,6 +21,11 @@ export declare function runSequence(command: "train" | "eval", project: Awaited<
|
|
|
21
21
|
report: {
|
|
22
22
|
formatVersion: number;
|
|
23
23
|
architecture: "embedding-window-mlp";
|
|
24
|
+
encoding: {
|
|
25
|
+
tokenizer: "characters" | "words";
|
|
26
|
+
casing: "lowercase" | "preserve" | undefined;
|
|
27
|
+
};
|
|
28
|
+
contextRadius: number;
|
|
24
29
|
backend: string;
|
|
25
30
|
seed: number;
|
|
26
31
|
artifactSha256: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-sequence.d.ts","sourceRoot":"","sources":["../../../src/models/sequence/run-sequence.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMzD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,EAChD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI
|
|
1
|
+
{"version":3,"file":"run-sequence.d.ts","sourceRoot":"","sources":["../../../src/models/sequence/run-sequence.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMzD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,EAChD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;YA0FlC,SAAS;YAAuB,MAAM;;;;;;;;;;;;;YAYhD,KAAK;YACL,UAAU;YACV,UAAU;YACV,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsBT"}
|
|
@@ -7,6 +7,8 @@ export interface SequenceRecipe {
|
|
|
7
7
|
/** Train the unknown-token embedding by masking this fraction of training token IDs. */
|
|
8
8
|
tokenDropout?: number;
|
|
9
9
|
tokenizer: "characters" | "words";
|
|
10
|
+
/** Preserve token casing or lowercase keys. Defaults to lowercase for existing recipes. */
|
|
11
|
+
casing?: "lowercase" | "preserve";
|
|
10
12
|
readout: "all" | "last";
|
|
11
13
|
labels: readonly string[];
|
|
12
14
|
annotate(example: DatasetExample<unknown>, tokens: readonly Token[]): readonly (string | null)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/models/sequence/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,+FAA+F;AAC/F,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,UAAU,CAAC,EAAE,SAAS,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7C,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC;IAClC,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAClG"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/models/sequence/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,+FAA+F;AAC/F,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,UAAU,CAAC,EAAE,SAAS,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7C,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC;IAClC,2FAA2F;IAC3F,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAClC,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAClG"}
|
package/dist/native/fit.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ interface NativeResult {
|
|
|
6
6
|
export declare function predict(config: {
|
|
7
7
|
vocabularySize: number;
|
|
8
8
|
labelCount: number;
|
|
9
|
-
|
|
9
|
+
contextRadius?: number;
|
|
10
|
+
}, weights: Uint8Array, inputs: number[][] | Int32Array): number[];
|
|
10
11
|
export declare function fit(config: {
|
|
11
12
|
vocabularySize: number;
|
|
12
13
|
labelCount: number;
|
|
13
|
-
|
|
14
|
+
contextRadius?: number;
|
|
15
|
+
}, inputs: number[][] | Int32Array, labels: number[] | Int32Array, progress?: (epoch: number, loss: number) => void): Promise<NativeResult>;
|
|
14
16
|
export {};
|
|
15
17
|
//# sourceMappingURL=fit.d.ts.map
|
package/dist/native/fit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../src/native/fit.ts"],"names":[],"mappings":"AACA,UAAU,YAAY;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAgB,OAAO,CACrB,MAAM,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../src/native/fit.ts"],"names":[],"mappings":"AACA,UAAU,YAAY;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAgB,OAAO,CACrB,MAAM,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9E,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,UAAU,GAC9B,MAAM,EAAE,CASV;AACD,wBAAgB,GAAG,CACjB,MAAM,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9E,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,UAAU,EAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,GAC/C,OAAO,CAAC,YAAY,CAAC,CAmBvB"}
|
|
@@ -5,6 +5,7 @@ export declare const pipelineSchema: z.ZodObject<{
|
|
|
5
5
|
}, z.core.$strict>, z.ZodObject<{
|
|
6
6
|
kind: z.ZodLiteral<"token-classifier">;
|
|
7
7
|
recipe: z.ZodDefault<z.ZodString>;
|
|
8
|
+
contextRadius: z.ZodOptional<z.ZodNumber>;
|
|
8
9
|
decode: z.ZodDefault<z.ZodString>;
|
|
9
10
|
}, z.core.$strict>], "kind">;
|
|
10
11
|
acceptance: z.ZodOptional<z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline/define-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"define-pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline/define-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;kBAgBzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAE3D"}
|
|
@@ -19,7 +19,6 @@ export declare function loadArtifact(configPath: string): Promise<{
|
|
|
19
19
|
precision: "float32";
|
|
20
20
|
weights: string;
|
|
21
21
|
} | {
|
|
22
|
-
formatVersion: 3;
|
|
23
22
|
engine: "burn-0.21";
|
|
24
23
|
kind: "sequence-parser";
|
|
25
24
|
architecture: "embedding-window-mlp";
|
|
@@ -30,11 +29,31 @@ export declare function loadArtifact(configPath: string): Promise<{
|
|
|
30
29
|
tokenizer: "characters" | "words";
|
|
31
30
|
vocabulary: string[];
|
|
32
31
|
labels: string[];
|
|
32
|
+
unknownTokens: "abstain" | "predict";
|
|
33
|
+
threshold: number;
|
|
34
|
+
precision: "float32";
|
|
35
|
+
weights: string;
|
|
36
|
+
formatVersion: 3;
|
|
33
37
|
radius: 1;
|
|
38
|
+
casing?: "lowercase" | undefined;
|
|
39
|
+
} | {
|
|
40
|
+
engine: "burn-0.21";
|
|
41
|
+
kind: "sequence-parser";
|
|
42
|
+
architecture: "embedding-window-mlp";
|
|
43
|
+
taskModule: string;
|
|
44
|
+
decoderModule: string;
|
|
45
|
+
taskMetadata: unknown;
|
|
46
|
+
readout: "all" | "last";
|
|
47
|
+
tokenizer: "characters" | "words";
|
|
48
|
+
vocabulary: string[];
|
|
49
|
+
labels: string[];
|
|
34
50
|
unknownTokens: "abstain" | "predict";
|
|
35
51
|
threshold: number;
|
|
36
52
|
precision: "float32";
|
|
37
53
|
weights: string;
|
|
54
|
+
formatVersion: 4;
|
|
55
|
+
radius: number;
|
|
56
|
+
casing: "lowercase" | "preserve";
|
|
38
57
|
};
|
|
39
58
|
task: ParserDefinition<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
40
59
|
decode: SequenceDecoder | undefined;
|
|
@@ -75,6 +94,7 @@ export declare function loadArtifact(configPath: string): Promise<{
|
|
|
75
94
|
sequence?: {
|
|
76
95
|
recipe: string;
|
|
77
96
|
decoder: string;
|
|
97
|
+
contextRadius?: number | undefined;
|
|
78
98
|
} | undefined;
|
|
79
99
|
challenges?: string | undefined;
|
|
80
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../src/project/artifact.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../src/project/artifact.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoB1B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgBhC"}
|
package/dist/project/config.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
10
10
|
sequence: z.ZodOptional<z.ZodObject<{
|
|
11
11
|
recipe: z.ZodString;
|
|
12
12
|
decoder: z.ZodString;
|
|
13
|
+
contextRadius: z.ZodOptional<z.ZodNumber>;
|
|
13
14
|
}, z.core.$strict>>;
|
|
14
15
|
challenges: z.ZodOptional<z.ZodString>;
|
|
15
16
|
}, z.core.$strict>;
|
|
@@ -25,6 +26,7 @@ export declare function loadConfig(path: string): Promise<{
|
|
|
25
26
|
sequence?: {
|
|
26
27
|
recipe: string;
|
|
27
28
|
decoder: string;
|
|
29
|
+
contextRadius?: number | undefined;
|
|
28
30
|
} | undefined;
|
|
29
31
|
challenges?: string | undefined;
|
|
30
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/project/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/project/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;kBAgBvB,CAAC;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;GA4C5C"}
|
package/dist/project/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as loadConfig, n as discover, r as listTasks, t as loadArtifact } from "../project-
|
|
1
|
+
import { i as loadConfig, n as discover, r as listTasks, t as loadArtifact } from "../project-CgNwV9Dj.js";
|
|
2
2
|
export { discover, listTasks, loadArtifact, loadConfig };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as pipelineSchema } from "./define-pipeline-
|
|
1
|
+
import { n as pipelineSchema } from "./define-pipeline-DEkjmOte.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { readArtifact, tensorPredictor } from "@matchbox-ai/core/internal";
|
|
4
4
|
import { access, readFile, readdir, stat } from "node:fs/promises";
|
|
@@ -39,7 +39,8 @@ const configSchema = z.strictObject({
|
|
|
39
39
|
maxBytes: z.number().positive().default(64e3),
|
|
40
40
|
sequence: z.strictObject({
|
|
41
41
|
recipe: z.string(),
|
|
42
|
-
decoder: z.string()
|
|
42
|
+
decoder: z.string(),
|
|
43
|
+
contextRadius: z.number().int().min(1).max(16).optional()
|
|
43
44
|
}).optional(),
|
|
44
45
|
challenges: z.string().optional()
|
|
45
46
|
});
|
|
@@ -56,7 +57,8 @@ async function loadConfig(path) {
|
|
|
56
57
|
defaults = { ...pipeline.acceptance };
|
|
57
58
|
if (pipeline.prediction.kind === "token-classifier") defaults.sequence = {
|
|
58
59
|
recipe: pipeline.prediction.recipe,
|
|
59
|
-
decoder: pipeline.prediction.decode
|
|
60
|
+
decoder: pipeline.prediction.decode,
|
|
61
|
+
contextRadius: pipeline.prediction.contextRadius
|
|
60
62
|
};
|
|
61
63
|
} else if (!authored.sequence) throw new Error(`Missing pipeline.ts or pipeline/pipeline.ts in ${root}. Author an explicit pipeline before training.`);
|
|
62
64
|
const config = configSchema.parse({
|
|
@@ -155,4 +157,4 @@ async function loadArtifact(configPath) {
|
|
|
155
157
|
//#endregion
|
|
156
158
|
export { loadConfig as i, discover as n, listTasks as r, loadArtifact as t };
|
|
157
159
|
|
|
158
|
-
//# sourceMappingURL=project-
|
|
160
|
+
//# sourceMappingURL=project-CgNwV9Dj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-CgNwV9Dj.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\n .strictObject({\n recipe: z.string(),\n decoder: z.string(),\n contextRadius: z.number().int().min(1).max(16).optional(),\n })\n .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 contextRadius: pipeline.prediction.contextRadius,\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;CACnC,SAAS,OAAO;EACd,IAAI,CAAC,UAAU,SAAS,CAAC,CAAC,SAAU,MAAgC,QAAQ,EAAE,GAC5E,OAAO;EAET,MAAM;CACR;AACF;;AAEA,eAAsB,UAAU,MAAc,MAA2C;CACvF,MAAM,OAAO,QAAQ,MAAM,IAAI;CAC/B,MAAM,aAAa,CAAC,GAAG,KAAK,MAAM,QAAQ,MAAM,GAAG,SAAS,IAAI,EAAE,IAAI,CAAC;CACvE,MAAM,SAAS,MAAM,QAAQ,IAAI,WAAW,IAAI,MAAM,CAAC,EAAA,CACpD,KAAK,QAAQ,UAAW,SAAS,WAAW,SAAS,KAAA,CAAU,CAAC,CAChE,QAAQ,SAAyB,SAAS,KA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project-CgNwV9Dj.js";
|
|
2
2
|
import "zod";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { resolve } from "node:path";
|
|
@@ -57,7 +57,7 @@ async function loadProject(path) {
|
|
|
57
57
|
async function run(command, path, progress) {
|
|
58
58
|
const project = await loadProject(path);
|
|
59
59
|
if (project.config.sequence) {
|
|
60
|
-
const { runSequence } = await import("./sequence-
|
|
60
|
+
const { runSequence } = await import("./sequence-NevJFVwZ.js");
|
|
61
61
|
return runSequence(command, project, progress);
|
|
62
62
|
}
|
|
63
63
|
if (command !== "train") throw new Error("Use the eval CLI command to evaluate a saved artifact.");
|
|
@@ -67,4 +67,4 @@ async function run(command, path, progress) {
|
|
|
67
67
|
//#endregion
|
|
68
68
|
export { run };
|
|
69
69
|
|
|
70
|
-
//# sourceMappingURL=run-
|
|
70
|
+
//# sourceMappingURL=run-MgK9OCQv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-MgK9OCQv.js","names":[],"sources":["../src/load-project.ts","../src/run.ts"],"sourcesContent":["import { loadConfig } from \"./project/index.js\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { z } from \"zod\";\nimport { parseDatasets } from \"@matchbox-ai/core\";\nimport type { ParserDefinition } from \"@matchbox-ai/core\";\nexport async function loadProject(path: string) {\n const { config, root } = await loadConfig(path);\n const taskPath = resolve(root, config.task);\n const task: ParserDefinition<z.ZodType> = (await import(pathToFileURL(taskPath).href)).default;\n const sources = await Promise.all(\n [config.train, config.validation, config.eval].map(async (source) => ({\n source,\n text: await readFile(resolve(root, source), \"utf8\"),\n })),\n );\n const training = parseDatasets(task, { formatVersion: 1, train: sources[0]!, eval: sources[1]! });\n const evaluation = parseDatasets(task, {\n formatVersion: 1,\n train: sources[0]!,\n eval: sources[2]!,\n });\n for (const result of [training, evaluation]) {\n if (!result.success) {\n throw new Error(\n result.issues\n .map((issue) => `${issue.source}:${issue.line} ${issue.path.join(\".\")}: ${issue.message}`)\n .join(\"\\n\"),\n );\n }\n }\n if (!training.success || !evaluation.success) {\n throw new Error(\"Invalid datasets.\");\n }\n const groups = [training.data.train, training.data.eval, evaluation.data.eval];\n const seen = new Map<string, number>();\n groups.forEach((group, split) =>\n group.forEach((row) => {\n const key = row.input.trim().toLowerCase();\n if (seen.has(key) && seen.get(key) !== split) {\n throw new Error(`Input overlaps dataset splits: ${row.input}`);\n }\n seen.set(key, split);\n }),\n );\n return {\n root,\n config,\n task,\n taskPath,\n output: resolve(root, config.output),\n sources,\n train: training.data.train,\n validation: training.data.eval,\n evaluation: evaluation.data.eval,\n };\n}\n","import { loadProject } from \"./load-project.js\";\nexport async function run(\n command: \"train\" | \"eval\",\n path: string,\n progress?: (epoch: number, loss: number) => void,\n) {\n const project = await loadProject(path);\n if (project.config.sequence) {\n const { runSequence } = await import(\"./models/sequence/index.js\");\n return runSequence(command, project, progress);\n }\n if (command !== \"train\") {\n throw new Error(\"Use the eval CLI command to evaluate a saved artifact.\");\n }\n const { runRecord } = await import(\"./models/record/index.js\");\n return runRecord(project, progress);\n}\n"],"mappings":";;;;;;;AAOA,eAAsB,YAAY,MAAc;CAC9C,MAAM,EAAE,QAAQ,SAAS,MAAM,WAAW,IAAI;CAC9C,MAAM,WAAW,QAAQ,MAAM,OAAO,IAAI;CAC1C,MAAM,QAAqC,MAAM,OAAO,cAAc,QAAQ,CAAC,CAAC,MAAA,CAAO;CACvF,MAAM,UAAU,MAAM,QAAQ,IAC5B;EAAC,OAAO;EAAO,OAAO;EAAY,OAAO;CAAI,CAAC,CAAC,IAAI,OAAO,YAAY;EACpE;EACA,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM,GAAG,MAAM;CACpD,EAAE,CACJ;CACA,MAAM,WAAW,cAAc,MAAM;EAAE,eAAe;EAAG,OAAO,QAAQ;EAAK,MAAM,QAAQ;CAAI,CAAC;CAChG,MAAM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run.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export declare function run(command: "train" | "eval", path: string, progress?:
|
|
|
20
20
|
report: {
|
|
21
21
|
formatVersion: number;
|
|
22
22
|
architecture: "embedding-window-mlp";
|
|
23
|
+
encoding: {
|
|
24
|
+
tokenizer: "characters" | "words";
|
|
25
|
+
casing: "lowercase" | "preserve" | undefined;
|
|
26
|
+
};
|
|
27
|
+
contextRadius: number;
|
|
23
28
|
backend: string;
|
|
24
29
|
seed: number;
|
|
25
30
|
artifactSha256: string;
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AACA,wBAAsB,GAAG,CACvB,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AACA,wBAAsB,GAAG,CACvB,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYjD"}
|