@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.
Files changed (117) hide show
  1. package/dist/Generator.js +6 -6
  2. package/dist/NanoGPTModel.js +9 -9
  3. package/dist/{RealDiv-7xu-pkZN.js → RealDiv-BYViZwhN.js} +6 -6
  4. package/dist/{Reshape-BYC1oUku.js → Reshape-t7Kcikjk.js} +2 -2
  5. package/dist/TeachableLLM.d.ts +3 -0
  6. package/dist/TeachableLLM.js +49 -46
  7. package/dist/{TiedEmbedding-C1HBot-5.js → TiedEmbedding-9WeDwvjO.js} +4 -4
  8. package/dist/{axis_util-CCNL7jea.js → axis_util-Bu4h7XWV.js} +1 -1
  9. package/dist/{broadcast_to-CddAF879.js → broadcast_to-DARN-DBD.js} +2 -2
  10. package/dist/{concat-XOK9ANZu.js → concat-5aPGqw3Z.js} +8 -8
  11. package/dist/{dataset-BFFipD1c.js → dataset-pgqp-YfL.js} +5 -5
  12. package/dist/{dropout-xlKRoJyU.js → dropout-Bciw46HT.js} +10 -10
  13. package/dist/{gather-DKtUaTtA.js → gather-DjyCjmOD.js} +1 -1
  14. package/dist/{gpgpu_math-B_ycgZ4W.js → gpgpu_math-CNslybmD.js} +31 -31
  15. package/dist/{index-CamYe_M8.js → index-BAzbokzv.js} +31 -31
  16. package/dist/{kernel_funcs_utils-D5MS0JFg.js → kernel_funcs_utils-CUxJCg0g.js} +5 -5
  17. package/dist/layers/BaseLayer.js +2 -2
  18. package/dist/layers/CausalSelfAttention.js +6 -6
  19. package/dist/layers/MLP.js +5 -5
  20. package/dist/layers/RMSNorm.js +3 -3
  21. package/dist/layers/RoPECache.js +4 -4
  22. package/dist/layers/TiedEmbedding.js +5 -5
  23. package/dist/layers/TransformerBlock.js +1 -1
  24. package/dist/loader/load.d.ts +13 -0
  25. package/dist/loader/load.js +27 -0
  26. package/dist/loader/loadHF.d.ts +7 -0
  27. package/dist/loader/loadHF.js +22 -0
  28. package/dist/{utilities/load.d.ts → loader/loadTransformers.d.ts} +11 -11
  29. package/dist/loader/loadTransformers.js +28 -0
  30. package/dist/loader/newZipLoad.d.ts +8 -0
  31. package/dist/loader/newZipLoad.js +21 -0
  32. package/dist/loader/oldZipLoad.d.ts +7 -0
  33. package/dist/loader/oldZipLoad.js +76 -0
  34. package/dist/{log_sum_exp-CV_5-TTu.js → log_sum_exp-YEo2h3gb.js} +16 -16
  35. package/dist/main.js +4 -4
  36. package/dist/{mat_mul-CAbRFWUj.js → mat_mul-7121rsJk.js} +4 -4
  37. package/dist/{max-JBBv7aUf.js → max-DtlIuVeW.js} +3 -3
  38. package/dist/{mulmat_packed_gpu-DW4doKL_.js → mulmat_packed_gpu-D4nKF7Je.js} +1 -1
  39. package/dist/{norm-B9dQTFYn.js → norm-CzltS9Fz.js} +10 -10
  40. package/dist/{ones-CMHNqMr6.js → ones-BBlSRqn1.js} +2 -2
  41. package/dist/ops/appendCache.js +3 -3
  42. package/dist/ops/attentionMask.js +1 -1
  43. package/dist/ops/cpu/appendCache.js +2 -2
  44. package/dist/ops/cpu/attentionMask.js +6 -6
  45. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  46. package/dist/ops/cpu/gatherSub.js +9 -9
  47. package/dist/ops/cpu/gelu.js +1 -1
  48. package/dist/ops/cpu/matMulGelu.js +1 -1
  49. package/dist/ops/cpu/matMulMul.js +1 -1
  50. package/dist/ops/cpu/mulDropout.js +1 -1
  51. package/dist/ops/cpu/normRMS.js +1 -1
  52. package/dist/ops/cpu/qkv.js +3 -3
  53. package/dist/ops/cpu/rope.js +5 -5
  54. package/dist/ops/cpu/scatterSub.js +14 -14
  55. package/dist/ops/fusedSoftmax.js +1 -1
  56. package/dist/ops/gatherSub.js +1 -1
  57. package/dist/ops/gelu.js +1 -1
  58. package/dist/ops/grads/attentionMask.js +1 -1
  59. package/dist/ops/grads/fusedSoftmax.js +4 -4
  60. package/dist/ops/grads/gelu.js +1 -1
  61. package/dist/ops/grads/matMulGelu.js +1 -1
  62. package/dist/ops/grads/normRMS.js +1 -1
  63. package/dist/ops/grads/qkv.js +1 -1
  64. package/dist/ops/grads/rope.js +1 -1
  65. package/dist/ops/matMulGelu.js +1 -1
  66. package/dist/ops/matMulMul.js +1 -1
  67. package/dist/ops/mulDrop.js +1 -1
  68. package/dist/ops/normRMS.js +1 -1
  69. package/dist/ops/qkv.js +1 -1
  70. package/dist/ops/rope.js +4 -4
  71. package/dist/ops/scatterSub.js +1 -1
  72. package/dist/ops/webgl/appendCache.js +1 -1
  73. package/dist/ops/webgl/attentionMask.js +1 -1
  74. package/dist/ops/webgl/fusedSoftmax.js +4 -4
  75. package/dist/ops/webgl/gatherSub.js +1 -1
  76. package/dist/ops/webgl/gelu.js +2 -2
  77. package/dist/ops/webgl/log.js +3 -3
  78. package/dist/ops/webgl/matMulGelu.js +17 -17
  79. package/dist/ops/webgl/matMulMul.js +1 -1
  80. package/dist/ops/webgl/mulDropout.js +1 -1
  81. package/dist/ops/webgl/normRMS.js +2 -2
  82. package/dist/ops/webgl/qkv.js +1 -1
  83. package/dist/ops/webgl/rope.js +1 -1
  84. package/dist/ops/webgl/scatterSub.js +1 -1
  85. package/dist/{ops-DqtYemmV.js → ops-C0sQEcPw.js} +78 -78
  86. package/dist/{random_width-CLMQG5Jn.js → random_width-DWzaOgrn.js} +22 -22
  87. package/dist/{range-DqYjKnuG.js → range-DYsrnfiy.js} +1 -1
  88. package/dist/{reciprocal-z49filta.js → reciprocal-CJQeasVa.js} +1 -1
  89. package/dist/{register_all_kernels-COt6wLD0.js → register_all_kernels-BfFCQAqs.js} +28 -28
  90. package/dist/{reshape-C45vIIRU.js → reshape-krWGKraP.js} +1 -1
  91. package/dist/{scatter_nd_util-qgtnviTE.js → scatter_nd_util-93ln7Hut.js} +3 -3
  92. package/dist/{selu_util-4QV_GXTB.js → selu_util-sntGesxr.js} +41 -41
  93. package/dist/{shared-ByfrGA97.js → shared-Ca6iDobD.js} +6 -6
  94. package/dist/{sin-9JBrfVaB.js → sin-D_h-qCSx.js} +1 -1
  95. package/dist/{softmax-DvMvui-_.js → softmax-fsdtf6JC.js} +1 -1
  96. package/dist/{split-DxrHrPFK.js → split-eiktj-6L.js} +4 -4
  97. package/dist/{stack-DgaoDmnF.js → stack-dfEEz2OY.js} +2 -2
  98. package/dist/{sum-BpcpxNEh.js → sum-BE_Irnim.js} +3 -3
  99. package/dist/{tensor-CDz5x1mP.js → tensor-Xyi595sG.js} +1 -1
  100. package/dist/{tensor2d-jO8JY5Jd.js → tensor2d-CPEkynbH.js} +1 -1
  101. package/dist/training/AdamExt.js +1 -1
  102. package/dist/training/DatasetBuilder.js +2 -2
  103. package/dist/training/FullTrainer.js +1 -1
  104. package/dist/training/Trainer.js +3 -3
  105. package/dist/training/sparseCrossEntropy.js +19 -26
  106. package/dist/utilities/dummy.js +2 -2
  107. package/dist/utilities/generate.js +3 -3
  108. package/dist/utilities/profile.js +1 -1
  109. package/dist/utilities/safetensors.js +2 -2
  110. package/dist/utilities/save.js +1 -1
  111. package/dist/utilities/weights.js +2 -2
  112. package/dist/{variable-CLVXjN7F.js → variable-wSS22xj5.js} +1 -1
  113. package/dist/{zeros-DUkkVccu.js → zeros-YJDE7oRb.js} +10 -10
  114. package/package.json +3 -3
  115. package/dist/ops/node/sparseCrossEntropy.d.ts +0 -1
  116. package/dist/ops/node/sparseCrossEntropy.js +0 -11
  117. 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-CamYe_M8.js";
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-CLMQG5Jn.js";
10
- import "./register_all_kernels-COt6wLD0.js";
9
+ import "./random_width-DWzaOgrn.js";
10
+ import "./register_all_kernels-BfFCQAqs.js";
11
11
  import "./index-Tf7vU29b.js";
