@genai-fi/nanogpt 0.3.2 → 0.4.1

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 (98) hide show
  1. package/dist/Generator.js +22 -22
  2. package/dist/MLP-KHhikThU.js +83 -0
  3. package/dist/NanoGPTModel.d.ts +2 -3
  4. package/dist/NanoGPTModel.js +79 -79
  5. package/dist/TeachableLLM.js +16 -13
  6. package/dist/axis_util-DeydwOoC.js +69 -0
  7. package/dist/{concat-BIZS_td9.js → concat-DS_qH7MI.js} +5 -5
  8. package/dist/config.js +7 -8
  9. package/dist/{gather-BPGW8RsB.js → gather-BUmJIS8n.js} +1 -1
  10. package/dist/{index-pWA4_lUh.js → index-XjBAhiFO.js} +1272 -1174
  11. package/dist/layers/BaseLayer.d.ts +14 -2
  12. package/dist/layers/BaseLayer.js +9 -9
  13. package/dist/layers/CausalSelfAttention.d.ts +4 -8
  14. package/dist/layers/CausalSelfAttention.js +106 -80
  15. package/dist/layers/MLP.d.ts +2 -3
  16. package/dist/layers/MLP.js +5 -62
  17. package/dist/layers/RMSNorm.d.ts +2 -2
  18. package/dist/layers/RMSNorm.js +11 -11
  19. package/dist/layers/RoPECache.js +3 -3
  20. package/dist/layers/TiedEmbedding.js +7 -6
  21. package/dist/layers/TransformerBlock.d.ts +2 -6
  22. package/dist/layers/TransformerBlock.js +9 -12
  23. package/dist/{sum-C7Mgy9Bw.js → log_sum_exp-DJPkVZZn.js} +32 -54
  24. package/dist/main.js +22 -19
  25. package/dist/{mat_mul-D7_a4KJn.js → mat_mul-CKwFEV1Q.js} +1 -1
  26. package/dist/max-DJvEiCAJ.js +25 -0
  27. package/dist/moments-CrWRPcR3.js +53 -0
  28. package/dist/norm-BzY929B_.js +86 -0
  29. package/dist/{ones-Cog-G2ag.js → ones-BO01zpJG.js} +2 -2
  30. package/dist/ops/appendCache.js +1 -1
  31. package/dist/ops/attentionMask.js +1 -1
  32. package/dist/ops/cpu/appendCache.js +2 -2
  33. package/dist/ops/cpu/attentionMask.js +2 -2
  34. package/dist/ops/cpu/fusedSoftmax.d.ts +9 -0
  35. package/dist/ops/cpu/fusedSoftmax.js +23 -0
  36. package/dist/ops/cpu/gatherSub.js +3 -3
  37. package/dist/ops/cpu/mulDropout.d.ts +1 -0
  38. package/dist/ops/cpu/mulDropout.js +17 -0
  39. package/dist/ops/cpu/qkv.js +3 -3
  40. package/dist/ops/cpu/rope.js +5 -5
  41. package/dist/ops/cpu/scatterSub.js +27 -27
  42. package/dist/ops/fusedSoftmax.d.ts +2 -0
  43. package/dist/ops/fusedSoftmax.js +10 -0
  44. package/dist/ops/gatherSub.js +1 -1
  45. package/dist/ops/grads/attentionMask.js +1 -1
  46. package/dist/ops/grads/fusedSoftmax.d.ts +2 -0
  47. package/dist/ops/grads/fusedSoftmax.js +17 -0
  48. package/dist/ops/grads/qkv.js +1 -1
  49. package/dist/ops/grads/rope.js +1 -1
  50. package/dist/ops/mulDrop.d.ts +2 -0
  51. package/dist/ops/mulDrop.js +9 -0
  52. package/dist/ops/node/sparseCrossEntropy.js +1 -1
  53. package/dist/ops/qkv.js +1 -1
  54. package/dist/ops/scatterSub.js +1 -1
  55. package/dist/ops/webgl/appendCache.js +1 -1
  56. package/dist/ops/webgl/attentionMask.js +1 -1
  57. package/dist/ops/webgl/fusedSoftmax.d.ts +11 -0
  58. package/dist/ops/webgl/fusedSoftmax.js +3930 -0
  59. package/dist/ops/webgl/gatherSub.js +1 -1
  60. package/dist/ops/webgl/mulDropout.d.ts +1 -0
  61. package/dist/ops/webgl/mulDropout.js +41 -0
  62. package/dist/ops/webgl/qkv.js +1 -1
  63. package/dist/ops/webgl/rope.js +1 -1
  64. package/dist/ops/webgl/scatterSub.js +1 -1
  65. package/dist/{random_width-oeUIlUZj.js → random_width-CMHmdbSu.js} +4212 -6630
  66. package/dist/{range-CcDl05lo.js → range-DQMNzBWs.js} +1 -1
  67. package/dist/{reshape-C8CR_Bad.js → reshape-DFzh97Sc.js} +1 -1
  68. package/dist/{sin-BJIrfnj7.js → sin-BYM-U4Ut.js} +1 -1
  69. package/dist/slice_util-CnVNPQI-.js +90 -0
  70. package/dist/softmax-4DOn6cPq.js +28 -0
  71. package/dist/{split-DZbvruEP.js → split-CkbeVdF8.js} +3 -3
  72. package/dist/{stack-BMm-efee.js → stack-DaIMO5iX.js} +1 -1
  73. package/dist/sum-C6u3xMi3.js +27 -0
  74. package/dist/{tensor-DJVbYhh1.js → tensor-Cu1fU7H7.js} +1 -1
  75. package/dist/{tensor2d-ZuQSh2D-.js → tensor2d-D0CKdG6B.js} +1 -1
  76. package/dist/tfjs_backend-Bzl2SrRo.js +2460 -0
  77. package/dist/training/AdamExt.js +1 -1
  78. package/dist/training/DatasetBuilder.js +3 -3
  79. package/dist/training/FullTrainer.js +1 -1
  80. package/dist/training/Trainer.js +13 -12
  81. package/dist/training/sparseCrossEntropy.js +12 -11
  82. package/dist/utilities/dummy.js +8 -8
  83. package/dist/utilities/generate.js +11 -11
  84. package/dist/utilities/load.js +1 -1
  85. package/dist/utilities/profile.js +1 -1
  86. package/dist/utilities/weights.js +2 -2
  87. package/dist/{variable-Dl_ub3pk.js → variable-BS4AKqNU.js} +1 -1
  88. package/dist/{zeros-CCy9C3uU.js → zeros-CmJFiC84.js} +1 -1
  89. package/package.json +1 -1
  90. package/dist/exports_layers-tbTBcwMM.js +0 -25
  91. package/dist/layers/LayerNorm.d.ts +0 -13
  92. package/dist/layers/LayerNorm.js +0 -33
  93. package/dist/moments-DfcpfwKi.js +0 -132
  94. package/dist/softmax-Be_lsqUc.js +0 -105
  95. package/dist/training/LayerTrainer.d.ts +0 -29
  96. package/dist/training/LayerTrainer.js +0 -95
  97. package/dist/training/lwSchedule.d.ts +0 -7
  98. package/dist/training/lwSchedule.js +0 -162
