@mailwoman/mtf 11.0.0 → 11.2.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/README.md +2 -2
- package/crates/mtf-channels/tests/fixtures/README.md +12 -6
- package/crates/mtf-sampler/tests/fixtures/README.md +1 -1
- package/lib/code-units.ts +6 -6
- package/lib/index.ts +6 -7
- package/out/code-units.d.ts +2 -5
- package/out/code-units.d.ts.map +1 -1
- package/out/code-units.js +3 -7
- package/out/code-units.js.map +1 -1
- package/out/index.d.ts +3 -7
- package/out/index.d.ts.map +1 -1
- package/out/index.js +5 -7
- package/out/index.js.map +1 -1
- package/out/tools/build-wasm.run.d.ts +0 -12
- package/out/tools/build-wasm.run.d.ts.map +1 -1
- package/out/tools/build-wasm.run.js +2 -4
- package/out/tools/build-wasm.run.js.map +1 -1
- package/out/tools/sampler/native.d.ts +44 -18
- package/out/tools/sampler/native.d.ts.map +1 -1
- package/out/tools/sampler/native.js +14 -9
- package/out/tools/sampler/native.js.map +1 -1
- package/out/tools/tokenizer/binary.d.ts +0 -16
- package/out/tools/tokenizer/binary.d.ts.map +1 -1
- package/out/tools/tokenizer/binary.js +11 -11
- package/out/tools/tokenizer/binary.js.map +1 -1
- package/out/tools/tokenizer/byte-fallback.d.ts +0 -10
- package/out/tools/tokenizer/byte-fallback.d.ts.map +1 -1
- package/out/tools/tokenizer/byte-fallback.js +5 -6
- package/out/tools/tokenizer/byte-fallback.js.map +1 -1
- package/out/tools/tokenizer/model.d.ts +0 -8
- package/out/tools/tokenizer/model.d.ts.map +1 -1
- package/out/tools/tokenizer/model.js +4 -6
- package/out/tools/tokenizer/model.js.map +1 -1
- package/out/tools/tokenizer/prune.d.ts +2 -14
- package/out/tools/tokenizer/prune.d.ts.map +1 -1
- package/out/tools/tokenizer/prune.js +10 -10
- package/out/tools/tokenizer/prune.js.map +1 -1
- package/out/tools/tokenizer/prune.run.d.ts +0 -14
- package/out/tools/tokenizer/prune.run.d.ts.map +1 -1
- package/out/tools/tokenizer/prune.run.js +7 -7
- package/out/tools/tokenizer/prune.run.js.map +1 -1
- package/out/tools/tokenizer/sentencepiece.d.ts +0 -16
- package/out/tools/tokenizer/sentencepiece.d.ts.map +1 -1
- package/out/tools/tokenizer/sentencepiece.js +14 -11
- package/out/tools/tokenizer/sentencepiece.js.map +1 -1
- package/out/tools/tokenizer/splice.d.ts +1 -14
- package/out/tools/tokenizer/splice.d.ts.map +1 -1
- package/out/tools/tokenizer/splice.js +12 -11
- package/out/tools/tokenizer/splice.js.map +1 -1
- package/out/tools/tokenizer/splice.run.d.ts +0 -27
- package/out/tools/tokenizer/splice.run.d.ts.map +1 -1
- package/out/tools/tokenizer/splice.run.js +14 -13
- package/out/tools/tokenizer/splice.run.js.map +1 -1
- package/out/tools/tokenizer/symbols.d.ts +1 -13
- package/out/tools/tokenizer/symbols.d.ts.map +1 -1
- package/out/tools/tokenizer/symbols.js +9 -9
- package/out/tools/tokenizer/symbols.js.map +1 -1
- package/out/tools/tokenizer/train/text.run.d.ts +0 -14
- package/out/tools/tokenizer/train/text.run.d.ts.map +1 -1
- package/out/tools/tokenizer/train/text.run.js +6 -6
- package/out/tools/tokenizer/train/text.run.js.map +1 -1
- package/out/tools/tokenizer/train.d.ts +0 -12
- package/out/tools/tokenizer/train.d.ts.map +1 -1
- package/out/tools/tokenizer/train.js +7 -8
- package/out/tools/tokenizer/train.js.map +1 -1
- package/out/tools/tokenizer/train.run.d.ts +0 -22
- package/out/tools/tokenizer/train.run.d.ts.map +1 -1
- package/out/tools/tokenizer/train.run.js +12 -9
- package/out/tools/tokenizer/train.run.js.map +1 -1
- package/out/tools/tokenizer/utilization.run.d.ts +0 -15
- package/out/tools/tokenizer/utilization.run.d.ts.map +1 -1
- package/out/tools/tokenizer/utilization.run.js +8 -8
- package/out/tools/tokenizer/utilization.run.js.map +1 -1
- package/out/tools/tokenizer/verify.d.ts +0 -15
- package/out/tools/tokenizer/verify.d.ts.map +1 -1
- package/out/tools/tokenizer/verify.js +11 -10
- package/out/tools/tokenizer/verify.js.map +1 -1
- package/out/tools/tokenizer/verify.run.d.ts +0 -20
- package/out/tools/tokenizer/verify.run.d.ts.map +1 -1
- package/out/tools/tokenizer/verify.run.js +7 -8
- package/out/tools/tokenizer/verify.run.js.map +1 -1
- package/package.json +6 -4
- package/tools/build-wasm.run.ts +3 -4
- package/tools/sampler/native.ts +65 -14
- package/tools/tokenizer/binary.ts +12 -11
- package/tools/tokenizer/byte-fallback.ts +6 -6
- package/tools/tokenizer/model.ts +5 -6
- package/tools/tokenizer/prune.run.ts +8 -7
- package/tools/tokenizer/prune.ts +11 -10
- package/tools/tokenizer/sentencepiece.ts +15 -11
- package/tools/tokenizer/splice.run.ts +15 -13
- package/tools/tokenizer/splice.ts +13 -11
- package/tools/tokenizer/symbols.ts +10 -9
- package/tools/tokenizer/train/text.run.ts +7 -6
- package/tools/tokenizer/train.run.ts +13 -9
- package/tools/tokenizer/train.ts +8 -8
- package/tools/tokenizer/utilization.run.ts +9 -8
- package/tools/tokenizer/verify.run.ts +8 -8
- package/tools/tokenizer/verify.ts +12 -10
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ toolchain. A repository check will rebuild it and compare hashes.
|
|
|
77
77
|
- A loaded model is a `Disposable` processor object. Its encode and decode methods are synchronous.
|
|
78
78
|
- Results are ordinary JavaScript values. The caller never handles WASM vectors or pointers.
|
|
79
79
|
- A model file records its format version, normalization policy, special IDs and vocabulary hash. The
|
|
80
|
-
loader refuses a model whose semantics it
|
|
80
|
+
loader refuses a model whose semantics it doesn't implement.
|
|
81
81
|
|
|
82
82
|
### Risks to test early
|
|
83
83
|
|
|
@@ -200,7 +200,7 @@ repository root with `node`:
|
|
|
200
200
|
|
|
201
201
|
Training runs native `spm_train`, built from google/sentencepiece `v0.2.2` under the cache root on first use. It
|
|
202
202
|
reproduces the Python wheel's model byte for byte: the CLI records every trainer default it set, and the tool drops
|
|
203
|
-
the spec fields the training call
|
|
203
|
+
the spec fields the training call didn't name. That's the form the wheel writes. `tools/tokenizer/sentencepiece.integration.test.ts`
|
|
204
204
|
checks five recorded wheel trainings against `test/fixtures/spm-recipes/`.
|
|
205
205
|
|
|
206
206
|
The proto edits, parquet reads, CPython-compatible sampling, the byte-fallback count and the ONNX initializer
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
# mtf-channels test fixtures
|
|
2
2
|
|
|
3
3
|
Both files are records of the training encoder this crate replaced (#2870). They were written from
|
|
4
|
-
that implementation before its deletion, so they
|
|
4
|
+
that implementation before its deletion, so they're not regenerated. Each file states the source revision
|
|
5
5
|
it was recorded at.
|
|
6
6
|
|
|
7
7
|
- `encode-row-reference.json` holds one row encoded by the Python `encode_row` with every soft-feed
|
|
8
8
|
channel on, under both label sources, with the shaped anchor and with no channels. It also holds every
|
|
9
|
-
input the encoder read: pieces, lexicons, the anchor table and the label table.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
templates, it groups every Unicode scalar value by the
|
|
13
|
-
template.
|
|
9
|
+
input the encoder read: pieces, lexicons, the anchor table and the label table. The postal anchor
|
|
10
|
+
paints the shaped case's row identically, and the test says so.
|
|
11
|
+
- `text-reference.json` holds the code units and `str.lower`, `str.upper` and `str.strip` results for a
|
|
12
|
+
list of adversarial texts. For each of 17 templates, it groups every Unicode scalar value by the
|
|
13
|
+
segmentation that value gives when placed in the template. The recording also held the retired shape
|
|
14
|
+
finder's spans and each unit's acceptance count, which the `postal` family's finders replaced, so those
|
|
15
|
+
answers were removed from the file.
|
|
16
|
+
|
|
17
|
+
The postal finders' own fixture is `test/fixtures/postcode-agreement.json` at the repository root, beside the
|
|
18
|
+
code-unit parity fixture. `tests/postcode_agreement.rs` replays it against the encoder's finder and
|
|
19
|
+
`packages/postcode/lib/postal-spans.test.ts` against serving's.
|
|
@@ -116,5 +116,5 @@ the train stream with seed 11 and a shuffle buffer of 6, as `source|country|raw`
|
|
|
116
116
|
validation split; `encoded` is one pass of the char path in word mode with the default shuffle buffer, as each row's
|
|
117
117
|
labels, attention and first three units of char ids; `source_row_counts` is the rows per source. The Python loader
|
|
118
118
|
wrote it before the Rust sampler replaced it, and `tests/loader_split_reference.rs` requires the Rust sampler to
|
|
119
|
-
reproduce every value in order. It is a record of the Python sampler's output and
|
|
119
|
+
reproduce every value in order. It is a record of the Python sampler's output and isn't regenerated from the Rust
|
|
120
120
|
sampler.
|
package/lib/code-units.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
5
|
* @file Code units: each digit run or alphanumeric code in an address, segmented as one unit (#2845).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { TextFragment } from "@mailwoman/core/tokenization/Span"
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* One code unit and its half-open UTF-16 offsets into the text.
|
|
12
12
|
*/
|
|
13
|
-
export type CodeUnit =
|
|
13
|
+
export type CodeUnit = TextFragment
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* A run of ASCII letters and digits holding at least one digit, with a hyphen
|
|
17
17
|
* allowed between two digits (`12345-6789`, `100-0005`).
|
|
18
18
|
*
|
|
19
|
-
* The run
|
|
19
|
+
* The run mustn't touch another ASCII letter or digit on either side, so `B2B` and `SW1A` are whole units.
|
|
20
20
|
* A Han or Kana character next to a run is a boundary, because Japanese and Chinese
|
|
21
21
|
* addresses write a block number straight after its place name (`丸の内1-9-1`).
|
|
22
22
|
*/
|
package/lib/index.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
5
|
* The TypeScript loader for the Multilingual Token Framework's WebAssembly runtime.
|
|
7
6
|
*
|
|
8
7
|
* The module's import has no side effects: the WASM fetch and instantiation happen in the caller.
|
|
9
|
-
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module`
|
|
10
|
-
* and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
8
|
+
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module`
|
|
9
|
+
* (Workers supply the latter) and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
11
10
|
* {@linkcode mtfWASMURL} locates the committed binary beside this package.
|
|
12
11
|
* A loaded model's encode and decode methods are synchronous.
|
|
13
12
|
*/
|
|
@@ -123,7 +122,7 @@ export class MTFRuntime {
|
|
|
123
122
|
/**
|
|
124
123
|
* Loads a serialized SentencePiece unigram model.
|
|
125
124
|
*
|
|
126
|
-
* @throws When the bytes are malformed or the model uses a feature the runtime
|
|
125
|
+
* @throws When the bytes are malformed or the model uses a feature the runtime doesn't implement.
|
|
127
126
|
*/
|
|
128
127
|
loadModel(bytes: Uint8Array): MTFModel {
|
|
129
128
|
const handle = this.#withInput(bytes, (ptr, len) => this.#exports.mtf_model_load(ptr, len))
|
package/out/code-units.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
2
|
* @file Code units: each digit run or alphanumeric code in an address, segmented as one unit (#2845).
|
|
6
3
|
*/
|
|
7
|
-
import type {
|
|
4
|
+
import type { TextFragment } from "@mailwoman/core/tokenization/Span";
|
|
8
5
|
/**
|
|
9
6
|
* One code unit and its half-open UTF-16 offsets into the text.
|
|
10
7
|
*/
|
|
11
|
-
export type CodeUnit =
|
|
8
|
+
export type CodeUnit = TextFragment;
|
|
12
9
|
/**
|
|
13
10
|
* Every code unit in `text`, left to right.
|
|
14
11
|
*
|
package/out/code-units.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-units.d.ts","sourceRoot":"","sources":["../lib/code-units.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-units.d.ts","sourceRoot":"","sources":["../lib/code-units.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAErE;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAA;AAYnC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAMzD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/out/code-units.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
* @file Code units: each digit run or alphanumeric code in an address, segmented as one unit (#2845).
|
|
6
|
-
*/
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
7
3
|
/**
|
|
8
4
|
* A run of ASCII letters and digits holding at least one digit, with a hyphen
|
|
9
5
|
* allowed between two digits (`12345-6789`, `100-0005`).
|
|
10
6
|
*
|
|
11
|
-
* The run
|
|
7
|
+
* The run mustn't touch another ASCII letter or digit on either side, so `B2B` and `SW1A` are whole units.
|
|
12
8
|
* A Han or Kana character next to a run is a boundary, because Japanese and Chinese
|
|
13
9
|
* addresses write a block number straight after its place name (`丸の内1-9-1`).
|
|
14
10
|
*/
|
package/out/code-units.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-units.js","sourceRoot":"","sources":["../lib/code-units.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"code-units.js","sourceRoot":"","sources":["../lib/code-units.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAalE;;;;;;;GAOG;AACH,MAAM,SAAS,GAAG,0FAA0F,CAAA;AAE5G;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QACd,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;KAClC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;AAChE,CAAC"}
|
package/out/index.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
2
|
* The TypeScript loader for the Multilingual Token Framework's WebAssembly runtime.
|
|
7
3
|
*
|
|
8
4
|
* The module's import has no side effects: the WASM fetch and instantiation happen in the caller.
|
|
9
|
-
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module`
|
|
10
|
-
* and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
5
|
+
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module`
|
|
6
|
+
* (Workers supply the latter) and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
11
7
|
* {@linkcode mtfWASMURL} locates the committed binary beside this package.
|
|
12
8
|
* A loaded model's encode and decode methods are synchronous.
|
|
13
9
|
*/
|
|
@@ -78,7 +74,7 @@ export declare class MTFRuntime {
|
|
|
78
74
|
/**
|
|
79
75
|
* Loads a serialized SentencePiece unigram model.
|
|
80
76
|
*
|
|
81
|
-
* @throws When the bytes are malformed or the model uses a feature the runtime
|
|
77
|
+
* @throws When the bytes are malformed or the model uses a feature the runtime doesn't implement.
|
|
82
78
|
*/
|
|
83
79
|
loadModel(bytes: Uint8Array): MTFModel;
|
|
84
80
|
/**
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,wBAAgB,UAAU,IAAI,GAAG,CAEhC;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;AAqBrF;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,IAAI,EAAE,MAAM,EAAE,CAAA;CACd;AAED;;GAEG;AACH,UAAU,UAAU;IACnB,MAAM,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;KAAE,CAAA;I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UAAU,EAAE,MAAM,EAAE,MAAM,EAInE;IAQD;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAqBpC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAmBrC;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI,CAKd;IAED,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAEvB;CACD"}
|
package/out/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
4
|
* The TypeScript loader for the Multilingual Token Framework's WebAssembly runtime.
|
|
7
5
|
*
|
|
8
6
|
* The module's import has no side effects: the WASM fetch and instantiation happen in the caller.
|
|
9
|
-
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module`
|
|
10
|
-
* and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
7
|
+
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module`
|
|
8
|
+
* (Workers supply the latter) and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
11
9
|
* {@linkcode mtfWASMURL} locates the committed binary beside this package.
|
|
12
10
|
* A loaded model's encode and decode methods are synchronous.
|
|
13
11
|
*/
|
|
@@ -49,7 +47,7 @@ export class MTFRuntime {
|
|
|
49
47
|
/**
|
|
50
48
|
* Loads a serialized SentencePiece unigram model.
|
|
51
49
|
*
|
|
52
|
-
* @throws When the bytes are malformed or the model uses a feature the runtime
|
|
50
|
+
* @throws When the bytes are malformed or the model uses a feature the runtime doesn't implement.
|
|
53
51
|
*/
|
|
54
52
|
loadModel(bytes) {
|
|
55
53
|
const handle = this.#withInput(bytes, (ptr, len) => this.#exports.mtf_model_load(ptr, len));
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU;IACzB,OAAO,IAAI,GAAG,CAAC,kBAAkB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AACpD,CAAC;AAmED;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,CAAA;AAErB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AACjC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AAEzD;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACb,QAAQ,CAAY;IAE7B,YAAoB,OAAmB;QACtC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACxB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAqB;QAC7C,MAAM,QAAQ,GACb,MAAM,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;YAC1D,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ;YACtD,CAAC,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAE7C,OAAO,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,KAAiB;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/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Builds `crates/mtf-wasm` for `wasm32-unknown-unknown` and writes the result to `wasm/mtf.wasm`.
|
|
7
|
-
*
|
|
8
|
-
* With `--check`, the tool builds without writing.
|
|
9
|
-
* It exits non-zero when the build's SHA-256 differs from the committed binary's.
|
|
10
|
-
*
|
|
11
|
-
* Usage: `node packages/mtf/tools/build-wasm.run.ts [--check]`
|
|
12
|
-
*/
|
|
13
1
|
export {};
|
|
14
2
|
//# sourceMappingURL=build-wasm.run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-wasm.run.d.ts","sourceRoot":"","sources":["../../tools/build-wasm.run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-wasm.run.d.ts","sourceRoot":"","sources":["../../tools/build-wasm.run.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
4
|
* Builds `crates/mtf-wasm` for `wasm32-unknown-unknown` and writes the result to `wasm/mtf.wasm`.
|
|
7
5
|
*
|
|
8
6
|
* With `--check`, the tool builds without writing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-wasm.run.js","sourceRoot":"","sources":["../../tools/build-wasm.run.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"build-wasm.run.js","sourceRoot":"","sources":["../../tools/build-wasm.run.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;GAOG;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,CAAC,CAAA;IAC/E,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,KAAK,CAAC,qCAAqC,eAAe,WAAW,WAAW,KAAK,IAAI,SAAS,CAAC,CAAA;QAE3G,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;IACrB,CAAC;AACF,CAAC;KAAM,CAAC;IACP,MAAM,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAE7C,OAAO,CAAC,GAAG,CAAC,wBAAwB,WAAW,KAAK,IAAI,SAAS,CAAC,CAAA;AACnE,CAAC"}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The `mtf-node` addon: the training-row sampler and the row encoders of `crates/mtf-node`, loaded into Node.
|
|
7
|
-
*
|
|
8
|
-
* Cargo builds the addon from source the first time a process asks for it, under the root workspace's `node`
|
|
9
|
-
* profile and the toolchain the root `rust-toolchain.toml` pins, into the root `target/node/`. The build
|
|
10
|
-
* reads `mtf-sampler` with its parquet reader, so it stays out of the browser `wasm/mtf.wasm`, whose one dependency is
|
|
11
|
-
* `mtf-core`. The addon is built for the host it runs on: Linux and macOS, where Cargo writes the library to
|
|
12
|
-
* `libmtf_node.so` and `libmtf_node.dylib`.
|
|
13
|
-
*/
|
|
14
1
|
/**
|
|
15
2
|
* One sampled row.
|
|
16
3
|
* The span triple is present when the row's file stores one.
|
|
@@ -117,7 +104,7 @@ export interface SplitColumnChunk {
|
|
|
117
104
|
}
|
|
118
105
|
/**
|
|
119
106
|
* The rows a split read keeps: those whose string column `column`, uppercased, is one of `values`.
|
|
120
|
-
* A row whose value is null
|
|
107
|
+
* A row whose value is null isn't kept.
|
|
121
108
|
*/
|
|
122
109
|
export interface SplitKeep {
|
|
123
110
|
column: string;
|
|
@@ -140,10 +127,10 @@ export interface RowEncoderOptions {
|
|
|
140
127
|
labelSet?: string | null;
|
|
141
128
|
maxLength: number;
|
|
142
129
|
padID?: number | null;
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
postalArtifactPath: string;
|
|
131
|
+
postalDefinitionPath: string;
|
|
145
132
|
anchorLookupPath?: string | null;
|
|
146
|
-
anchorPaintMode?: "gold" | "
|
|
133
|
+
anchorPaintMode?: "gold" | "postal" | null;
|
|
147
134
|
gazetteerLexiconPath?: string | null;
|
|
148
135
|
gazetteerChoreography?: boolean | null;
|
|
149
136
|
countryLexiconPath?: string | null;
|
|
@@ -171,6 +158,43 @@ export interface EncodedRows {
|
|
|
171
158
|
labels: BigInt64Array;
|
|
172
159
|
channels: EncodedChannel[];
|
|
173
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* One postcode span of a line, as character offsets.
|
|
163
|
+
*
|
|
164
|
+
* The key is the one the anchor table resolved it under, when the finder holds a table with that key.
|
|
165
|
+
*/
|
|
166
|
+
export interface NativePostcodeSpan {
|
|
167
|
+
start: number;
|
|
168
|
+
end: number;
|
|
169
|
+
key?: string | null;
|
|
170
|
+
/**
|
|
171
|
+
* The countries the candidate's shapes belong to.
|
|
172
|
+
*/
|
|
173
|
+
countries: string[];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The encoder's postcode finder without the rest of the encoder.
|
|
177
|
+
*
|
|
178
|
+
* The audits compare it with `findPostcodeSpans` of `@mailwoman/postcode`.
|
|
179
|
+
*/
|
|
180
|
+
export interface NativePostcodeFinder {
|
|
181
|
+
/**
|
|
182
|
+
* The postcode spans of `raw`, in start order.
|
|
183
|
+
*/
|
|
184
|
+
spans(raw: string): NativePostcodeSpan[];
|
|
185
|
+
/**
|
|
186
|
+
* The code units of `raw`, as character offsets, with the number of countries whose syntax accepts each.
|
|
187
|
+
*/
|
|
188
|
+
codeUnits(raw: string): Array<{
|
|
189
|
+
start: number;
|
|
190
|
+
end: number;
|
|
191
|
+
accepting: number;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* The number of countries whose postcode syntax accepts the whole of `unit`.
|
|
195
|
+
*/
|
|
196
|
+
accepting(unit: string): number;
|
|
197
|
+
}
|
|
174
198
|
export interface NativeRowEncoder {
|
|
175
199
|
encodeBatch(rows: SampledRow[]): EncodedRows;
|
|
176
200
|
readonly channelDims: Array<{
|
|
@@ -232,6 +256,7 @@ interface NativeModule {
|
|
|
232
256
|
CharEncoder: new (options: CharEncoderOptions) => {
|
|
233
257
|
encodeBatch(rows: SampledRow[]): RawEncodedChars;
|
|
234
258
|
};
|
|
259
|
+
PostcodeFinder: new (artifactPath: string, definitionPath: string, anchorLookupPath?: string | null) => NativePostcodeFinder;
|
|
235
260
|
sourceRowCounts(config: string, split: string): SourceCount[];
|
|
236
261
|
deriveSourceWeights(fixed: SourceWeight[] | null, sourceReps: SourceWeight[], rowsBySource: SourceCount[], samples: number): {
|
|
237
262
|
merged: SourceWeight[];
|
|
@@ -255,7 +280,7 @@ export interface PythonText {
|
|
|
255
280
|
*/
|
|
256
281
|
casefold(text: string): string;
|
|
257
282
|
/**
|
|
258
|
-
* The consecutive runs of letter scripts, every character that
|
|
283
|
+
* The consecutive runs of letter scripts, every character that's not a letter skipped,
|
|
259
284
|
* as the mixed-script audit's `script_runs` names them.
|
|
260
285
|
*/
|
|
261
286
|
scriptRuns(text: string): string[];
|
|
@@ -301,6 +326,7 @@ export interface MTFNode {
|
|
|
301
326
|
SplitColumns: NativeModule["SplitColumns"];
|
|
302
327
|
createRowEncoder(options: RowEncoderOptions): NativeRowEncoder;
|
|
303
328
|
createCharEncoder(options: CharEncoderOptions): NativeCharEncoder;
|
|
329
|
+
createPostcodeFinder(artifactPath: string, definitionPath: string, anchorLookupPath?: string | null): NativePostcodeFinder;
|
|
304
330
|
sourceRowCounts: NativeModule["sourceRowCounts"];
|
|
305
331
|
deriveSourceWeights: NativeModule["deriveSourceWeights"];
|
|
306
332
|
channelNames: NativeModule["channelNames"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../tools/sampler/native.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../tools/sampler/native.ts"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;aAC5B,UAAU,EAAE,aAAa;aACzB,UAAU,EAAE,aAAa;aACzB,eAAe,EAAE,kBAAkB;aACnC,aAAa,EAAE,gBAAgB;CACtB,CAAA;AAEV,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAA;AAEvF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM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,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAAA;IAC9D,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CAAA;IACjE,oBAAoB,CACnB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAC9B,oBAAoB,CAAA;IACvB,eAAe,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;IAChD,mBAAmB,EAAE,YAAY,CAAC,qBAAqB,CAAC,CAAA;IACxD,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;IAC1C,UAAU,EAAE,UAAU,CAAA;CACtB;AAED;;GAEG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAiDhD"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
4
|
+
* The `mtf-node` addon: the training-row sampler and the row encoders of
|
|
5
|
+
* `crates/mtf-node`, loaded into Node.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
+
* Cargo builds the addon from source the first time a process asks for it,
|
|
8
|
+
* under the root workspace's `node` profile and the toolchain the root
|
|
9
|
+
* `rust-toolchain.toml` pins, into the root `target/node/`.
|
|
10
|
+
* The build reads `mtf-sampler` with its parquet reader, so it stays out of the
|
|
11
|
+
* browser `wasm/mtf.wasm`, whose one dependency is `mtf-core`.
|
|
7
12
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* reads `mtf-sampler` with its parquet reader, so it stays out of the browser `wasm/mtf.wasm`, whose one dependency is
|
|
11
|
-
* `mtf-core`. The addon is built for the host it runs on: Linux and macOS, where Cargo writes the library to
|
|
12
|
-
* `libmtf_node.so` and `libmtf_node.dylib`.
|
|
13
|
+
* The addon is built for the host it runs on: Linux and macOS, where Cargo writes
|
|
14
|
+
* the library to `libmtf_node.so` and `libmtf_node.dylib`.
|
|
13
15
|
*/
|
|
14
16
|
import { repoRootPath, workspacePath } from "@mailwoman/core/paths";
|
|
15
17
|
import { runFile } from "@mailwoman/core/process";
|
|
@@ -91,6 +93,9 @@ export async function mtfNode() {
|
|
|
91
93
|
},
|
|
92
94
|
};
|
|
93
95
|
},
|
|
96
|
+
createPostcodeFinder(artifactPath, definitionPath, anchorLookupPath) {
|
|
97
|
+
return new native.PostcodeFinder(artifactPath, definitionPath, anchorLookupPath ?? undefined);
|
|
98
|
+
},
|
|
94
99
|
createCharEncoder(options) {
|
|
95
100
|
const encoder = new native.CharEncoder(options);
|
|
96
101
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../../tools/sampler/native.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,YAAY,IAAI,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAiCvE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,aAAa;IACzB,eAAe,EAAE,kBAAkB;IACnC,aAAa,EAAE,gBAAgB;CACtB,CAAA;
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../../tools/sampler/native.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAA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BAAiB,CAAC,OAAO;YACxB,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;YAE/C,OAAO;gBACN,WAAW,CAAC,IAAI;oBACf,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;oBAEvD,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;gBACtC,CAAC;aACD,CAAA;QACF,CAAC;QACD,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,UAAU,EAAE;YACX,QAAQ,EAAE,MAAM,CAAC,cAAc;YAC/B,UAAU,EAAE,MAAM,CAAC,gBAAgB;YACnC,YAAY,EAAE,MAAM,CAAC,kBAAkB;YACvC,WAAW,EAAE,MAAM,CAAC,iBAAiB;SACrC;KACD,CAAA;AACF,CAAC"}
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The two native programs the tokenizer tools run: `mtf-tokenizer`, built from `crates/mtf-tools`, and
|
|
7
|
-
* SentencePiece v0.2.2's `spm_train`.
|
|
8
|
-
*
|
|
9
|
-
* `mtf-tokenizer` is a binary rather than a Node addon. Each tool calls it a handful of times over files, so a
|
|
10
|
-
* process per call costs milliseconds. A binary also builds without an addon toolchain, a per-platform artifact or ABI
|
|
11
|
-
* matching against Node. Cargo builds it on first use under the `tools` profile.
|
|
12
|
-
*
|
|
13
|
-
* `spm_train` is built from the google/sentencepiece tag the runtime and the Python wheel were built from, with the
|
|
14
|
-
* CMake recipe of `packages/sentencepiece-wasm/build.sh` minus emscripten. The checkout and build live under the
|
|
15
|
-
* cache root, outside the repository.
|
|
16
|
-
*/
|
|
17
1
|
/**
|
|
18
2
|
* The SentencePiece release every tokenizer is trained with, and the commit its tag names.
|
|
19
3
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../../tools/tokenizer/binary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../../tools/tokenizer/binary.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,eAAO,MAAM,aAAa;aACzB,OAAO,EAAE,OAAO;aAChB,GAAG,EAAE,QAAQ;aACb,MAAM,EAAE,0CAA0C;CACzC,CAAA;AASV;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAWpD;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAI5E;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CA+C9E"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
4
|
+
* The two native programs the tokenizer tools run: `mtf-tokenizer`, built from
|
|
5
|
+
* `crates/mtf-tools`, and SentencePiece v0.2.2's `spm_train`.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* `mtf-tokenizer` is a binary rather than a Node addon.
|
|
8
|
+
* Each tool calls it a handful of times over files, so a process per call costs milliseconds.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* matching against Node. Cargo builds it on first use under the `tools` profile.
|
|
10
|
+
* A binary also builds without an addon toolchain, a per-platform artifact or ABI matching against Node.
|
|
11
|
+
* Cargo builds it on first use under the `tools` profile.
|
|
12
12
|
*
|
|
13
|
-
* `spm_train` is built from the google/sentencepiece tag the runtime and the Python wheel were
|
|
14
|
-
* CMake recipe of `packages/sentencepiece-wasm/build.sh` minus emscripten.
|
|
15
|
-
* cache root, outside the repository.
|
|
13
|
+
* `spm_train` is built from the google/sentencepiece tag the runtime and the Python wheel were
|
|
14
|
+
* built from, with the CMake recipe of `packages/sentencepiece-wasm/build.sh` minus emscripten.
|
|
15
|
+
* The checkout and build live under the cache root, outside the repository.
|
|
16
16
|
*/
|
|
17
17
|
import { cacheRootPath } from "@mailwoman/core/data-root";
|
|
18
18
|
import { isFile } from "@mailwoman/core/fs/readers/stat";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../../../tools/tokenizer/binary.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../../../tools/tokenizer/binary.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,OAAO,EAAE,OAAO;IAChB,GAAG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at which a tokenizer falls back to raw bytes, overall and per script.
|
|
7
|
-
*
|
|
8
|
-
* `mtf-tokenizer byte-fallback` encodes each line with the model and assigns it a script from the Unicode name of
|
|
9
|
-
* its letters, through the tables `mtf-channels` generates from CPython's Unicode database.
|
|
10
|
-
*/
|
|
11
1
|
/**
|
|
12
2
|
* One bucket's counts.
|
|
13
3
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"byte-fallback.d.ts","sourceRoot":"","sources":["../../../tools/tokenizer/byte-fallback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"byte-fallback.d.ts","sourceRoot":"","sources":["../../../tools/tokenizer/byte-fallback.ts"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,oBAAoB,EAAE,MAAM,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,iBAAiB,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;CAC7C;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAY9G;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAmBtE"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
1
3
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
4
|
* The rate at which a tokenizer falls back to raw bytes, overall and per script.
|
|
7
5
|
*
|
|
8
|
-
* `mtf-tokenizer byte-fallback` encodes each line with the model and assigns it a
|
|
9
|
-
* its letters, through the tables `mtf-channels`
|
|
6
|
+
* `mtf-tokenizer byte-fallback` encodes each line with the model and assigns it a
|
|
7
|
+
* script from the Unicode name of its letters, through the tables `mtf-channels`
|
|
8
|
+
* generates from CPython's Unicode database.
|
|
10
9
|
*/
|
|
11
10
|
import { readLocalTextFile } from "@mailwoman/core/fs/readers";
|
|
12
11
|
import { temporaryDirectory } from "@mailwoman/core/fs/temporary";
|