12
- import "./dataset-BFFipD1c.js";
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-jO8JY5Jd.js";
39
- import { c as g } from "./concat-XOK9ANZu.js";
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
@@ -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-C1HBot-5.js";
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-CLMQG5Jn.js";
10
- import { q as W, w as H, E as J, a6 as Q, t as z, a7 as U, f as v, n as X } from "./index-CamYe_M8.js";
11
- import { m as Y, t as Z } from "./register_all_kernels-COt6wLD0.js";
12
- import { r as L } from "./reshape-C45vIIRU.js";
13
- import { r as tt } from "./range-DqYjKnuG.js";
14
- import { s as M } from "./softmax-DvMvui-_.js";
15
- import { t as et } from "./ops-DqtYemmV.js";
16
- import { g as ot } from "./gather-DKtUaTtA.js";
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, i as V, aw as B, O as F, M as j, ax as K } from "./index-CamYe_M8.js";
2
- import { r as $ } from "./Reshape-BYC1oUku.js";
3
- import { g as A, a as k, b as C, c as N, e as R } from "./axis_util-CCNL7jea.js";
4
- import { t as U, m as W } from "./shared-ByfrGA97.js";
5
- import { j as _, f as y } from "./gpgpu_math-B_ycgZ4W.js";
6
- import { g as G, b as L } from "./kernel_funcs_utils-D5MS0JFg.js";
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 { i as c, aa as C, k as f, F as R } from "./index-CamYe_M8.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-B_ycgZ4W.js";
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.
@@ -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>;
@@ -1,17 +1,17 @@
1
- import { defaultConfig as d } from "./config.js";
2
- import l from "./NanoGPTModel.js";
3
- import { saveModel as f } from "./utilities/save.js";
4
- import { loadModel as u } from "./utilities/load.js";
5
- import p from "./Generator.js";
6
- import _ from "./Trainer.js";
7
- import { E as c } from "./index-Dwqa6Zy2.js";
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 g from "./tokeniser/CharTokeniser.js";
10
- import w from "./tokeniser/bpe.js";
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-CamYe_M8.js";
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-CLMQG5Jn.js";
26
- import "./register_all_kernels-COt6wLD0.js";
27
- import "./dataset-BFFipD1c.js";
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 k from "./utilities/profile.js";
46
+ import w from "./utilities/profile.js";
47
47
  class a {
48
- ee = new c();
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("Model configuration is not initialized.");
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("Model is not initialized.");
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("Tokeniser is not initialized.");
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 && this.tokeniser.trained;
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 }, r = e.perBatch * t, o = e.gradients;
87
- return r * 0.66 + o * 4;
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("Model or tokeniser is not initialized.");
95
- return f(this._model, this._tokeniser, {
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 u(t).then(({ model: r, tokeniser: o, name: s }) => {
103
- e._model = r, e._tokeniser = o, e._config = r.config, s && (e.meta.name = s), e.setStatus("warmup"), m(r).then((i) => {
104
- e._memoryRequirements = i, e.setStatus("ready"), e.ee.emit("loaded");
105
- }).catch((i) => {
106
- e.setStatus("error"), e.ee.emit("error", i);
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((r) => {
109
- e.setStatus("error"), e.ee.emit("error", r);
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 r = { ...d, ...e }, o = t === "char" ? new g(r.vocabSize) : new w(r.vocabSize), s = new l(r), i = new a(o, s);
114
- return i.setStatus("warmup"), m(s).then((n) => {
115
- i._memoryRequirements = n, i.tokeniser.trained ? (i.setStatus("ready"), i.ee.emit("loaded")) : (i.setStatus("awaitingTokens"), i.ee.emit("loaded"), i.tokeniser.once("trainStatus", (h) => {
116
- h === "trained" && i.setStatus("ready");
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
- i.setStatus("error"), i.ee.emit("error", n);
120
- }), i;
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
- throw new Error("Model is not initialized.");
132
- this._config.layerConfig.profiler || (this._config.layerConfig.profiler = new k());
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
- if (!this._model)
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("Model or tokeniser is not initialized.");
144
- const t = new _(this._model, this._tokeniser);
145
- return t.on("start", () => this.setStatus("training")), t.on("stop", () => this.setStatus("ready")), t.on("log", async (e, r) => {
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, r);
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 p(this._model, this._tokeniser);
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-CLMQG5Jn.js";
2
- import "./index-CamYe_M8.js";
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-CLVXjN7F.js";
5
- import { g as d } from "./gather-DKtUaTtA.js";
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,4 +1,4 @@
1
- import { k as c } from "./index-CamYe_M8.js";
1
+ import { i as c } from "./index-BAzbokzv.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC. All Rights Reserved.
@@ -1,5 +1,5 @@
1
- import { q as h, w as f, y as p, I as g, E as u, J as b } from "./index-CamYe_M8.js";
2
- import { r as T } from "./reshape-C45vIIRU.js";
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 { q as s, k as a, x as p, I as i, E as l, K as f } from "./index-CamYe_M8.js";
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(n, e = 0) {
19
- a(n.length >= 1, () => "Pass at least one tensor to concat");
20
- const t = p(n, "tensors", "concat", "string_or_numeric");
21
- if (t[0].dtype === "complex64" && t.forEach((o) => {
22
- if (o.dtype !== "complex64")
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 ${o.dtype}. `);
24
+ with dtype ${n.dtype}. `);
25
25
  }), t.length === 1)
26
- return i(t[0]);
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 k, a as v, ad as o, ae as p, af as g, k as N, t as y } from "./index-CamYe_M8.js";
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-DgaoDmnF.js";
4
- import { t as B } from "./tensor-CDz5x1mP.js";
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 (k().get("IS_BROWSER"))
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
- N(t > 0, () => `batchSize needs to be positive, but it is
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 { q as l, w as h, E as m, ag as p, y as c, ah as d, ai as g, k as u, T as V, aj as v, a7 as w, b as N } from "./index-CamYe_M8.js";
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 b(r) {
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 x = /* @__PURE__ */ l({ floor_: b });
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 y {
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 $(r, t = 0, e = 1, s, n) {
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 y(t, e, null, n);
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(x(w(D(o, 0, 1, "float32", s), a)), a);
184
- return N(n, i);
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
- x as f,
191
+ b as f,
192
192
  _ as r
193
193
  };
@@ -1,4 +1,4 @@
1
- import { q as g, w as t, E as h, G as p } from "./index-CamYe_M8.js";
1
+ import { o as g, q as t, E as h, G as p } from "./index-BAzbokzv.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.