@@ -1,4 +1,4 @@
1
- import { E as e, R as f } from "./index-pWA4_lUh.js";
1
+ import { E as e, R as f } from "./index-XjBAhiFO.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-pWA4_lUh.js";
1
+ import { o, h as t, E as a, q as p } from "./index-XjBAhiFO.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1,4 +1,4 @@
1
- import { o, h as t, E as c, K as a, L as e } from "./index-pWA4_lUh.js";
1
+ import { o, h as t, E as c, Q as a, T as e } from "./index-XjBAhiFO.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -0,0 +1,90 @@
1
+ import { o as u, h as p, k as g, w as m, E as w, a1 as x, j as i } from "./index-XjBAhiFO.js";
2
+ import { r as y } from "./reshape-DFzh97Sc.js";
3
+ /**
4
+ * @license
5
+ * Copyright 2020 Google LLC. All Rights Reserved.
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ * =============================================================================
18
+ */
19
+ function T(a, t) {
20
+ let e = p(a, "broadcastTo", "x");
21
+ const r = e.shape;
22
+ if (g(t), t.length < e.rank)
23
+ throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${e.rank}.`);
24
+ if (t.length > e.rank) {
25
+ const l = e.shape.slice();
26
+ for (; l.length < t.length; )
27
+ l.unshift(1);
28
+ e = y(e, l);
29
+ }
30
+ const n = e.shape, o = Array.from(t);
31
+ for (let l = t.length - 1; l >= 0; l--)
32
+ if (n[l] === t[l])
33
+ o[l] = 1;
34
+ else if (e.shape[l] !== 1)
35
+ throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);
36
+ if (o.map((l, h) => l > 1 ? h : -1).filter((l) => l >= 0).length === 0)
37
+ return m(e);
38
+ const f = { x: e }, c = { reps: o };
39
+ return w.runKernel(x, f, c);
40
+ }
41
+ const A = /* @__PURE__ */ u({ broadcastTo_: T });
42
+ /**
43
+ * @license
44
+ * Copyright 2021 Google LLC. All Rights Reserved.
45
+ * Licensed under the Apache License, Version 2.0 (the "License");
46
+ * you may not use this file except in compliance with the License.
47
+ * You may obtain a copy of the License at
48
+ *
49
+ * http://www.apache.org/licenses/LICENSE-2.0
50
+ *
51
+ * Unless required by applicable law or agreed to in writing, software
52
+ * distributed under the License is distributed on an "AS IS" BASIS,
53
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
54
+ * See the License for the specific language governing permissions and
55
+ * limitations under the License.
56
+ * =============================================================================
57
+ */
58
+ function b(a, t, e) {
59
+ let r = e.length;
60
+ for (let n = 0; n < e.length; n++)
61
+ if (e[n] > 1) {
62
+ r = n;
63
+ break;
64
+ }
65
+ for (let n = r + 1; n < e.length; n++)
66
+ if (t[n] > 0 || e[n] !== a[n])
67
+ return !1;
68
+ return !0;
69
+ }
70
+ function E(a, t) {
71
+ let e = a.length > 0 ? a[a.length - 1] : 1;
72
+ for (let r = 0; r < a.length - 1; r++)
73
+ e += a[r] * t[r];
74
+ return e;
75
+ }
76
+ function N(a, t, e) {
77
+ let r;
78
+ const n = a.shape.length;
79
+ typeof t == "number" ? r = [t, ...new Array(n - 1).fill(0)] : t.length < n ? r = t.concat(new Array(n - t.length).fill(0)) : r = t.slice(), r.forEach((s) => {
80
+ i(s !== -1, () => "slice() does not support negative begin indexing.");
81
+ });
82
+ let o;
83
+ return e == null ? o = new Array(n).fill(-1) : typeof e == "number" ? o = [e, ...new Array(n - 1).fill(-1)] : e.length < n ? o = e.concat(new Array(n - e.length).fill(-1)) : o = e, o = o.map((s, f) => s >= 0 ? s : (i(s === -1, () => `Negative size values should be exactly -1 but got ${s} for the slice() size at index ${f}.`), a.shape[f] - r[f])), [r, o];
84
+ }
85
+ export {
86
+ A as b,
87
+ E as c,
88
+ b as i,
89
+ N as p
90
+ };
@@ -0,0 +1,28 @@
1
+ import { o as r, h as f, E as e, S as i } from "./index-XjBAhiFO.js";
2
+ /**
3
+ * @license
4
+ * Copyright 2018 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 l(s, o = -1) {
19
+ const t = f(s, "logits", "softmax", "float32");
20
+ if (o === -1 && (o = t.rank - 1), o !== t.rank - 1)
21
+ throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${o}`);
22
+ const n = { logits: t }, a = { dim: o };
23
+ return e.runKernel(i, n, a);
24
+ }
25
+ const p = /* @__PURE__ */ r({ softmax_: l });
26
+ export {
27
+ p as s
28
+ };
@@ -1,4 +1,4 @@
1
- import { o as p, h as i, E as a, S as c } from "./index-pWA4_lUh.js";
1
+ import { o as p, h as i, E as a, u as c } from "./index-XjBAhiFO.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -19,7 +19,7 @@ function e(t, s, o = 0) {
19
19
  const n = { x: i(t, "x", "split") }, r = { numOrSizeSplits: s, axis: o };
