@genai-fi/nanogpt 0.10.2 → 0.11.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/dist/Generator.d.ts +10 -5
- package/dist/Generator.js +11760 -146
- package/dist/{RealDiv-zz7FpkKX.js → RealDiv-Ds-jvL09.js} +28 -30
- package/dist/Reshape-Cd6e-Otn.js +14 -0
- package/dist/{Reshape-CHdUjC72.js → Reshape-Ct266DEk.js} +21 -23
- package/dist/TeachableLLM.d.ts +4 -3
- package/dist/TeachableLLM.js +15 -16
- package/dist/Trainer.d.ts +2 -2
- package/dist/Trainer.js +6 -6
- package/dist/{axis_util-BsIr9ZNu.js → axis_util-DofAuy0p.js} +1 -1
- package/dist/backend.js +2 -2
- package/dist/{backend_util-B1XRLuq9.js → backend_util-C7NWHpv7.js} +72 -73
- package/dist/{backend_webgpu-CqpfEImu.js → backend_webgpu-B0Vls736.js} +52 -54
- package/dist/broadcast_to-DDaNMbX7.js +28 -0
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +3 -3
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/matMulGelu.js +7 -11
- package/dist/checks/normRMS.js +9 -9
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.js +2 -2
- package/dist/checks/qkv.js +11 -12
- package/dist/checks/rope.js +2 -2
- package/dist/clip_by_value-Dn5tzexi.js +12 -0
- package/dist/complex-DClmWqJt.js +11 -0
- package/dist/concat-C6X3AAlQ.js +17 -0
- package/dist/{concat_util-iBYIyuQe.js → concat_util-CHsJFZJJ.js} +1 -1
- package/dist/{dataset-D2P7rHAw.js → dataset-DcjWqUVQ.js} +135 -137
- package/dist/dropout-OxuaJz6z.js +92 -0
- package/dist/expand_dims-BzfJK2uc.js +11 -0
- package/dist/{exports_initializers-CZSUJoVE.js → exports_initializers-eS9QJ6ut.js} +1 -1
- package/dist/floor-DIb-lN_u.js +9 -0
- package/dist/gather-BcO5UQNJ.js +9 -0
- package/dist/{gelu-Bmhopi0J.js → gelu-DqTbCx5x.js} +10 -11
- package/dist/{gpgpu_math-DsCcikas.js → gpgpu_math-CJcbnKPC.js} +841 -1015
- package/dist/index-D0RBWjq8.js +3520 -0
- package/dist/{index-DRyE072i.js → index-Dj5TkmPY.js} +330 -331
- package/dist/{kernel_funcs_utils-CWfOAPGO.js → kernel_funcs_utils-CSaumNDs.js} +132 -134
- package/dist/layers/BaseLayer.js +15 -16
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +4 -4
- package/dist/layers/PositionEmbedding.js +7 -7
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +9 -9
- package/dist/layers/TiedEmbedding.js +6 -6
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +21 -22
- package/dist/log_sum_exp-VLZgbFAH.js +39 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.js +49 -50
- package/dist/{matMul16-fEAJ4smh.js → matMul16-cDxwemKj.js} +14 -15
- package/dist/matMulGelu-B2s_80-H.js +163 -0
- package/dist/mat_mul-DxpNTCRz.js +11 -0
- package/dist/mod-PrOKlFxH.js +11 -0
- package/dist/models/NanoGPTV1.js +2 -2
- package/dist/models/model.js +13 -14
- package/dist/ones-BX_wEgzB.js +14 -0
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/add16.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/concat16.js +2 -2
- package/dist/ops/cpu/adamAdjust.js +12 -13
- package/dist/ops/cpu/adamMoments.js +6 -7
- package/dist/ops/cpu/appendCache.js +7 -8
- package/dist/ops/cpu/attentionMask.js +11 -11
- package/dist/ops/cpu/fusedSoftmax.js +10 -11
- package/dist/ops/cpu/gatherSub.js +10 -11
- package/dist/ops/cpu/gelu.js +14 -15
- package/dist/ops/cpu/matMul16.js +6 -7
- package/dist/ops/cpu/matMulGelu.js +5 -6
- package/dist/ops/cpu/matMulMul.js +3 -4
- package/dist/ops/cpu/mulDropout.js +3 -4
- package/dist/ops/cpu/normRMS.js +11 -12
- package/dist/ops/cpu/qkv.js +8 -9
- package/dist/ops/cpu/rope.js +9 -10
- package/dist/ops/cpu/scatterSub.js +14 -16
- package/dist/ops/dot16.js +2 -2
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/add16.js +10 -11
- package/dist/ops/grads/attentionMask.js +5 -6
- package/dist/ops/grads/gelu.js +3 -4
- package/dist/ops/grads/matMul16.js +4 -5
- package/dist/ops/grads/matMulGelu.js +8 -9
- package/dist/ops/grads/normRMS.js +9 -10
- package/dist/ops/grads/pack16.js +4 -5
- package/dist/ops/grads/qkv.js +17 -19
- package/dist/ops/grads/rope.js +3 -5
- package/dist/ops/grads/softmax16.js +3 -4
- package/dist/ops/grads/unpack16.js +3 -4
- package/dist/ops/grads/utils.d.ts +1 -0
- package/dist/ops/grads/utils.js +8 -4
- package/dist/ops/matMul16.js +3 -3
- package/dist/ops/matMulGelu.js +2 -2
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mul16.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/pack16.js +3 -4
- package/dist/ops/qkv.js +4 -8
- package/dist/ops/reshape16.js +16 -18
- package/dist/ops/rope.d.ts +1 -1
- package/dist/ops/rope.js +3 -8
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.js +2 -2
- package/dist/ops/softmax16.js +5 -8
- package/dist/ops/sub16.js +1 -1
- package/dist/ops/sum16.js +2 -2
- package/dist/ops/transpose16.js +23 -24
- package/dist/ops/unpack16.js +2 -2
- package/dist/ops/webgl/adamAdjust.js +2 -3
- package/dist/ops/webgl/adamMoments.js +1 -2
- package/dist/ops/webgl/appendCache.js +1 -2
- package/dist/ops/webgl/attentionMask.js +5 -6
- package/dist/ops/webgl/fusedSoftmax.js +6 -8
- package/dist/ops/webgl/gatherSub.js +6 -7
- package/dist/ops/webgl/gelu.js +2 -3
- package/dist/ops/webgl/log.js +11 -12
- package/dist/ops/webgl/matMul16.js +15 -16
- package/dist/ops/webgl/matMulGelu.js +7 -111
- package/dist/ops/webgl/matMulMul.js +14 -15
- package/dist/ops/webgl/mulDropout.js +8 -9
- package/dist/ops/webgl/normRMS.js +7 -8
- package/dist/ops/webgl/qkv.js +5 -6
- package/dist/ops/webgl/rope.js +7 -8
- package/dist/ops/webgl/scatterSub.js +5 -6
- package/dist/ops/webgpu/adamAdjust.js +10 -12
- package/dist/ops/webgpu/adamMoments.js +8 -10
- package/dist/ops/webgpu/add16.js +8 -9
- package/dist/ops/webgpu/appendCache.js +23 -25
- package/dist/ops/webgpu/attentionMask.js +10 -12
- package/dist/ops/webgpu/attentionMask32_program.js +2 -2
- package/dist/ops/webgpu/concat16.js +12 -14
- package/dist/ops/webgpu/gatherSub.js +9 -11
- package/dist/ops/webgpu/gelu.js +28 -29
- package/dist/ops/webgpu/matMul16.js +26 -28
- package/dist/ops/webgpu/matMul16_program.js +4 -5
- package/dist/ops/webgpu/mul16.js +7 -8
- package/dist/ops/webgpu/normRMS.js +17 -19
- package/dist/ops/webgpu/normRMSGrad.js +21 -28
- package/dist/ops/webgpu/pack16.js +12 -13
- package/dist/ops/webgpu/pack16_program.js +2 -2
- package/dist/ops/webgpu/qkv.js +13 -15
- package/dist/ops/webgpu/rope.js +25 -27
- package/dist/ops/webgpu/scatterSub.js +7 -9
- package/dist/ops/webgpu/slice16.js +21 -23
- package/dist/ops/webgpu/softmax16.js +17 -19
- package/dist/ops/webgpu/softmax16_program.js +2 -2
- package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
- package/dist/ops/webgpu/softmax16grad.js +7 -8
- package/dist/ops/webgpu/sub16.js +8 -9
- package/dist/ops/webgpu/sum16.js +19 -21
- package/dist/ops/webgpu/transpose16.js +19 -20
- package/dist/ops/webgpu/transpose16_program.js +2 -2
- package/dist/ops/webgpu/transpose16_shared_program.js +11 -12
- package/dist/ops/webgpu/unpack16.js +3 -4
- package/dist/ops/webgpu/utils/binary_op.js +7 -8
- package/dist/ops/webgpu/utils/reductions.js +14 -22
- package/dist/ops-FJapAPfm.js +476 -0
- package/dist/pack16-k4jq6aMX.js +39 -0
- package/dist/patches/webgpu_backend.js +19 -20
- package/dist/patches/webgpu_base.js +1 -1
- package/dist/patches/webgpu_program.js +15 -16
- package/dist/{random_width-BVV9HveY.js → random_width-UGQn4OWb.js} +2506 -2761
- package/dist/range-CuGvVN2c.js +10 -0
- package/dist/relu-Cf80uA2p.js +9 -0
- package/dist/reshape-CkjKPPqB.js +9 -0
- package/dist/resize_nearest_neighbor-DB8k9KN_.js +175 -0
- package/dist/rope-BmZmp9uP.js +24 -0
- package/dist/{scatter_nd_util-C7zXRT_h.js → scatter_nd_util-BY22Cc-C.js} +1 -1
- package/dist/selu_util-BuLbmbrl.js +44 -0
- package/dist/{shared-CHhxz-O5.js → shared-B7USJZgw.js} +1 -1
- package/dist/{shared-D2NP_CpY.js → shared-BQboIImQ.js} +379 -381
- package/dist/slice-Aqy7KbJh.js +12 -0
- package/dist/{slice_util-DyjSAD0u.js → slice_util-D8CQRenR.js} +7 -7
- package/dist/{softmax-C9JQEtnO.js → softmax-faLoUZVT.js} +4 -5
- package/dist/split-BNz5jcGc.js +9 -0
- package/dist/squeeze--YMgaAAf.js +10 -0
- package/dist/stack-WJK22CFn.js +11 -0
- package/dist/step-dXR33iOg.js +261 -0
- package/dist/sum-BdplSvq_.js +11 -0
- package/dist/{tensor-0r5yOo2R.js → tensor-BQqrDvpx.js} +1 -1
- package/dist/tensor1d-LxP9asMm.js +11 -0
- package/dist/{tensor2d-CSB4KOb0.js → tensor2d-BN1sSfQO.js} +6 -7
- package/dist/{tensor4d-D7bLqGqz.js → tensor4d-DVwr7pLF.js} +6 -7
- package/dist/{tfjs_backend-CNkSTL0c.js → tfjs_backend-Vi4JfLzT.js} +256 -265
- package/dist/tile-CvN_LyVr.js +11 -0
- package/dist/tokeniser/BaseTokeniser.d.ts +27 -0
- package/dist/tokeniser/BaseTokeniser.js +94 -0
- package/dist/tokeniser/CharTokeniser.d.ts +4 -3
- package/dist/tokeniser/CharTokeniser.js +46 -32
- package/dist/tokeniser/bpe.d.ts +4 -3
- package/dist/tokeniser/bpe.js +60 -45
- package/dist/tokeniser/type.d.ts +11 -0
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.d.ts +2 -2
- package/dist/training/DatasetBuilder.js +32 -36
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.d.ts +3 -3
- package/dist/training/Trainer.js +2 -2
- package/dist/training/sparseCrossEntropy.js +5 -5
- package/dist/transpose-JawVKyZy.js +36 -0
- package/dist/unsorted_segment_sum-LAbmE9G4.js +277 -0
- package/dist/utilities/dummy.js +3 -3
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.d.ts +1 -4
- package/dist/utilities/packed.js +10 -745
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/sentences.js +5 -5
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-DzfrwYuP.js → variable-DQ9yYgEU.js} +1 -1
- package/dist/{webgpu_program-DzaQiqel.js → webgpu_program-CAE4RICo.js} +177 -171
- package/dist/{webgpu_util-0_ubCEHJ.js → webgpu_util-BdovYhXr.js} +34 -35
- package/dist/zeros-DeiE2zTa.js +13 -0
- package/dist/zeros_like-BAz3iKru.js +721 -0
- package/package.json +4 -2
- package/dist/Reshape-CDVLyVfz.js +0 -16
- package/dist/broadcast_to-B0ChcDaz.js +0 -30
- package/dist/complex-BBiRlsVq.js +0 -13
- package/dist/concat-DmBLPVGC.js +0 -19
- package/dist/dropout-B1x1kYMa.js +0 -99
- package/dist/expand_dims-ouvfxQ1n.js +0 -13
- package/dist/gather-CH9sdacz.js +0 -10
- package/dist/index-D6Q1lPZO.js +0 -2157
- package/dist/log_sum_exp-D3ftBNY5.js +0 -41
- package/dist/mat_mul-C59XWcJd.js +0 -12
- package/dist/mod-DESSvHIU.js +0 -12
- package/dist/mulmat_packed_gpu-Coh6qbJk.js +0 -55
- package/dist/ones-jU9jlQvM.js +0 -15
- package/dist/ops-BFDtP6th.js +0 -645
- package/dist/pack16-CmVZs6af.js +0 -41
- package/dist/patches/PackedTensor.d.ts +0 -12
- package/dist/patches/PackedTensor.js +0 -11
- package/dist/patches/engine.d.ts +0 -261
- package/dist/patches/engine.js +0 -12
- package/dist/patches/tape.d.ts +0 -12
- package/dist/patches/tape.js +0 -5
- package/dist/range-ZZZD60Fx.js +0 -11
- package/dist/reciprocal-CrYlsAGD.js +0 -10
- package/dist/register_all_kernels-nvj2k7OC.js +0 -12307
- package/dist/relu-BYDneVPn.js +0 -10
- package/dist/reshape-CaPQzFvz.js +0 -10
- package/dist/rope-s4W2XO9B.js +0 -32
- package/dist/selu_util-BGPXmd4B.js +0 -303
- package/dist/sin-Djs4aQiu.js +0 -16
- package/dist/slice-DvovR5wq.js +0 -13
- package/dist/split-DBck65sX.js +0 -10
- package/dist/squeeze-C00Ipm_7.js +0 -11
- package/dist/stack-ChnHwRpX.js +0 -13
- package/dist/sum-ywRJj3Zr.js +0 -12
- package/dist/tensor-CzmOBsdf.js +0 -909
- package/dist/tensor1d-BlUT89BP.js +0 -12
- package/dist/tensor_util-DfwaWayG.js +0 -523
- package/dist/tile-CR074jmp.js +0 -13
- package/dist/transpose-DH4gmHvu.js +0 -38
- package/dist/zeros-DBFVbpv5.js +0 -14
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { r as $ } from "./Reshape-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { f as y } from "./gpgpu_math-DsCcikas.js";
|
|
9
|
-
import { g as j, b as L } from "./kernel_funcs_utils-CWfOAPGO.js";
|
|
1
|
+
import { aG as T, ab as E, af as O, V, aS as B, Q as F, am as G, aT as K } from "./index-D0RBWjq8.js";
|
|
2
|
+
import { r as $ } from "./Reshape-Ct266DEk.js";
|
|
3
|
+
import { a as A, b as k, d as C, c as N, e as R } from "./axis_util-DofAuy0p.js";
|
|
4
|
+
import { t as U, m as W } from "./shared-B7USJZgw.js";
|
|
5
|
+
import { c as _ } from "./backend_util-C7NWHpv7.js";
|
|
6
|
+
import { f as y } from "./gpgpu_math-CJcbnKPC.js";
|
|
7
|
+
import { g as j, b as L } from "./kernel_funcs_utils-CSaumNDs.js";
|
|
10
8
|
class w {
|
|
11
9
|
constructor(s, e) {
|
|
12
10
|
this.variableNames = ["x"];
|
|
@@ -16,7 +14,7 @@ class w {
|
|
|
16
14
|
let o = "sumValue += dot(values, ones);";
|
|
17
15
|
if (e != null) {
|
|
18
16
|
const p = 1 / e;
|
|
19
|
-
o = `sumValue += dot(values * ${
|
|
17
|
+
o = `sumValue += dot(values * ${T(p) ? p.toPrecision(2) : p}, ones);`;
|
|
20
18
|
}
|
|
21
19
|
let u = "";
|
|
22
20
|
l % t > 0 && (u = `
|
|
@@ -186,7 +184,7 @@ class X {
|
|
|
186
184
|
function q(a) {
|
|
187
185
|
const s = [];
|
|
188
186
|
for (; s.length === 0 || s[s.length - 1].outSize !== 1; ) {
|
|
189
|
-
const e = s.length ? s[s.length - 1].outSize : a[1], t =
|
|
187
|
+
const e = s.length ? s[s.length - 1].outSize : a[1], t = _(e);
|
|
190
188
|
s.push({
|
|
191
189
|
inSize: e,
|
|
192
190
|
windowSize: t,
|
|
@@ -205,14 +203,14 @@ function P(a, s, e, t) {
|
|
|
205
203
|
}
|
|
206
204
|
return l;
|
|
207
205
|
}
|
|
208
|
-
class
|
|
206
|
+
class Q {
|
|
209
207
|
constructor(s, e) {
|
|
210
208
|
this.variableNames = ["A"];
|
|
211
209
|
const t = new Array(s.length);
|
|
212
210
|
for (let r = 0; r < t.length; r++)
|
|
213
211
|
t[r] = s[e[r]];
|
|
214
212
|
this.outputShape = t, this.rank = t.length;
|
|
215
|
-
const n = y(this.rank), l =
|
|
213
|
+
const n = y(this.rank), l = Y(e);
|
|
216
214
|
this.userCode = `
|
|
217
215
|
void main() {
|
|
218
216
|
${n} resRC = getOutputCoords();
|
|
@@ -221,7 +219,7 @@ class Y {
|
|
|
221
219
|
`;
|
|
222
220
|
}
|
|
223
221
|
}
|
|
224
|
-
function
|
|
222
|
+
function Y(a) {
|
|
225
223
|
const s = a.length;
|
|
226
224
|
if (s > 6)
|
|
227
225
|
throw Error(`Transpose for rank ${s} is not yet supported`);
|
|
@@ -230,7 +228,7 @@ function H(a) {
|
|
|
230
228
|
t[a[n]] = e[n];
|
|
231
229
|
return t.join();
|
|
232
230
|
}
|
|
233
|
-
class
|
|
231
|
+
class H {
|
|
234
232
|
constructor(s, e) {
|
|
235
233
|
this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0;
|
|
236
234
|
const t = new Array(s.length);
|
|
@@ -263,10 +261,10 @@ class J {
|
|
|
263
261
|
}
|
|
264
262
|
}
|
|
265
263
|
function D(a, s, e) {
|
|
266
|
-
const t =
|
|
264
|
+
const t = E().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new H(a.shape, s) : new Q(a.shape, s);
|
|
267
265
|
return e.runWebGLProgram(t, [a], a.dtype);
|
|
268
266
|
}
|
|
269
|
-
function
|
|
267
|
+
function J(a, s, e, t) {
|
|
270
268
|
const n = s, l = a.shape.length, r = O(n, a.shape);
|
|
271
269
|
let i = r;
|
|
272
270
|
const c = A(i, l), o = c != null;
|
|
@@ -275,15 +273,15 @@ function Q(a, s, e, t) {
|
|
|
275
273
|
const [p, h] = N(u.shape, i);
|
|
276
274
|
let d = p;
|
|
277
275
|
e && (d = R(p, r));
|
|
278
|
-
const f = V(h), g = V(a.shape) / f, x = $({ inputs: { x: u }, attrs: { shape: [g, f] }, backend: t }), b =
|
|
276
|
+
const f = V(h), g = V(a.shape) / f, x = $({ inputs: { x: u }, attrs: { shape: [g, f] }, backend: t }), b = B(a.dtype), I = P(x, b, "sum", t), m = $({ inputs: { x: I }, attrs: { shape: d }, backend: t });
|
|
279
277
|
return t.disposeIntermediateTensorInfo(x), t.disposeIntermediateTensorInfo(I), o && t.disposeIntermediateTensorInfo(u), m;
|
|
280
278
|
}
|
|
281
279
|
function Z(a) {
|
|
282
280
|
const { inputs: s, backend: e, attrs: t } = a, { x: n } = s, { axis: l, keepDims: r } = t;
|
|
283
|
-
return
|
|
281
|
+
return J(n, l, r, e);
|
|
284
282
|
}
|
|
285
|
-
const
|
|
286
|
-
kernelName:
|
|
283
|
+
const pe = {
|
|
284
|
+
kernelName: F,
|
|
287
285
|
backendName: "webgl",
|
|
288
286
|
kernelFunc: Z
|
|
289
287
|
};
|
|
@@ -301,7 +299,7 @@ function te(a) {
|
|
|
301
299
|
const I = e.texData.get(d.dataId).values, m = new Array(i);
|
|
302
300
|
for (let v = 0; v < m.length; v++)
|
|
303
301
|
m[v] = n.shape[u[v]];
|
|
304
|
-
const z =
|
|
302
|
+
const z = U(I, n.shape, n.dtype, u, m);
|
|
305
303
|
d = e.makeTensorInfo(m, n.dtype);
|
|
306
304
|
const M = e.texData.get(d.dataId);
|
|
307
305
|
M.values = z;
|
|
@@ -315,7 +313,7 @@ function te(a) {
|
|
|
315
313
|
r && (g = R(f, c));
|
|
316
314
|
let x;
|
|
317
315
|
if (h) {
|
|
318
|
-
const I = e.texData.get(d.dataId).values, m =
|
|
316
|
+
const I = e.texData.get(d.dataId).values, m = W(I, V(S), g, n.dtype);
|
|
319
317
|
x = e.makeTensorInfo(g, n.dtype);
|
|
320
318
|
const z = e.texData.get(x.dataId);
|
|
321
319
|
z.values = m;
|
|
@@ -323,8 +321,8 @@ function te(a) {
|
|
|
323
321
|
x = ee(d, S, g, e);
|
|
324
322
|
return p && e.disposeIntermediateTensorInfo(d), x;
|
|
325
323
|
}
|
|
326
|
-
const
|
|
327
|
-
kernelName:
|
|
324
|
+
const he = {
|
|
325
|
+
kernelName: G,
|
|
328
326
|
backendName: "webgl",
|
|
329
327
|
kernelFunc: te
|
|
330
328
|
};
|
|
@@ -350,16 +348,16 @@ return a / b;`, se = `
|
|
|
350
348
|
}
|
|
351
349
|
|
|
352
350
|
return result;
|
|
353
|
-
`, ne = L({ opSnippet: ae, packedOpSnippet: se, checkOutOfBounds: !0 }),
|
|
354
|
-
kernelName:
|
|
351
|
+
`, ne = L({ opSnippet: ae, packedOpSnippet: se, checkOutOfBounds: !0 }), fe = {
|
|
352
|
+
kernelName: K,
|
|
355
353
|
backendName: "webgl",
|
|
356
354
|
kernelFunc: ne
|
|
357
355
|
};
|
|
358
356
|
export {
|
|
359
357
|
P as a,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
358
|
+
he as b,
|
|
359
|
+
fe as c,
|
|
360
|
+
pe as d,
|
|
363
361
|
te as m,
|
|
364
362
|
ne as r,
|
|
365
363
|
Z as s,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { V as h, ah as d, y as c, R as m } from "./index-D0RBWjq8.js";
|
|
2
|
+
function i(n) {
|
|
3
|
+
const { inputs: p, attrs: o } = n, { x: e } = p, { shape: r } = o, a = h(e.shape), s = d(r, a), t = h(s);
|
|
4
|
+
return c(a === t, () => `The new shape (${s}) has ${t} elements and the old shape (${e.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`), n.backend.incRef(e.dataId), { dataId: e.dataId, shape: s, dtype: e.dtype };
|
|
5
|
+
}
|
|
6
|
+
const u = {
|
|
7
|
+
kernelName: m,
|
|
8
|
+
backendName: "webgpu",
|
|
9
|
+
kernelFunc: i
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
u as a,
|
|
13
|
+
i as r
|
|
14
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { u as
|
|
3
|
-
import { b as x } from "./tensor_util-DfwaWayG.js";
|
|
4
|
-
import { s as l, n as F, a as $ } from "./tensor-CzmOBsdf.js";
|
|
1
|
+
import { R as C, V as c, ah as R, y as f } from "./index-D0RBWjq8.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-CJcbnKPC.js";
|
|
5
3
|
class S {
|
|
6
4
|
constructor(t, i) {
|
|
7
|
-
this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = t, this.enableShapeUniforms =
|
|
5
|
+
this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = t, this.enableShapeUniforms = g(this.outputShape.length);
|
|
8
6
|
let a = "";
|
|
9
7
|
for (let e = 0; e < 4; e++) {
|
|
10
8
|
let o = "thisRC = rc;";
|
|
@@ -22,8 +20,8 @@ class S {
|
|
|
22
20
|
`;
|
|
23
21
|
}
|
|
24
22
|
this.userCode = `
|
|
25
|
-
${
|
|
26
|
-
${this.enableShapeUniforms ?
|
|
23
|
+
${v(i, this.enableShapeUniforms)}
|
|
24
|
+
${this.enableShapeUniforms ? I() : x(t)}
|
|
27
25
|
|
|
28
26
|
void main() {
|
|
29
27
|
ivec3 rc = getOutputCoords();
|
|
@@ -41,41 +39,41 @@ class S {
|
|
|
41
39
|
`;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
function
|
|
42
|
+
function v(s, t) {
|
|
45
43
|
return `
|
|
46
44
|
ivec3 inputCoordsFromReshapedOutCoords(int index) {
|
|
47
|
-
${t ?
|
|
45
|
+
${t ? F(["r", "c", "d"], "inputShape") : $(["r", "c", "d"], s)}
|
|
48
46
|
return ivec3(r, c, d);
|
|
49
47
|
}
|
|
50
48
|
`;
|
|
51
49
|
}
|
|
52
|
-
function
|
|
50
|
+
function y(s, t, i) {
|
|
53
51
|
const a = [
|
|
54
|
-
|
|
55
|
-
...
|
|
52
|
+
u(s.shape),
|
|
53
|
+
...m(s.shape)
|
|
56
54
|
], e = {
|
|
57
55
|
dtype: s.dtype,
|
|
58
56
|
shape: a,
|
|
59
57
|
dataId: s.dataId
|
|
60
58
|
}, o = [
|
|
61
|
-
|
|
62
|
-
...
|
|
59
|
+
u(t),
|
|
60
|
+
...m(t)
|
|
63
61
|
], r = new S(o, a), p = !0, n = [a], h = i.runWebGLProgram(r, [e], s.dtype, n, p);
|
|
64
62
|
return { dataId: h.dataId, shape: t, dtype: h.dtype };
|
|
65
63
|
}
|
|
66
|
-
function
|
|
67
|
-
const { inputs: t, backend: i, attrs: a } = s, { x: e } = t, { shape: o } = a, r = i, p =
|
|
68
|
-
|
|
64
|
+
function b(s) {
|
|
65
|
+
const { inputs: t, backend: i, attrs: a } = s, { x: e } = t, { shape: o } = a, r = i, p = c(e.shape), n = R(o, p), h = c(n);
|
|
66
|
+
f(p === h, () => `The new shape (${n}) has ${h} elements and the old shape (${e.shape}) has ${p} elements. The new shape and old shape must have the same number of elements.`);
|
|
69
67
|
const d = r.texData.get(e.dataId);
|
|
70
|
-
return d.isPacked && !
|
|
68
|
+
return d.isPacked && !l(e.shape, n) && !(d.texture !== null && l(d.shape, n)) ? y(e, n, r) : (r.incRef(e.dataId), { dataId: e.dataId, shape: n, dtype: e.dtype });
|
|
71
69
|
}
|
|
72
|
-
const
|
|
73
|
-
kernelName:
|
|
70
|
+
const U = {
|
|
71
|
+
kernelName: C,
|
|
74
72
|
backendName: "webgl",
|
|
75
|
-
kernelFunc:
|
|
73
|
+
kernelFunc: b
|
|
76
74
|
};
|
|
77
75
|
export {
|
|
78
76
|
S as R,
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
U as a,
|
|
78
|
+
b as r
|
|
81
79
|
};
|
package/dist/TeachableLLM.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GPTConfig } from './models/config';
|
|
2
|
-
import { ITokeniser } from './tokeniser/type';
|
|
2
|
+
import { Conversation, ITokeniser } from './tokeniser/type';
|
|
3
3
|
import { SaveOptions } from './loader/save';
|
|
4
4
|
import { default as Generator, IGenerateOptions } from './Generator';
|
|
5
5
|
import { default as Trainer, ITrainerOptions } from './Trainer';
|
|
@@ -41,10 +41,11 @@ export default class TeachableLLM {
|
|
|
41
41
|
set enableProfiler(value: boolean);
|
|
42
42
|
getNumParams(): number;
|
|
43
43
|
trainer(): Trainer;
|
|
44
|
-
train(text:
|
|
44
|
+
train(text: Conversation[][], options?: ITrainerOptions): Promise<void>;
|
|
45
45
|
trainTokeniser(text: string[]): Promise<number>;
|
|
46
46
|
generator(): Generator;
|
|
47
|
-
generateText(prompt
|
|
47
|
+
generateText(prompt: Conversation[], options?: IGenerateOptions): Promise<Conversation[]>;
|
|
48
|
+
generateText(options?: IGenerateOptions): Promise<Conversation[]>;
|
|
48
49
|
dispose(): void;
|
|
49
50
|
on(event: 'status', listener: (status: TeachableLLMStatus) => void): void;
|
|
50
51
|
on(event: 'error', listener: (error: Error) => void): void;
|
package/dist/TeachableLLM.js
CHANGED
|
@@ -2,28 +2,27 @@ import { defaultConfig as d } from "./models/config.js";
|
|
|
2
2
|
import { saveModel as l } from "./loader/save.js";
|
|
3
3
|
import { loadModel as _ } from "./loader/load.js";
|
|
4
4
|
import u from "./Generator.js";
|
|
5
|
-
import
|
|
6
|
-
import { E as
|
|
5
|
+
import f from "./Trainer.js";
|
|
6
|
+
import { E as p } from "./index-DvYrXKkX.js";
|
|
7
7
|
import { dummyPassTrainAsync as m } from "./utilities/dummy.js";
|
|
8
|
-
import "./
|
|
9
|
-
import "./
|
|
8
|
+
import "./index-D0RBWjq8.js";
|
|
9
|
+
import "./random_width-UGQn4OWb.js";
|
|
10
|
+
import "./zeros_like-BAz3iKru.js";
|
|
11
|
+
import "./index-Cp39cXWe.js";
|
|
12
|
+
import "./dataset-DcjWqUVQ.js";
|
|
10
13
|
import "./ops/cpu/attentionMask.js";
|
|
11
14
|
import "./ops/webgl/attentionMask.js";
|
|
12
15
|
import "./ops/grads/attentionMask.js";
|
|
13
|
-
import "./random_width-BVV9HveY.js";
|
|
14
|
-
import "./register_all_kernels-nvj2k7OC.js";
|
|
15
|
-
import "./index-Cp39cXWe.js";
|
|
16
|
-
import "./dataset-D2P7rHAw.js";
|
|
17
16
|
import "./ops/cpu/rope.js";
|
|
18
17
|
import "./ops/webgl/rope.js";
|
|
19
|
-
import "./rope-
|
|
18
|
+
import "./rope-BmZmp9uP.js";
|
|
20
19
|
import "./ops/cpu/appendCache.js";
|
|
21
20
|
import "./ops/webgl/appendCache.js";
|
|
22
21
|
import "./ops/grads/softmax16.js";
|
|
23
|
-
import "./matMul16-
|
|
22
|
+
import "./matMul16-cDxwemKj.js";
|
|
24
23
|
import "./ops/webgl/matMul16.js";
|
|
25
24
|
import "./ops/cpu/matMul16.js";
|
|
26
|
-
import "./pack16-
|
|
25
|
+
import "./pack16-k4jq6aMX.js";
|
|
27
26
|
import "./ops/transpose16.js";
|
|
28
27
|
import "./ops/reshape16.js";
|
|
29
28
|
import "./ops/cpu/qkv.js";
|
|
@@ -42,11 +41,11 @@ import g from "./tokeniser/bpe.js";
|
|
|
42
41
|
import "./papaparse.min-C0cScC2i.js";
|
|
43
42
|
import "./jszip.min-Bz5-11Bk.js";
|
|
44
43
|
import "./ops/cpu/matMulGelu.js";
|
|
45
|
-
import "./
|
|
44
|
+
import "./matMulGelu-B2s_80-H.js";
|
|
46
45
|
import "./ops/grads/matMulGelu.js";
|
|
47
46
|
import "./ops/cpu/gelu.js";
|
|
48
47
|
import "./ops/webgl/gelu.js";
|
|
49
|
-
import "./gelu-
|
|
48
|
+
import "./gelu-DqTbCx5x.js";
|
|
50
49
|
import "./ops/webgl/log.js";
|
|
51
50
|
import "./ops/cpu/adamMoments.js";
|
|
52
51
|
import "./ops/webgl/adamMoments.js";
|
|
@@ -57,7 +56,7 @@ import "./checks/normRMSGrad.js";
|
|
|
57
56
|
import k from "./utilities/profile.js";
|
|
58
57
|
import w from "./models/factory.js";
|
|
59
58
|
class a {
|
|
60
|
-
ee = new
|
|
59
|
+
ee = new p();
|
|
61
60
|
_config;
|
|
62
61
|
_model;
|
|
63
62
|
_tokeniser;
|
|
@@ -156,7 +155,7 @@ class a {
|
|
|
156
155
|
trainer() {
|
|
157
156
|
if (!this._model || !this._tokeniser)
|
|
158
157
|
throw new Error("model_or_tokeniser_not_initialized.");
|
|
159
|
-
const t = new
|
|
158
|
+
const t = new f(this._model, this._tokeniser);
|
|
160
159
|
return t.on("start", () => this.setStatus("training")), t.on("stop", () => this.setStatus("ready")), t.on("log", async (e, r) => {
|
|
161
160
|
const o = this.ee.listeners("trainStep");
|
|
162
161
|
for (const s of o)
|
|
@@ -184,7 +183,7 @@ class a {
|
|
|
184
183
|
}), t;
|
|
185
184
|
}
|
|
186
185
|
generateText(t, e) {
|
|
187
|
-
return this.generator().generate(t, e);
|
|
186
|
+
return Array.isArray(t) ? this.generator().generate(t, e) : this.generator().generate([], e);
|
|
188
187
|
}
|
|
189
188
|
dispose() {
|
|
190
189
|
this._model?.dispose();
|
package/dist/Trainer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ITokeniser } from './tokeniser/type';
|
|
1
|
+
import { Conversation, ITokeniser } from './tokeniser/type';
|
|
2
2
|
import { default as EE } from 'eventemitter3';
|
|
3
3
|
import { TrainingLogEntry, TrainingProgress } from './training/Trainer';
|
|
4
4
|
import { default as Model, ModelForwardAttributes } from './models/model';
|
|
@@ -30,7 +30,7 @@ export default class Trainer extends EE<'start' | 'stop' | 'log'> {
|
|
|
30
30
|
constructor(model: Model<ModelForwardAttributes>, tokeniser: ITokeniser);
|
|
31
31
|
stop(): void;
|
|
32
32
|
reset(): void;
|
|
33
|
-
prepare(text:
|
|
33
|
+
prepare(text: Conversation[][], options?: ITrainerOptions): Promise<void>;
|
|
34
34
|
train(options?: ITrainerOptions): Promise<void>;
|
|
35
35
|
step(options?: ITrainerOptions): Promise<void>;
|
|
36
36
|
getLog(): TrainingLogEntry[];
|
package/dist/Trainer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import
|
|
3
|
-
class
|
|
1
|
+
import { E as o } from "./index-DvYrXKkX.js";
|
|
2
|
+
import d from "./training/FullTrainer.js";
|
|
3
|
+
class g extends o {
|
|
4
4
|
trainer;
|
|
5
5
|
hasTrained = !1;
|
|
6
6
|
trainDataset;
|
|
@@ -9,7 +9,7 @@ class m extends l {
|
|
|
9
9
|
log = [];
|
|
10
10
|
progress = null;
|
|
11
11
|
constructor(t, e) {
|
|
12
|
-
super(), this.trainer = new
|
|
12
|
+
super(), this.trainer = new d(t, e, 1e-3);
|
|
13
13
|
}
|
|
14
14
|
stop() {
|
|
15
15
|
this.trainer.stop();
|
|
@@ -22,7 +22,7 @@ class m extends l {
|
|
|
22
22
|
t,
|
|
23
23
|
e?.batchSize || 32,
|
|
24
24
|
e?.validationSplit || 0.1
|
|
25
|
-
), i = t.reduce((r, n) => r + n.length, 0) * (1 - (e?.validationSplit || 0));
|
|
25
|
+
), i = t.reduce((r, n) => r + n.reduce((l, h) => l + h.content.length, 0), 0) * (1 - (e?.validationSplit || 0));
|
|
26
26
|
this.trainDataset = a, this.validationDataset = s, this.totalSamples = i;
|
|
27
27
|
}
|
|
28
28
|
async train(t) {
|
|
@@ -91,5 +91,5 @@ class m extends l {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
export {
|
|
94
|
-
|
|
94
|
+
g as default
|
|
95
95
|
};
|
package/dist/backend.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as o, s as e, r as s } from "./index-
|
|
1
|
+
import { g as o, s as e, r as s } from "./index-D0RBWjq8.js";
|
|
2
2
|
async function c(t, a) {
|
|
3
3
|
if (o() !== t) {
|
|
4
4
|
if (t === "webgpu") {
|
|
5
5
|
const { registerWebGPUBackend: i } = await import("./patches/webgpu_base.js");
|
|
6
|
-
i(a), await import("./index-
|
|
6
|
+
i(a), await import("./index-Dj5TkmPY.js"), await import("./ops/webgpu/index.js");
|
|
7
7
|
}
|
|
8
8
|
await e(t), await s(), console.log(`Backend set to ${t}`);
|
|
9
9
|
}
|