@genai-fi/nanogpt 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/BaseLayer-BhrMN8JO.js +135 -0
  2. package/dist/Generator.js +44 -41
  3. package/dist/NanoGPTModel.d.ts +12 -16
  4. package/dist/NanoGPTModel.js +128 -138
  5. package/dist/{Reshape-CiAY8ltP.js → Reshape-BE5rA4rT.js} +8 -8
  6. package/dist/TeachableLLM.js +8 -5
  7. package/dist/{TiedEmbedding-DznFwzcB.js → TiedEmbedding-DsDRvLB0.js} +751 -768
  8. package/dist/{axis_util-QP0LdI1v.js → axis_util-97KkkyRQ.js} +1 -1
  9. package/dist/broadcast_to-CMlkG8NS.js +44 -0
  10. package/dist/{concat-DvWM7HGZ.js → concat-Cxbo2sOz.js} +3 -3
  11. package/dist/{dropout-DFEXTPV0.js → dropout-kbDY39Ci.js} +1 -1
  12. package/dist/{gather-C5D8PxwA.js → gather-Bxe1Qip8.js} +4 -4
  13. package/dist/{gpgpu_math-CUzjlO9A.js → gpgpu_math-C0zyxKFi.js} +1 -1
  14. package/dist/{index--6vO-cOz.js → index-iNhkcAEQ.js} +82 -82
  15. package/dist/{kernel_funcs_utils-C6YBCuOt.js → kernel_funcs_utils-C4eIk4fE.js} +20 -20
  16. package/dist/layers/BaseLayer.d.ts +28 -4
  17. package/dist/layers/BaseLayer.js +3 -16
  18. package/dist/layers/CausalSelfAttention.d.ts +22 -24
  19. package/dist/layers/CausalSelfAttention.js +73 -127
  20. package/dist/layers/MLP.d.ts +8 -15
  21. package/dist/layers/MLP.js +43 -81
  22. package/dist/layers/RMSNorm.d.ts +5 -11
  23. package/dist/layers/RMSNorm.js +13 -29
  24. package/dist/layers/RoPECache.js +14 -12
  25. package/dist/layers/TiedEmbedding.d.ts +6 -16
  26. package/dist/layers/TiedEmbedding.js +5 -5
  27. package/dist/layers/TransformerBlock.d.ts +12 -16
  28. package/dist/layers/TransformerBlock.js +20 -41
  29. package/dist/{log_sum_exp-CiEy1aUe.js → log_sum_exp-CkumwesB.js} +11 -11
  30. package/dist/main.js +22 -19
  31. package/dist/{mat_mul-BEHRPMh0.js → mat_mul-D0SifYfJ.js} +3 -3
  32. package/dist/{max-BUShNgfh.js → max-CYaAjEEp.js} +3 -3
  33. package/dist/{moments-DYOHXoRV.js → moments-B06NlR_V.js} +6 -6
  34. package/dist/{norm-DSva3hI3.js → norm-D3676xIo.js} +7 -7
  35. package/dist/{ones-D6kB8bdY.js → ones-BIeFnPHR.js} +2 -2
  36. package/dist/ops/appendCache.js +4 -4
  37. package/dist/ops/attentionMask.d.ts +1 -1
  38. package/dist/ops/attentionMask.js +4 -4
  39. package/dist/ops/cpu/appendCache.js +2 -2
  40. package/dist/ops/cpu/attentionMask.js +14 -15
  41. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  42. package/dist/ops/cpu/gatherSub.js +5 -5
  43. package/dist/ops/cpu/gelu.js +1 -1
  44. package/dist/ops/cpu/matMulGelu.js +1 -1
  45. package/dist/ops/cpu/matMulMul.d.ts +1 -0
  46. package/dist/ops/cpu/matMulMul.js +17 -0
  47. package/dist/ops/cpu/mulDropout.js +1 -1
  48. package/dist/ops/cpu/normRMS.d.ts +1 -0
  49. package/dist/ops/cpu/normRMS.js +39 -0
  50. package/dist/ops/cpu/qkv.js +3 -3
  51. package/dist/ops/cpu/rope.js +5 -5
  52. package/dist/ops/cpu/scatterSub.js +8 -8
  53. package/dist/ops/fusedSoftmax.js +1 -1
  54. package/dist/ops/gatherSub.js +1 -1
  55. package/dist/ops/gelu.js +1 -1
  56. package/dist/ops/grads/attentionMask.js +13 -9
  57. package/dist/ops/grads/fusedSoftmax.js +12 -9
  58. package/dist/ops/grads/gelu.js +1 -1
  59. package/dist/ops/grads/matMulGelu.js +1 -1
  60. package/dist/ops/grads/normRMS.d.ts +2 -0
  61. package/dist/ops/grads/normRMS.js +20 -0
  62. package/dist/ops/grads/qkv.js +19 -9
  63. package/dist/ops/grads/rope.js +1 -1
  64. package/dist/ops/matMulGelu.js +1 -1
  65. package/dist/ops/matMulMul.d.ts +2 -0
  66. package/dist/ops/matMulMul.js +9 -0
  67. package/dist/ops/mulDrop.js +1 -1
  68. package/dist/ops/node/sparseCrossEntropy.js +1 -1
  69. package/dist/ops/normRMS.d.ts +2 -0
  70. package/dist/ops/normRMS.js +10 -0
  71. package/dist/ops/qkv.js +1 -1
  72. package/dist/ops/scatterSub.js +1 -1
  73. package/dist/ops/webgl/appendCache.js +1 -1
  74. package/dist/ops/webgl/attentionMask.js +13 -12
  75. package/dist/ops/webgl/fusedSoftmax.js +43 -40
  76. package/dist/ops/webgl/gatherSub.js +1 -1
  77. package/dist/ops/webgl/gelu.js +2 -2
  78. package/dist/ops/webgl/matMulGelu.d.ts +3 -2
  79. package/dist/ops/webgl/matMulGelu.js +77 -75
  80. package/dist/ops/webgl/matMulMul.d.ts +14 -0
  81. package/dist/ops/webgl/matMulMul.js +28 -0
  82. package/dist/ops/webgl/mulDropout.js +1 -1
  83. package/dist/ops/webgl/normRMS.d.ts +1 -0
  84. package/dist/ops/webgl/normRMS.js +86 -0
  85. package/dist/ops/webgl/qkv.js +1 -1
  86. package/dist/ops/webgl/rope.js +1 -1
  87. package/dist/ops/webgl/scatterSub.js +1 -1
  88. package/dist/ops-ObfXLHYQ.js +1269 -0
  89. package/dist/{range-C_vpUjBu.js → range-BsFU-SNG.js} +1 -1
  90. package/dist/{reshape-z51Eu-re.js → reshape-DxTPgnwL.js} +3 -3
  91. package/dist/{sin-H567uayl.js → sin-BOX-JVAj.js} +5 -5
  92. package/dist/slice_util-D-kaD4ZV.js +49 -0
  93. package/dist/{softmax-Dsxflvdl.js → softmax-BjsptB07.js} +2 -2
  94. package/dist/{split-B_k_jwud.js → split-BCbrzthj.js} +4 -4
  95. package/dist/{stack-CmqSdsfs.js → stack--cqr9Dgc.js} +2 -2
  96. package/dist/{sum-DdkDf2MG.js → sum-B_92TaHD.js} +5 -5
  97. package/dist/{tensor-BGYi41cj.js → tensor-CfiPXsW4.js} +1 -1
  98. package/dist/{tensor2d-DUr_htjt.js → tensor2d-tSxWdFMH.js} +1 -1
  99. package/dist/tfjs_backend-NucKez4s.js +1010 -0
  100. package/dist/training/AdamExt.js +1 -1
  101. package/dist/training/DatasetBuilder.js +44 -44
  102. package/dist/training/Evaluator.js +6 -6
  103. package/dist/training/FullTrainer.js +1 -1
  104. package/dist/training/Trainer.js +7 -7
  105. package/dist/training/sparseCrossEntropy.js +4 -4
  106. package/dist/utilities/dummy.js +10 -10
  107. package/dist/utilities/generate.js +3 -3
  108. package/dist/utilities/load.js +1 -1
  109. package/dist/utilities/profile.js +1 -1
  110. package/dist/utilities/save.js +10 -8
  111. package/dist/utilities/weights.js +2 -2
  112. package/dist/{zeros-8xl-W2DC.js → zeros-NMYTayy7.js} +3 -3
  113. package/package.json +1 -1
  114. package/dist/slice_util-BdhYwFY_.js +0 -90
  115. package/dist/tfjs_backend-DuKis_xG.js +0 -2271
  116. package/dist/variable-BJTZ3jOy.js +0 -23