20
20
  return a.runKernel(c, n, r);
21
21
  }
22
- const u = /* @__PURE__ */ p({ split_: e });
22
+ const x = /* @__PURE__ */ p({ split_: e });
23
23
  export {
24
- u as s
24
+ x 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-pWA4_lUh.js";
1
+ import { o as e, i as c, j as n, E as i, P as k } from "./index-XjBAhiFO.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -0,0 +1,27 @@
1
+ import { o as e, h as u, x as c, E as l, y as m } from "./index-XjBAhiFO.js";
2
+ /**
3
+ * @license
4
+ * Copyright 2018 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 i(t, o = null, n = !1) {
19
+ let s = u(t, "x", "sum");
20
+ s.dtype === "bool" && (s = c(s, "int32"));
21
+ const r = { x: s }, a = { axis: o, keepDims: n };
22
+ return l.runKernel(m, r, a);
23
+ }
24
+ const x = /* @__PURE__ */ e({ sum_: i });
25
+ export {
26
+ x as s
27
+ };
@@ -1,4 +1,4 @@
1
- import { D as t, F as a } from "./index-pWA4_lUh.js";
1
+ import { J as t, K as a } from "./index-XjBAhiFO.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -1,4 +1,4 @@
1
- import { y as t, D as s, F as a } from "./index-pWA4_lUh.js";
1
+ import { I as t, J as s, K as a } from "./index-XjBAhiFO.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.