@genai-fi/nanogpt 0.6.1 → 0.6.3
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/dist/Generator.js +6 -6
- package/dist/NanoGPTModel.js +9 -9
- package/dist/{RealDiv-7xu-pkZN.js → RealDiv-BYViZwhN.js} +6 -6
- package/dist/{Reshape-BYC1oUku.js → Reshape-t7Kcikjk.js} +2 -2
- package/dist/TeachableLLM.d.ts +3 -0
- package/dist/TeachableLLM.js +49 -46
- package/dist/{TiedEmbedding-C1HBot-5.js → TiedEmbedding-9WeDwvjO.js} +4 -4
- package/dist/{axis_util-CCNL7jea.js → axis_util-Bu4h7XWV.js} +1 -1
- package/dist/{broadcast_to-CddAF879.js → broadcast_to-DARN-DBD.js} +2 -2
- package/dist/{concat-XOK9ANZu.js → concat-5aPGqw3Z.js} +8 -8
- package/dist/{dataset-BFFipD1c.js → dataset-pgqp-YfL.js} +5 -5
- package/dist/{dropout-xlKRoJyU.js → dropout-Bciw46HT.js} +10 -10
- package/dist/{gather-DKtUaTtA.js → gather-DjyCjmOD.js} +1 -1
- package/dist/{gpgpu_math-B_ycgZ4W.js → gpgpu_math-CNslybmD.js} +31 -31
- package/dist/{index-CamYe_M8.js → index-BAzbokzv.js} +31 -31
- package/dist/{kernel_funcs_utils-D5MS0JFg.js → kernel_funcs_utils-CUxJCg0g.js} +5 -5
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.js +5 -5
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/load.d.ts +13 -0
- package/dist/loader/load.js +27 -0
- package/dist/loader/loadHF.d.ts +7 -0
- package/dist/loader/loadHF.js +22 -0
- package/dist/{utilities/load.d.ts → loader/loadTransformers.d.ts} +11 -11
- package/dist/loader/loadTransformers.js +28 -0
- package/dist/loader/newZipLoad.d.ts +8 -0
- package/dist/loader/newZipLoad.js +21 -0
- package/dist/loader/oldZipLoad.d.ts +7 -0
- package/dist/loader/oldZipLoad.js +76 -0
- package/dist/{log_sum_exp-CV_5-TTu.js → log_sum_exp-YEo2h3gb.js} +16 -16
- package/dist/main.js +4 -4
- package/dist/{mat_mul-CAbRFWUj.js → mat_mul-7121rsJk.js} +4 -4
- package/dist/{max-JBBv7aUf.js → max-DtlIuVeW.js} +3 -3
- package/dist/{mulmat_packed_gpu-DW4doKL_.js → mulmat_packed_gpu-D4nKF7Je.js} +1 -1
- package/dist/{norm-B9dQTFYn.js → norm-CzltS9Fz.js} +10 -10
- package/dist/{ones-CMHNqMr6.js → ones-BBlSRqn1.js} +2 -2
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +6 -6
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +9 -9
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +1 -1
- package/dist/ops/cpu/matMulMul.js +1 -1
- package/dist/ops/cpu/mulDropout.js +1 -1
- package/dist/ops/cpu/normRMS.js +1 -1
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +14 -14
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +1 -1
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +4 -4
- package/dist/ops/grads/gelu.js +1 -1
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +4 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +4 -4
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMulGelu.js +17 -17
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/{ops-DqtYemmV.js → ops-C0sQEcPw.js} +78 -78
- package/dist/{random_width-CLMQG5Jn.js → random_width-DWzaOgrn.js} +22 -22
- package/dist/{range-DqYjKnuG.js → range-DYsrnfiy.js} +1 -1
- package/dist/{reciprocal-z49filta.js → reciprocal-CJQeasVa.js} +1 -1
- package/dist/{register_all_kernels-COt6wLD0.js → register_all_kernels-BfFCQAqs.js} +28 -28
- package/dist/{reshape-C45vIIRU.js → reshape-krWGKraP.js} +1 -1
- package/dist/{scatter_nd_util-qgtnviTE.js → scatter_nd_util-93ln7Hut.js} +3 -3
- package/dist/{selu_util-4QV_GXTB.js → selu_util-sntGesxr.js} +41 -41
- package/dist/{shared-ByfrGA97.js → shared-Ca6iDobD.js} +6 -6
- package/dist/{sin-9JBrfVaB.js → sin-D_h-qCSx.js} +1 -1
- package/dist/{softmax-DvMvui-_.js → softmax-fsdtf6JC.js} +1 -1
- package/dist/{split-DxrHrPFK.js → split-eiktj-6L.js} +4 -4
- package/dist/{stack-DgaoDmnF.js → stack-dfEEz2OY.js} +2 -2
- package/dist/{sum-BpcpxNEh.js → sum-BE_Irnim.js} +3 -3
- package/dist/{tensor-CDz5x1mP.js → tensor-Xyi595sG.js} +1 -1
- package/dist/{tensor2d-jO8JY5Jd.js → tensor2d-CPEkynbH.js} +1 -1
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +3 -3
- package/dist/training/sparseCrossEntropy.js +19 -26
- package/dist/utilities/dummy.js +2 -2
- package/dist/utilities/generate.js +3 -3
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/save.js +1 -1
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-CLVXjN7F.js → variable-wSS22xj5.js} +1 -1
- package/dist/{zeros-DUkkVccu.js → zeros-YJDE7oRb.js} +10 -10
- package/package.json +3 -3
- package/dist/ops/node/sparseCrossEntropy.d.ts +0 -1
- package/dist/ops/node/sparseCrossEntropy.js +0 -11
- package/dist/utilities/load.js +0 -99
package/dist/Generator.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { E as u } from "./index-Dwqa6Zy2.js";
|
|
2
|
-
import "./index-
|
|
2
|
+
import "./index-BAzbokzv.js";
|
|
3
3
|
import "./ops/cpu/attentionMask.js";
|
|
4
4
|
import "./ops/webgl/attentionMask.js";
|
|
5
5
|
import "./ops/grads/attentionMask.js";
|
|
6
6
|
import "./ops/cpu/qkv.js";
|
|
7
7
|
import "./ops/webgl/qkv.js";
|
|
8
8
|
import "./ops/grads/qkv.js";
|
|
9
|
-
import "./random_width-
|
|
10
|
-
import "./register_all_kernels-
|
|
9
|
+
import "./random_width-DWzaOgrn.js";
|
|
10
|
+
import "./register_all_kernels-BfFCQAqs.js";
|
|
11
11
|
import "./index-Tf7vU29b.js";
|
|
12
|
-
import "./dataset-
|
|
12
|
+
import "./dataset-pgqp-YfL.js";
|
|
13
13
|
import "./ops/cpu/rope.js";
|
|
14
14
|
import "./ops/webgl/rope.js";
|
|
15
15
|
import "./ops/grads/rope.js";
|
|
@@ -35,8 +35,8 @@ import "./ops/cpu/gelu.js";
|
|
|
35
35
|
import "./ops/webgl/gelu.js";
|
|
36
36
|
import "./ops/grads/gelu.js";
|
|
37
37
|
import "./ops/webgl/log.js";
|
|
38
|
-
import { t as d } from "./tensor2d-
|
|
39
|
-
import { c as g } from "./concat-
|
|
38
|
+
import { t as d } from "./tensor2d-CPEkynbH.js";
|
|
39
|
+
import { c as g } from "./concat-5aPGqw3Z.js";
|
|
40
40
|
const k = [
|
|
41
41
|
...Array.from({ length: 95 }, (a, t) => String.fromCharCode(t + 32)),
|
|
42
42
|
// ASCII
|
package/dist/NanoGPTModel.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { defaultConfig as F } from "./config.js";
|
|
2
2
|
import O from "./layers/TransformerBlock.js";
|
|
3
|
-
import { T as _, r as D } from "./TiedEmbedding-
|
|
3
|
+
import { T as _, r as D } from "./TiedEmbedding-9WeDwvjO.js";
|
|
4
4
|
import K from "./layers/RoPECache.js";
|
|
5
5
|
import N from "./layers/RMSNorm.js";
|
|
6
6
|
import { estimateParameterCount as R } from "./utilities/parameters.js";
|
|
7
7
|
import { createSoftmaxCrossEntropyWithGrad as A } from "./training/sparseCrossEntropy.js";
|
|
8
8
|
import G from "./layers/BaseLayer.js";
|
|
9
|
-
import { E as B, D as V, p as j } from "./random_width-
|
|
10
|
-
import {
|
|
11
|
-
import { m as Y, t as Z } from "./register_all_kernels-
|
|
12
|
-
import { r as L } from "./reshape-
|
|
13
|
-
import { r as tt } from "./range-
|
|
14
|
-
import { s as M } from "./softmax-
|
|
15
|
-
import { t as et } from "./ops-
|
|
16
|
-
import { g as ot } from "./gather-
|
|
9
|
+
import { E as B, D as V, p as j } from "./random_width-DWzaOgrn.js";
|
|
10
|
+
import { o as W, q as H, E as J, a6 as Q, t as z, a7 as U, s as v, k as X } from "./index-BAzbokzv.js";
|
|
11
|
+
import { m as Y, t as Z } from "./register_all_kernels-BfFCQAqs.js";
|
|
12
|
+
import { r as L } from "./reshape-krWGKraP.js";
|
|
13
|
+
import { r as tt } from "./range-DYsrnfiy.js";
|
|
14
|
+
import { s as M } from "./softmax-fsdtf6JC.js";
|
|
15
|
+
import { t as et } from "./ops-C0sQEcPw.js";
|
|
16
|
+
import { g as ot } from "./gather-DjyCjmOD.js";
|
|
17
17
|
/**
|
|
18
18
|
* @license
|
|
19
19
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ao as T, ac as E, p as O,
|
|
2
|
-
import { r as $ } from "./Reshape-
|
|
3
|
-
import { g as A, a as k, b as C, c as N, e as R } from "./axis_util-
|
|
4
|
-
import { t as U, m as W } from "./shared-
|
|
5
|
-
import { j as _, f as y } from "./gpgpu_math-
|
|
6
|
-
import { g as G, b as L } from "./kernel_funcs_utils-
|
|
1
|
+
import { ao as T, ac as E, p as O, g as V, aw as B, N as F, M as j, ax as K } from "./index-BAzbokzv.js";
|
|
2
|
+
import { r as $ } from "./Reshape-t7Kcikjk.js";
|
|
3
|
+
import { g as A, a as k, b as C, c as N, e as R } from "./axis_util-Bu4h7XWV.js";
|
|
4
|
+
import { t as U, m as W } from "./shared-Ca6iDobD.js";
|
|
5
|
+
import { j as _, f as y } from "./gpgpu_math-CNslybmD.js";
|
|
6
|
+
import { g as G, b as L } from "./kernel_funcs_utils-CUxJCg0g.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as g, g as I, a as x, b as F, c as $, d as u, e as m, i as l } from "./gpgpu_math-
|
|
1
|
+
import { g as c, aa as C, i as f, D as R } from "./index-BAzbokzv.js";
|
|
2
|
+
import { u as g, g as I, a as x, b as F, c as $, d as u, e as m, i as l } from "./gpgpu_math-CNslybmD.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
package/dist/TeachableLLM.d.ts
CHANGED
|
@@ -22,12 +22,15 @@ export default class TeachableLLM {
|
|
|
22
22
|
meta: TeachableLLMMeta;
|
|
23
23
|
constructor(tokeniser?: ITokeniser, model?: NanoGPT);
|
|
24
24
|
get vocab(): string[];
|
|
25
|
+
/** Model is fully loaded */
|
|
25
26
|
get loaded(): boolean;
|
|
26
27
|
get config(): GPTConfig;
|
|
27
28
|
get model(): NanoGPT;
|
|
28
29
|
get tokeniser(): ITokeniser;
|
|
29
30
|
get status(): TeachableLLMStatus;
|
|
31
|
+
/** Model is both ready and not busy */
|
|
30
32
|
get ready(): boolean;
|
|
33
|
+
get busy(): boolean;
|
|
31
34
|
estimateTrainingMemoryUsage(batchSize: number): number;
|
|
32
35
|
private setStatus;
|
|
33
36
|
saveModel(options?: SaveOptions): Promise<Blob>;
|
package/dist/TeachableLLM.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defaultConfig as
|
|
2
|
-
import
|
|
3
|
-
import { saveModel as
|
|
4
|
-
import { loadModel as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { E as
|
|
1
|
+
import { defaultConfig as _ } from "./config.js";
|
|
2
|
+
import f from "./NanoGPTModel.js";
|
|
3
|
+
import { saveModel as u } from "./utilities/save.js";
|
|
4
|
+
import { loadModel as d } from "./loader/load.js";
|
|
5
|
+
import l from "./Generator.js";
|
|
6
|
+
import p from "./Trainer.js";
|
|
7
|
+
import { E as g } from "./index-Dwqa6Zy2.js";
|
|
8
8
|
import { dummyPassTrainAsync as m } from "./utilities/dummy.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import c from "./tokeniser/CharTokeniser.js";
|
|
10
|
+
import k from "./tokeniser/bpe.js";
|
|
11
11
|
import "./papaparse.min-C8l2Kvo1.js";
|
|
12
12
|
import "./index-Tf7vU29b.js";
|
|
13
13
|
import "./jszip.min-CjP2V1VV.js";
|
|
14
|
-
import "./index-
|
|
14
|
+
import "./index-BAzbokzv.js";
|
|
15
15
|
import "./ops/cpu/scatterSub.js";
|
|
16
16
|
import "./ops/webgl/scatterSub.js";
|
|
17
17
|
import "./ops/cpu/gatherSub.js";
|
|
@@ -22,9 +22,9 @@ import "./ops/grads/attentionMask.js";
|
|
|
22
22
|
import "./ops/cpu/qkv.js";
|
|
23
23
|
import "./ops/webgl/qkv.js";
|
|
24
24
|
import "./ops/grads/qkv.js";
|
|
25
|
-
import "./random_width-
|
|
26
|
-
import "./register_all_kernels-
|
|
27
|
-
import "./dataset-
|
|
25
|
+
import "./random_width-DWzaOgrn.js";
|
|
26
|
+
import "./register_all_kernels-BfFCQAqs.js";
|
|
27
|
+
import "./dataset-pgqp-YfL.js";
|
|
28
28
|
import "./ops/cpu/rope.js";
|
|
29
29
|
import "./ops/webgl/rope.js";
|
|
30
30
|
import "./ops/grads/rope.js";
|
|
@@ -43,9 +43,9 @@ import "./ops/cpu/normRMS.js";
|
|
|
43
43
|
import "./ops/webgl/normRMS.js";
|
|
44
44
|
import "./ops/grads/normRMS.js";
|
|
45
45
|
import "./ops/webgl/log.js";
|
|
46
|
-
import
|
|
46
|
+
import w from "./utilities/profile.js";
|
|
47
47
|
class a {
|
|
48
|
-
ee = new
|
|
48
|
+
ee = new g();
|
|
49
49
|
_config;
|
|
50
50
|
_model;
|
|
51
51
|
_tokeniser;
|
|
@@ -58,66 +58,71 @@ class a {
|
|
|
58
58
|
get vocab() {
|
|
59
59
|
return this._tokeniser?.getVocab() || [];
|
|
60
60
|
}
|
|
61
|
+
/** Model is fully loaded */
|
|
61
62
|
get loaded() {
|
|
62
63
|
return !!this._model && !!this._tokeniser && !!this._config;
|
|
63
64
|
}
|
|
64
65
|
get config() {
|
|
65
66
|
if (!this._config)
|
|
66
|
-
throw new Error("
|
|
67
|
+
throw new Error("configuration_not_initialized.");
|
|
67
68
|
return this._config.gpt;
|
|
68
69
|
}
|
|
69
70
|
get model() {
|
|
70
71
|
if (!this._model)
|
|
71
|
-
throw new Error("
|
|
72
|
+
throw new Error("model_not_initialized.");
|
|
72
73
|
return this._model;
|
|
73
74
|
}
|
|
74
75
|
get tokeniser() {
|
|
75
76
|
if (!this._tokeniser)
|
|
76
|
-
throw new Error("
|
|
77
|
+
throw new Error("tokeniser_not_initialized.");
|
|
77
78
|
return this._tokeniser;
|
|
78
79
|
}
|
|
79
80
|
get status() {
|
|
80
81
|
return this._status;
|
|
81
82
|
}
|
|
83
|
+
/** Model is both ready and not busy */
|
|
82
84
|
get ready() {
|
|
83
|
-
return this._status === "ready" && !!this._model && !!this._tokeniser
|
|
85
|
+
return this._status === "ready" && !!this._model && !!this._tokeniser;
|
|
86
|
+
}
|
|
87
|
+
get busy() {
|
|
88
|
+
return this._status === "busy" || this._status === "training";
|
|
84
89
|
}
|
|
85
90
|
estimateTrainingMemoryUsage(t) {
|
|
86
|
-
const e = this._memoryRequirements ?? { perBatch: 0, gradients: 0 },
|
|
87
|
-
return
|
|
91
|
+
const e = this._memoryRequirements ?? { perBatch: 0, gradients: 0 }, i = e.perBatch * t, o = e.gradients;
|
|
92
|
+
return i * 0.66 + o * 4;
|
|
88
93
|
}
|
|
89
94
|
setStatus(t) {
|
|
90
95
|
this._status !== t && (this._status = t, this.ee.emit("status", t));
|
|
91
96
|
}
|
|
92
97
|
saveModel(t) {
|
|
93
98
|
if (!this._model || !this._tokeniser)
|
|
94
|
-
throw new Error("
|
|
95
|
-
return
|
|
99
|
+
throw new Error("model_or_tokeniser_not_initialized.");
|
|
100
|
+
return u(this._model, this._tokeniser, {
|
|
96
101
|
...t,
|
|
97
102
|
name: t?.name || this.meta.name
|
|
98
103
|
});
|
|
99
104
|
}
|
|
100
105
|
static loadModel(t) {
|
|
101
106
|
const e = new a();
|
|
102
|
-
return
|
|
103
|
-
e._model =
|
|
104
|
-
e._memoryRequirements =
|
|
105
|
-
}).catch((
|
|
106
|
-
e.setStatus("error"), e.ee.emit("error",
|
|
107
|
+
return d(t).then(({ model: i, tokeniser: o, name: s }) => {
|
|
108
|
+
e._model = i, e._tokeniser = o, e._config = i.config, s && (e.meta.name = s), e.setStatus("warmup"), m(i).then((r) => {
|
|
109
|
+
e._memoryRequirements = r, e.setStatus("ready"), e.ee.emit("loaded");
|
|
110
|
+
}).catch((r) => {
|
|
111
|
+
e.setStatus("error"), e.ee.emit("error", r);
|
|
107
112
|
});
|
|
108
|
-
}).catch((
|
|
109
|
-
e.setStatus("error"), e.ee.emit("error",
|
|
113
|
+
}).catch((i) => {
|
|
114
|
+
e.setStatus("error"), e.ee.emit("error", i);
|
|
110
115
|
}), e;
|
|
111
116
|
}
|
|
112
117
|
static create(t, e = {}) {
|
|
113
|
-
const
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
h === "trained" &&
|
|
118
|
+
const i = { ..._, ...e }, o = t === "char" ? new c(i.vocabSize) : new k(i.vocabSize), s = new f(i), r = new a(o, s);
|
|
119
|
+
return r.setStatus("warmup"), m(s).then((n) => {
|
|
120
|
+
r._memoryRequirements = n, r.tokeniser.trained ? (r.setStatus("ready"), r.ee.emit("loaded")) : (r.setStatus("awaitingTokens"), r.ee.emit("loaded"), r.tokeniser.once("trainStatus", (h) => {
|
|
121
|
+
h === "trained" && r.setStatus("ready");
|
|
117
122
|
}));
|
|
118
123
|
}).catch((n) => {
|
|
119
|
-
|
|
120
|
-
}),
|
|
124
|
+
r.setStatus("error"), r.ee.emit("error", n);
|
|
125
|
+
}), r;
|
|
121
126
|
}
|
|
122
127
|
getProfiler() {
|
|
123
128
|
return this._model?.getProfiler();
|
|
@@ -128,24 +133,22 @@ class a {
|
|
|
128
133
|
set enableProfiler(t) {
|
|
129
134
|
if (t) {
|
|
130
135
|
if (!this._config)
|
|
131
|
-
|
|
132
|
-
this._config.layerConfig.profiler || (this._config.layerConfig.profiler = new
|
|
136
|
+
return;
|
|
137
|
+
this._config.layerConfig.profiler || (this._config.layerConfig.profiler = new w());
|
|
133
138
|
} else
|
|
134
139
|
this._config?.layerConfig.profiler && (this._config.layerConfig.profiler = void 0);
|
|
135
140
|
}
|
|
136
141
|
getNumParams() {
|
|
137
|
-
|
|
138
|
-
throw new Error("Model is not initialized.");
|
|
139
|
-
return this._model.getNumParams();
|
|
142
|
+
return this._model ? this._model.getNumParams() : 0;
|
|
140
143
|
}
|
|
141
144
|
trainer() {
|
|
142
145
|
if (!this._model || !this._tokeniser)
|
|
143
|
-
throw new Error("
|
|
144
|
-
const t = new
|
|
145
|
-
return t.on("start", () => this.setStatus("training")), t.on("stop", () => this.setStatus("ready")), t.on("log", async (e,
|
|
146
|
+
throw new Error("model_or_tokeniser_not_initialized.");
|
|
147
|
+
const t = new p(this._model, this._tokeniser);
|
|
148
|
+
return t.on("start", () => this.setStatus("training")), t.on("stop", () => this.setStatus("ready")), t.on("log", async (e, i) => {
|
|
146
149
|
const o = this.ee.listeners("trainStep");
|
|
147
150
|
for (const s of o)
|
|
148
|
-
await s(e,
|
|
151
|
+
await s(e, i);
|
|
149
152
|
}), t;
|
|
150
153
|
}
|
|
151
154
|
train(t, e) {
|
|
@@ -160,7 +163,7 @@ class a {
|
|
|
160
163
|
generator() {
|
|
161
164
|
if (!this._model || !this._tokeniser)
|
|
162
165
|
throw new Error("model_or_tokeniser_not_initialized.");
|
|
163
|
-
const t = new
|
|
166
|
+
const t = new l(this._model, this._tokeniser);
|
|
164
167
|
return t.on("start", () => {
|
|
165
168
|
this.status === "ready" && this.setStatus("busy");
|
|
166
169
|
}), t.on("stop", () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { R as a, d as s } from "./random_width-
|
|
2
|
-
import "./index-
|
|
1
|
+
import { R as a, d as s } from "./random_width-DWzaOgrn.js";
|
|
2
|
+
import "./index-BAzbokzv.js";
|
|
3
3
|
import o from "./layers/BaseLayer.js";
|
|
4
|
-
import { v as m } from "./variable-
|
|
5
|
-
import { g as d } from "./gather-
|
|
4
|
+
import { v as m } from "./variable-wSS22xj5.js";
|
|
5
|
+
import { g as d } from "./gather-DjyCjmOD.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2018 Google LLC
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as T } from "./reshape-
|
|
1
|
+
import { o as h, q as f, x as p, H as g, E as u, I as b } from "./index-BAzbokzv.js";
|
|
2
|
+
import { r as T } from "./reshape-krWGKraP.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as s, i as a, w as i, H as p, E as l, J as f } from "./index-BAzbokzv.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -15,15 +15,15 @@ import { q as s, k as a, x as p, I as i, E as l, K as f } from "./index-CamYe_M8
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function h(
|
|
19
|
-
a(
|
|
20
|
-
const t =
|
|
21
|
-
if (t[0].dtype === "complex64" && t.forEach((
|
|
22
|
-
if (
|
|
18
|
+
function h(o, e = 0) {
|
|
19
|
+
a(o.length >= 1, () => "Pass at least one tensor to concat");
|
|
20
|
+
const t = i(o, "tensors", "concat", "string_or_numeric");
|
|
21
|
+
if (t[0].dtype === "complex64" && t.forEach((n) => {
|
|
22
|
+
if (n.dtype !== "complex64")
|
|
23
23
|
throw new Error(`Cannot concatenate complex64 tensors with a tensor
|
|
24
|
-
with dtype ${
|
|
24
|
+
with dtype ${n.dtype}. `);
|
|
25
25
|
}), t.length === 1)
|
|
26
|
-
return
|
|
26
|
+
return p(t[0]);
|
|
27
27
|
const r = t, c = { axis: e };
|
|
28
28
|
return l.runKernel(f, r, c);
|
|
29
29
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ab as S, T as h, ac as
|
|
1
|
+
import { ab as S, T as h, ac as N, d as v, ad as o, ae as p, af as g, i as k, t as y } from "./index-BAzbokzv.js";
|
|
2
2
|
import { s as R } from "./index-C4L8Cm77.js";
|
|
3
|
-
import { s as $ } from "./stack-
|
|
4
|
-
import { t as B } from "./tensor-
|
|
3
|
+
import { s as $ } from "./stack-dfEEz2OY.js";
|
|
4
|
+
import { t as B } from "./tensor-Xyi595sG.js";
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -75,7 +75,7 @@ function I(s) {
|
|
|
75
75
|
}
|
|
76
76
|
function c(s) {
|
|
77
77
|
let t = !1;
|
|
78
|
-
if (
|
|
78
|
+
if (N().get("IS_BROWSER"))
|
|
79
79
|
t = s instanceof TextDecoder;
|
|
80
80
|
else {
|
|
81
81
|
const { StringDecoder: e } = require("string_decoder");
|
|
@@ -930,7 +930,7 @@ class T {
|
|
|
930
930
|
*/
|
|
931
931
|
batch(t, e = !0) {
|
|
932
932
|
const r = this;
|
|
933
|
-
|
|
933
|
+
k(t > 0, () => `batchSize needs to be positive, but it is
|
|
934
934
|
${t}`);
|
|
935
935
|
let n;
|
|
936
936
|
return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await r.iterator()).columnMajorBatch(t, e, st), n);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as l, q as h, E as m, ag as p, x as c, ah as d, ai as g, i as u, T as V, aj as v, a7 as N, a as w } from "./index-BAzbokzv.js";
|
|
2
2
|
import { s as f } from "./index-C4L8Cm77.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
@@ -16,11 +16,11 @@ import { s as f } from "./index-C4L8Cm77.js";
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
* =============================================================================
|
|
18
18
|
*/
|
|
19
|
-
function
|
|
19
|
+
function x(r) {
|
|
20
20
|
const e = { x: h(r, "x", "floor", "float32") };
|
|
21
21
|
return m.runKernel(p, e);
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const b = /* @__PURE__ */ l({ floor_: x });
|
|
24
24
|
/**
|
|
25
25
|
* @license
|
|
26
26
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -69,7 +69,7 @@ class T {
|
|
|
69
69
|
return t <= this.upper && t >= this.lower;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class $ {
|
|
73
73
|
constructor(t = 0, e = 1, s, n) {
|
|
74
74
|
if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = t, this.range = e - t, this.dtype = s, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
|
|
75
75
|
throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);
|
|
@@ -98,7 +98,7 @@ class y {
|
|
|
98
98
|
* limitations under the License.
|
|
99
99
|
* =============================================================================
|
|
100
100
|
*/
|
|
101
|
-
function
|
|
101
|
+
function y(r, t = 0, e = 1, s, n) {
|
|
102
102
|
if (c(r), s != null && s === "bool")
|
|
103
103
|
throw new Error(`Unsupported data type ${s}`);
|
|
104
104
|
const o = new T(t, e, s, !1, n), a = d(r, s);
|
|
@@ -106,7 +106,7 @@ function $(r, t = 0, e = 1, s, n) {
|
|
|
106
106
|
a.values[i] = o.nextValue();
|
|
107
107
|
return a.toTensor();
|
|
108
108
|
}
|
|
109
|
-
const _ = /* @__PURE__ */ l({ randomNormal_:
|
|
109
|
+
const _ = /* @__PURE__ */ l({ randomNormal_: y });
|
|
110
110
|
/**
|
|
111
111
|
* @license
|
|
112
112
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -125,7 +125,7 @@ const _ = /* @__PURE__ */ l({ randomNormal_: $ });
|
|
|
125
125
|
*/
|
|
126
126
|
function M(r, t = 0, e = 1, s = "float32", n) {
|
|
127
127
|
c(r);
|
|
128
|
-
const o = d(r, s), a = new
|
|
128
|
+
const o = d(r, s), a = new $(t, e, null, n);
|
|
129
129
|
for (let i = 0; i < o.values.length; i++)
|
|
130
130
|
o.values[i] = a.nextValue();
|
|
131
131
|
return o.toTensor();
|
|
@@ -180,14 +180,14 @@ function R(r, t, e, s) {
|
|
|
180
180
|
const n = h(r, "x", "dropout");
|
|
181
181
|
if (u(n.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${n.dtype} tensor instead.`), u(t >= 0 && t < 1, () => `rate must be a float in the range [0, 1), but got ${t}.`), t === 0)
|
|
182
182
|
return r instanceof V ? n.clone() : n;
|
|
183
|
-
const o = E(n, e), a = 1 - t, i = v(
|
|
184
|
-
return
|
|
183
|
+
const o = E(n, e), a = 1 - t, i = v(b(N(D(o, 0, 1, "float32", s), a)), a);
|
|
184
|
+
return w(n, i);
|
|
185
185
|
}
|
|
186
186
|
const q = /* @__PURE__ */ l({ dropout_: R });
|
|
187
187
|
export {
|
|
188
188
|
T as M,
|
|
189
189
|
D as a,
|
|
190
190
|
q as d,
|
|
191
|
-
|
|
191
|
+
b as f,
|
|
192
192
|
_ as r
|
|
193
193
|
};
|