@@ -1,4 +1,4 @@
1
- import { E as e, R as f } from "./index--6vO-cOz.js";
1
+ import { E as e, R as f } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -1,4 +1,4 @@
1
- import { o, h as t, E as a, q as p } from "./index--6vO-cOz.js";
1
+ import { o, i as t, E as a, u as p } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -19,7 +19,7 @@ function c(r, s) {
19
19
  const e = { x: t(r, "x", "reshape", "string_or_numeric") }, n = { shape: s };
20
20
  return a.runKernel(p, e, n);
21
21
  }
22
- const u = /* @__PURE__ */ o({ reshape_: c });
22
+ const x = /* @__PURE__ */ o({ reshape_: c });
23
23
  export {
24
- u as r
24
+ x as r
25
25
  };
@@ -1,4 +1,4 @@
1
- import { o, h as t, E as c, V as a, W as e } from "./index--6vO-cOz.js";
1
+ import { o, i as t, E as c, _ as i, $ as a } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -15,11 +15,11 @@ import { o, h as t, E as c, V as a, W as e } from "./index--6vO-cOz.js";
15
15
  * limitations under the License.
16
16
  * =============================================================================
17
17
  */
18
- function i(n) {
18
+ function e(n) {
19
19
  const s = { x: t(n, "x", "cos", "float32") };
20
- return c.runKernel(a, s);
20
+ return c.runKernel(i, s);
21
21
  }
22
- const f = /* @__PURE__ */ o({ cos_: i });
22
+ const f = /* @__PURE__ */ o({ cos_: e });
23
23
  /**
24
24
  * @license
25
25
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -38,7 +38,7 @@ const f = /* @__PURE__ */ o({ cos_: i });
38
38
  */
39
39
  function x(n) {
40
40
  const s = { x: t(n, "x", "sin", "float32") };
41
- return c.runKernel(e, s);
41
+ return c.runKernel(a, s);
42
42
  }
43
43
  const p = /* @__PURE__ */ o({ sin_: x });
44
44
  export {
@@ -0,0 +1,49 @@
1
+ import { k as s } from "./index-iNhkcAEQ.js";
2
+ /**
3
+ * @license
4
+ * Copyright 2021 Google LLC. All Rights Reserved.
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ * =============================================================================
17
+ */
18
+ function u(r, n, t) {
19
+ let l = t.length;
20
+ for (let e = 0; e < t.length; e++)
21
+ if (t[e] > 1) {
22
+ l = e;
23
+ break;
24
+ }
25
+ for (let e = l + 1; e < t.length; e++)
26
+ if (n[e] > 0 || t[e] !== r[e])
27
+ return !1;
28
+ return !0;
29
+ }
30
+ function c(r, n) {
31
+ let t = r.length > 0 ? r[r.length - 1] : 1;
32
+ for (let l = 0; l < r.length - 1; l++)
33
+ t += r[l] * n[l];
34
+ return t;
35
+ }
36
+ function h(r, n, t) {
37
+ let l;
38
+ const e = r.shape.length;
39
+ typeof n == "number" ? l = [n, ...new Array(e - 1).fill(0)] : n.length < e ? l = n.concat(new Array(e - n.length).fill(0)) : l = n.slice(), l.forEach((a) => {
40
+ s(a !== -1, () => "slice() does not support negative begin indexing.");
41
+ });
42
+ let f;
43
+ return t == null ? f = new Array(e).fill(-1) : typeof t == "number" ? f = [t, ...new Array(e - 1).fill(-1)] : t.length < e ? f = t.concat(new Array(e - t.length).fill(-1)) : f = t, f = f.map((a, o) => a >= 0 ? a : (s(a === -1, () => `Negative size values should be exactly -1 but got ${a} for the slice() size at index ${o}.`), r.shape[o] - l[o])), [l, f];
44
+ }
45
+ export {
46
+ c,
47
+ u as i,
48
+ h as p
49
+ };
@@ -1,4 +1,4 @@
1
- import { o as r, h as f, E as e, S as i } from "./index--6vO-cOz.js";
1
+ import { o as r, i as f, E as i, S as e } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -20,7 +20,7 @@ function l(s, o = -1) {
20
20
  if (o === -1 && (o = t.rank - 1), o !== t.rank - 1)
21
21
  throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${o}`);
22
22
  const n = { logits: t }, a = { dim: o };
23
- return e.runKernel(i, n, a);
23
+ return i.runKernel(e, n, a);
24
24
  }
25
25
  const p = /* @__PURE__ */ r({ softmax_: l });
26
26
  export {
@@ -1,4 +1,4 @@
1
- import { o as p, h as i, E as a, u as c } from "./index--6vO-cOz.js";
1
+ import { o as i, i as p, E as a, w as c } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -16,10 +16,10 @@ import { o as p, h as i, E as a, u as c } from "./index--6vO-cOz.js";
16
16
  * =============================================================================
17
17
  */
18
18
  function e(t, s, o = 0) {
19
- const n = { x: i(t, "x", "split") }, r = { numOrSizeSplits: s, axis: o };
19
+ const n = { x: p(t, "x", "split") }, r = { numOrSizeSplits: s, axis: o };
20
20
  return a.runKernel(c, n, r);
21
21
  }
22
- const x = /* @__PURE__ */ p({ split_: e });
22
+ const u = /* @__PURE__ */ i({ split_: e });
23
23
  export {
24
- x as s
24
+ u as s
25
25
  };
@@ -1,4 +1,4 @@
1
- import { o as e, i as c, j as n, E as i, P as k } from "./index--6vO-cOz.js";
1
+ import { o as e, j as c, k as n, E as k, P as i } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -19,7 +19,7 @@ function u(r, t = 0) {
19
19
  const s = c(r, "tensors", "stack", "string_or_numeric");
20
20
  n(s.length >= 1, () => "Pass at least one tensor to tf.stack"), s.length > 0 && n(t <= s[0].rank, () => "Axis must be <= rank of the tensor");
21
21
  const o = s, a = { axis: t };
22
- return i.runKernel(k, o, a);
22
+ return k.runKernel(i, o, a);
23
23
  }
24
24
  const l = /* @__PURE__ */ e({ stack_: u });
25
25
  export {
@@ -1,4 +1,4 @@
1
- import { o as e, h as u, x as c, E as l, y as m } from "./index--6vO-cOz.js";
1
+ import { o as e, i as u, y as c, E as i, D as l } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -15,13 +15,13 @@ import { o as e, h as u, x as c, E as l, y as m } from "./index--6vO-cOz.js";
15
15
  * limitations under the License.
16
16
  * =============================================================================
17
17
  */
18
- function i(t, o = null, n = !1) {
18
+ function m(t, o = null, n = !1) {
19
19
  let s = u(t, "x", "sum");
20
20
  s.dtype === "bool" && (s = c(s, "int32"));
21
21
  const r = { x: s }, a = { axis: o, keepDims: n };
22
- return l.runKernel(m, r, a);
22
+ return i.runKernel(l, r, a);
23
23
  }
24
- const x = /* @__PURE__ */ e({ sum_: i });
24
+ const f = /* @__PURE__ */ e({ sum_: m });
25
25
  export {
26
- x as s
26
+ f as s
27
27
  };
@@ -1,4 +1,4 @@
1
- import { J as t, K as a } from "./index--6vO-cOz.js";
1
+ import { I as t, J as a } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -1,4 +1,4 @@
1
- import { I as t, J as s, K as a } from "./index--6vO-cOz.js";
1
+ import { H as t, I as s, J as a } from "./index-iNhkcAEQ.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.