@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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ay as J, ac as m, az as le, aA as fe, aB as he,
|
|
1
|
+
import { ay as J, ac as m, az as le, aA as fe, aB as he, i as $, aC as we, aD as Q, g as T, W as D, aE as z, aF as Ce, aG as Fe, h as Ae, aH as de, au as _e, aI as Ie, u as Oe, aJ as Ne, aK as N, ai as E, aL as q, aM as ye, aN as ee } from "./index-BAzbokzv.js";
|
|
2
2
|
import "./index-Tf7vU29b.js";
|
|
3
|
-
import { b as Le, d as De, f as be, c as Ue, e as Me, g as Be, a as
|
|
4
|
-
import { S as We, a as Ve, b as He, c as Xe, d as Ge, e as ze, f as qe, g as je, h as Je, i as Ye, j as Ke, k as Ze, l as Qe, m as et, s as tt, n as nt, o as rt, t as ot } from "./selu_util-
|
|
5
|
-
import { c as at, v as st, a as it } from "./scatter_nd_util-
|
|
3
|
+
import { b as Le, d as De, f as be, c as Ue, e as Me, g as Be, a as Pe, h as ke } from "./axis_util-Bu4h7XWV.js";
|
|
4
|
+
import { S as We, a as Ve, b as He, c as Xe, d as Ge, e as ze, f as qe, g as je, h as Je, i as Ye, j as Ke, k as Ze, l as Qe, m as et, s as tt, n as nt, o as rt, t as ot } from "./selu_util-sntGesxr.js";
|
|
5
|
+
import { c as at, v as st, a as it } from "./scatter_nd_util-93ln7Hut.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -509,7 +509,7 @@ const Lt = 0.3275911, Dt = 0.254829592, bt = -0.284496736, Ut = 1.421413741, Mt
|
|
|
509
509
|
* limitations under the License.
|
|
510
510
|
* =============================================================================
|
|
511
511
|
*/
|
|
512
|
-
function
|
|
512
|
+
function Pt(e, t) {
|
|
513
513
|
if (e.length !== t.length)
|
|
514
514
|
throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);
|
|
515
515
|
const n = new Float32Array(e.length * 2);
|
|
@@ -517,7 +517,7 @@ function kt(e, t) {
|
|
|
517
517
|
n[r] = e[r / 2], n[r + 1] = t[r / 2];
|
|
518
518
|
return n;
|
|
519
519
|
}
|
|
520
|
-
function
|
|
520
|
+
function kt(e) {
|
|
521
521
|
const t = new Float32Array(e.length / 2), n = new Float32Array(e.length / 2);
|
|
522
522
|
for (let r = 0; r < e.length; r += 2)
|
|
523
523
|
t[r / 2] = e[r], n[r / 2] = e[r + 1];
|
|
@@ -890,7 +890,7 @@ const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
890
890
|
getFusedBiasGradient: Qe,
|
|
891
891
|
getFusedDyActivation: et,
|
|
892
892
|
getImageCenter: At,
|
|
893
|
-
getInnerMostAxes:
|
|
893
|
+
getInnerMostAxes: Pe,
|
|
894
894
|
getPermuted: It,
|
|
895
895
|
getRaggedRank: wt,
|
|
896
896
|
getReductionAxes: _e,
|
|
@@ -911,16 +911,16 @@ const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
911
911
|
getSparseSegmentReductionNegativeSegmentIdsErrorMessage: ln,
|
|
912
912
|
getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: fn,
|
|
913
913
|
getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: hn,
|
|
914
|
-
getUndoAxesPermutation:
|
|
914
|
+
getUndoAxesPermutation: ke,
|
|
915
915
|
isIdentityPermutation: Zt,
|
|
916
916
|
log: Ie,
|
|
917
|
-
mergeRealAndImagArrays:
|
|
917
|
+
mergeRealAndImagArrays: Pt,
|
|
918
918
|
prepareAndValidate: Tt,
|
|
919
919
|
prepareSplitSize: en,
|
|
920
920
|
segment_util: vn,
|
|
921
921
|
shouldFuse: tt,
|
|
922
922
|
slice_util: nt,
|
|
923
|
-
splitRealAndImagArrays:
|
|
923
|
+
splitRealAndImagArrays: kt,
|
|
924
924
|
stridesOrDilationsArePositive: rt,
|
|
925
925
|
tupleValuesAreOne: ot,
|
|
926
926
|
upcastType: Oe,
|
|
@@ -1245,9 +1245,9 @@ function Cn(e, t, n) {
|
|
|
1245
1245
|
case 3:
|
|
1246
1246
|
return Mn(e, t, n);
|
|
1247
1247
|
case 4:
|
|
1248
|
-
return
|
|
1248
|
+
return Pn(e, t, n);
|
|
1249
1249
|
case 5:
|
|
1250
|
-
return
|
|
1250
|
+
return kn(e, t);
|
|
1251
1251
|
case 6:
|
|
1252
1252
|
return Wn(e, t);
|
|
1253
1253
|
default:
|
|
@@ -1557,7 +1557,7 @@ function Bn(e, t, n) {
|
|
|
1557
1557
|
}
|
|
1558
1558
|
`;
|
|
1559
1559
|
}
|
|
1560
|
-
function
|
|
1560
|
+
function Pn(e, t, n) {
|
|
1561
1561
|
if (n)
|
|
1562
1562
|
return `
|
|
1563
1563
|
ivec4 getOutputCoords() {
|
|
@@ -1579,7 +1579,7 @@ function kn(e, t, n) {
|
|
|
1579
1579
|
}
|
|
1580
1580
|
`;
|
|
1581
1581
|
}
|
|
1582
|
-
function
|
|
1582
|
+
function kn(e, t) {
|
|
1583
1583
|
const n = V(["r", "c", "d", "d2", "d3"], e);
|
|
1584
1584
|
return `
|
|
1585
1585
|
ivec5 getOutputCoords() {
|
|
@@ -1870,7 +1870,7 @@ function Jn(e, t) {
|
|
|
1870
1870
|
return `
|
|
1871
1871
|
${U(h, t)}
|
|
1872
1872
|
float ${o}(int row, int col) {
|
|
1873
|
-
return ${o}(${
|
|
1873
|
+
return ${o}(${P(d, i)});
|
|
1874
1874
|
}
|
|
1875
1875
|
`;
|
|
1876
1876
|
}
|
|
@@ -1929,7 +1929,7 @@ function Yn(e, t) {
|
|
|
1929
1929
|
return `
|
|
1930
1930
|
${ve(p, t)}
|
|
1931
1931
|
vec4 ${o}(int b, int row, int col) {
|
|
1932
|
-
return ${o}(${
|
|
1932
|
+
return ${o}(${P(x, d)});
|
|
1933
1933
|
}
|
|
1934
1934
|
`;
|
|
1935
1935
|
}
|
|
@@ -1961,7 +1961,7 @@ function Kn(e, t) {
|
|
|
1961
1961
|
return `
|
|
1962
1962
|
${U(x, t)}
|
|
1963
1963
|
float ${o}(int row, int col, int depth) {
|
|
1964
|
-
return ${o}(${
|
|
1964
|
+
return ${o}(${P(S, c)});
|
|
1965
1965
|
}
|
|
1966
1966
|
`;
|
|
1967
1967
|
}
|
|
@@ -2065,7 +2065,7 @@ function Qn(e, t) {
|
|
|
2065
2065
|
return `
|
|
2066
2066
|
${U(w, t)}
|
|
2067
2067
|
float ${o}(int row, int col, int depth, int depth2) {
|
|
2068
|
-
return ${o}(${
|
|
2068
|
+
return ${o}(${P(F, l)});
|
|
2069
2069
|
}
|
|
2070
2070
|
`;
|
|
2071
2071
|
}
|
|
@@ -2151,7 +2151,7 @@ function er(e) {
|
|
|
2151
2151
|
return `
|
|
2152
2152
|
${U(x)}
|
|
2153
2153
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
2154
|
-
return ${r}(${
|
|
2154
|
+
return ${r}(${P(S, l)});
|
|
2155
2155
|
}
|
|
2156
2156
|
`;
|
|
2157
2157
|
}
|
|
@@ -2209,7 +2209,7 @@ function tr(e) {
|
|
|
2209
2209
|
${U(S)}
|
|
2210
2210
|
float ${r}(int row, int col, int depth,
|
|
2211
2211
|
int depth2, int depth3, int depth4) {
|
|
2212
|
-
return ${r}(${
|
|
2212
|
+
return ${r}(${P(g, a)});
|
|
2213
2213
|
}
|
|
2214
2214
|
`;
|
|
2215
2215
|
}
|
|
@@ -2356,7 +2356,7 @@ function B(e, t) {
|
|
|
2356
2356
|
const n = JSON.parse(JSON.stringify(e));
|
|
2357
2357
|
return n.shapeInfo.logicalShape = t, n;
|
|
2358
2358
|
}
|
|
2359
|
-
function
|
|
2359
|
+
function P(e, t) {
|
|
2360
2360
|
return t.map((n) => e[n]).join(", ");
|
|
2361
2361
|
}
|
|
2362
2362
|
/**
|
|
@@ -2375,7 +2375,7 @@ function k(e, t) {
|
|
|
2375
2375
|
* limitations under the License.
|
|
2376
2376
|
* =============================================================================
|
|
2377
2377
|
*/
|
|
2378
|
-
const I = {},
|
|
2378
|
+
const I = {}, k = {
|
|
2379
2379
|
alpha: !1,
|
|
2380
2380
|
antialias: !1,
|
|
2381
2381
|
premultipliedAlpha: !1,
|
|
@@ -2411,10 +2411,10 @@ function ar(e, t) {
|
|
|
2411
2411
|
const n = t ?? or(e);
|
|
2412
2412
|
return n.addEventListener("webglcontextlost", (r) => {
|
|
2413
2413
|
r.preventDefault(), delete I[e];
|
|
2414
|
-
}, !1), m().getBool("SOFTWARE_WEBGL_ENABLED") && (
|
|
2414
|
+
}, !1), m().getBool("SOFTWARE_WEBGL_ENABLED") && (k.failIfMajorPerformanceCaveat = !1), e === 1 ? (
|
|
2415
2415
|
// tslint:disable-next-line
|
|
2416
|
-
n.getContext("webgl",
|
|
2417
|
-
) : n.getContext("webgl2",
|
|
2416
|
+
n.getContext("webgl", k) || n.getContext("experimental-webgl", k)
|
|
2417
|
+
) : n.getContext("webgl2", k);
|
|
2418
2418
|
}
|
|
2419
2419
|
/**
|
|
2420
2420
|
* @license
|
|
@@ -2575,11 +2575,11 @@ function Br(e, t) {
|
|
|
2575
2575
|
if (v(e, () => e.validateProgram(t)), e.getProgramParameter(t, e.VALIDATE_STATUS) === !1)
|
|
2576
2576
|
throw console.log(e.getProgramInfoLog(t)), new Error("Shader program validation failed.");
|
|
2577
2577
|
}
|
|
2578
|
-
function
|
|
2578
|
+
function Pr(e, t) {
|
|
2579
2579
|
const n = C(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
|
|
2580
2580
|
return v(e, () => e.bindBuffer(e.ARRAY_BUFFER, n)), v(e, () => e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
|
|
2581
2581
|
}
|
|
2582
|
-
function
|
|
2582
|
+
function kr(e, t) {
|
|
2583
2583
|
const n = C(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
|
|
2584
2584
|
return v(e, () => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n)), v(e, () => e.bufferData(e.ELEMENT_ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
|
|
2585
2585
|
}
|
|
@@ -3026,7 +3026,7 @@ export {
|
|
|
3026
3026
|
Dt as U,
|
|
3027
3027
|
Lt as V,
|
|
3028
3028
|
Ht as W,
|
|
3029
|
-
|
|
3029
|
+
kt as X,
|
|
3030
3030
|
Wt as Y,
|
|
3031
3031
|
Vt as Z,
|
|
3032
3032
|
Gt as _,
|
|
@@ -3068,8 +3068,8 @@ export {
|
|
|
3068
3068
|
xe as ae,
|
|
3069
3069
|
ie as af,
|
|
3070
3070
|
Ar as ag,
|
|
3071
|
-
|
|
3072
|
-
|
|
3071
|
+
Pr as ah,
|
|
3072
|
+
kr as ai,
|
|
3073
3073
|
v as aj,
|
|
3074
3074
|
Ir as ak,
|
|
3075
3075
|
br as al,
|
|
@@ -3098,7 +3098,7 @@ export {
|
|
|
3098
3098
|
Ft as j,
|
|
3099
3099
|
gt as k,
|
|
3100
3100
|
wt as l,
|
|
3101
|
-
|
|
3101
|
+
Pt as m,
|
|
3102
3102
|
Rt as n,
|
|
3103
3103
|
Tn as o,
|
|
3104
3104
|
tn as p,
|
|
@@ -4142,33 +4142,33 @@ Bs();
|
|
|
4142
4142
|
export {
|
|
4143
4143
|
ne as $,
|
|
4144
4144
|
Is as A,
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4145
|
+
K as B,
|
|
4146
|
+
ur as C,
|
|
4147
|
+
Ja as D,
|
|
4148
4148
|
g as E,
|
|
4149
|
-
|
|
4149
|
+
wo as F,
|
|
4150
4150
|
Qr as G,
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4151
|
+
Xn as H,
|
|
4152
|
+
Co as I,
|
|
4153
|
+
wr as J,
|
|
4154
|
+
Ha as K,
|
|
4155
|
+
Rt as L,
|
|
4156
4156
|
Sa as M,
|
|
4157
|
-
|
|
4158
|
-
|
|
4157
|
+
yo as N,
|
|
4158
|
+
In as O,
|
|
4159
4159
|
Oa as P,
|
|
4160
|
-
|
|
4160
|
+
An as Q,
|
|
4161
4161
|
qa as R,
|
|
4162
4162
|
So as S,
|
|
4163
4163
|
x as T,
|
|
4164
|
-
|
|
4164
|
+
ei as U,
|
|
4165
4165
|
Ps as V,
|
|
4166
4166
|
$t as W,
|
|
4167
4167
|
ao as X,
|
|
4168
4168
|
ta as Y,
|
|
4169
4169
|
xe as Z,
|
|
4170
4170
|
br as _,
|
|
4171
|
-
|
|
4171
|
+
b as a,
|
|
4172
4172
|
Ka as a$,
|
|
4173
4173
|
vr as a0,
|
|
4174
4174
|
ho as a1,
|
|
@@ -4233,7 +4233,7 @@ export {
|
|
|
4233
4233
|
Xe as ax,
|
|
4234
4234
|
A as ay,
|
|
4235
4235
|
st as az,
|
|
4236
|
-
b,
|
|
4236
|
+
tt as b,
|
|
4237
4237
|
La as b$,
|
|
4238
4238
|
so as b0,
|
|
4239
4239
|
Go as b1,
|
|
@@ -4298,7 +4298,7 @@ export {
|
|
|
4298
4298
|
vo as bx,
|
|
4299
4299
|
Mo as by,
|
|
4300
4300
|
nn as bz,
|
|
4301
|
-
|
|
4301
|
+
Jo as c,
|
|
4302
4302
|
xr as c$,
|
|
4303
4303
|
Ga as c0,
|
|
4304
4304
|
bo as c1,
|
|
@@ -4363,7 +4363,7 @@ export {
|
|
|
4363
4363
|
_r as cx,
|
|
4364
4364
|
Vr as cy,
|
|
4365
4365
|
aa as cz,
|
|
4366
|
-
|
|
4366
|
+
M as d,
|
|
4367
4367
|
pa as d0,
|
|
4368
4368
|
Xr as d1,
|
|
4369
4369
|
sa as d2,
|
|
@@ -4408,25 +4408,25 @@ export {
|
|
|
4408
4408
|
Ro as dy,
|
|
4409
4409
|
xo as dz,
|
|
4410
4410
|
ni as e,
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4411
|
+
as as f,
|
|
4412
|
+
z as g,
|
|
4413
|
+
os as h,
|
|
4414
|
+
y as i,
|
|
4415
|
+
Qt as j,
|
|
4416
|
+
Bn as k,
|
|
4417
|
+
mi as l,
|
|
4418
4418
|
si as m,
|
|
4419
|
-
|
|
4420
|
-
|
|
4419
|
+
gi as n,
|
|
4420
|
+
D as o,
|
|
4421
4421
|
$e as p,
|
|
4422
|
-
|
|
4422
|
+
T as q,
|
|
4423
4423
|
Xo as r,
|
|
4424
|
-
|
|
4424
|
+
q as s,
|
|
4425
4425
|
E as t,
|
|
4426
4426
|
fe as u,
|
|
4427
4427
|
hs as v,
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4428
|
+
Tn as w,
|
|
4429
|
+
Ct as x,
|
|
4430
|
+
Ge as y,
|
|
4431
4431
|
C as z
|
|
4432
4432
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as O, f as Y, h as v } from "./gpgpu_math-
|
|
1
|
+
import { h as B, g as G, ak as K, _ as W, al as z, am as V, ac as N, an as F, u as S } from "./index-BAzbokzv.js";
|
|
2
|
+
import { u as O, f as Y, h as v } from "./gpgpu_math-CNslybmD.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -62,7 +62,7 @@ class q {
|
|
|
62
62
|
`;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
const T = "if (isnan(x)) return x;",
|
|
65
|
+
const T = "if (isnan(x)) return x;", M = "return x;", pe = "return abs(x);", j = "return (x >= 0.0) ? x : (exp(x) - 1.0);", J = T + `
|
|
66
66
|
return (x < 0.0) ? 0.0 : x;
|
|
67
67
|
`, Q = T + `
|
|
68
68
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
@@ -424,11 +424,11 @@ function ye({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: s = !1, suppor
|
|
|
424
424
|
}
|
|
425
425
|
function Ie(t, e = !1) {
|
|
426
426
|
if (t === "linear")
|
|
427
|
-
return e ? ee :
|
|
427
|
+
return e ? ee : M;
|
|
428
428
|
if (t === "relu")
|
|
429
429
|
return e ? se : J;
|
|
430
430
|
if (t === "elu")
|
|
431
|
-
return e ? te :
|
|
431
|
+
return e ? te : j;
|
|
432
432
|
if (t === "relu6")
|
|
433
433
|
return e ? ae : Q;
|
|
434
434
|
if (t === "prelu")
|
package/dist/layers/BaseLayer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as g,
|
|
2
|
-
import { v as _ } from "../variable-
|
|
1
|
+
import { T as g, l as p, e as o, n as v } from "../index-BAzbokzv.js";
|
|
2
|
+
import { v as _ } from "../variable-wSS22xj5.js";
|
|
3
3
|
class M {
|
|
4
4
|
parent;
|
|
5
5
|
config;
|
|
@@ -3,13 +3,13 @@ import O from "./BaseLayer.js";
|
|
|
3
3
|
import { qkv as P } from "../ops/qkv.js";
|
|
4
4
|
import { rope as v } from "../ops/rope.js";
|
|
5
5
|
import { appendCache as V } from "../ops/appendCache.js";
|
|
6
|
-
import {
|
|
6
|
+
import { k as c, t as C } from "../index-BAzbokzv.js";
|
|
7
7
|
import { fusedSoftmax as T } from "../ops/fusedSoftmax.js";
|
|
8
|
-
import { d as y } from "../random_width-
|
|
9
|
-
import { v as b } from "../variable-
|
|
10
|
-
import { r as k, d as L } from "../dropout-
|
|
11
|
-
import { r as N } from "../reshape-
|
|
12
|
-
import { m as R } from "../mat_mul-
|
|
8
|
+
import { d as y } from "../random_width-DWzaOgrn.js";
|
|
9
|
+
import { v as b } from "../variable-wSS22xj5.js";
|
|
10
|
+
import { r as k, d as L } from "../dropout-Bciw46HT.js";
|
|
11
|
+
import { r as N } from "../reshape-krWGKraP.js";
|
|
12
|
+
import { m as R } from "../mat_mul-7121rsJk.js";
|
|
13
13
|
class $ extends O {
|
|
14
14
|
divisor;
|
|
15
15
|
index;
|
package/dist/layers/MLP.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as l } from "../index-
|
|
1
|
+
import { t as l } from "../index-BAzbokzv.js";
|
|
2
2
|
import u from "./BaseLayer.js";
|
|
3
3
|
import { matMulGelu as M } from "../ops/matMulGelu.js";
|
|
4
|
-
import { v as o } from "../variable-
|
|
5
|
-
import { r as h, d as f } from "../dropout-
|
|
6
|
-
import { r as d } from "../reshape-
|
|
7
|
-
import { m as c } from "../mat_mul-
|
|
4
|
+
import { v as o } from "../variable-wSS22xj5.js";
|
|
5
|
+
import { r as h, d as f } from "../dropout-Bciw46HT.js";
|
|
6
|
+
import { r as d } from "../reshape-krWGKraP.js";
|
|
7
|
+
import { m as c } from "../mat_mul-7121rsJk.js";
|
|
8
8
|
class V extends u {
|
|
9
9
|
index;
|
|
10
10
|
hiddenUnits;
|
package/dist/layers/RMSNorm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as s } from "../index-
|
|
1
|
+
import { t as s } from "../index-BAzbokzv.js";
|
|
2
2
|
import e from "./BaseLayer.js";
|
|
3
3
|
import { normRMS as a } from "../ops/normRMS.js";
|
|
4
|
-
import { v as i } from "../variable-
|
|
5
|
-
import { o as m } from "../ones-
|
|
4
|
+
import { v as i } from "../variable-wSS22xj5.js";
|
|
5
|
+
import { o as m } from "../ones-BBlSRqn1.js";
|
|
6
6
|
class f extends e {
|
|
7
7
|
GAMMA;
|
|
8
8
|
constructor(r, t = "", o) {
|
package/dist/layers/RoPECache.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as c } from "../reciprocal-
|
|
3
|
-
import { c as f, s as m } from "../sin-
|
|
4
|
-
import { r as a } from "../range-
|
|
1
|
+
import { s as t, j as h, t as n, k as p } from "../index-BAzbokzv.js";
|
|
2
|
+
import { r as c } from "../reciprocal-CJQeasVa.js";
|
|
3
|
+
import { c as f, s as m } from "../sin-D_h-qCSx.js";
|
|
4
|
+
import { r as a } from "../range-DYsrnfiy.js";
|
|
5
5
|
class D {
|
|
6
6
|
constructor(o) {
|
|
7
7
|
this.config = o;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "../random_width-
|
|
2
|
-
import "../index-
|
|
3
|
-
import { T as e } from "../TiedEmbedding-
|
|
1
|
+
import "../random_width-DWzaOgrn.js";
|
|
2
|
+
import "../index-BAzbokzv.js";
|
|
3
|
+
import { T as e } from "../TiedEmbedding-9WeDwvjO.js";
|
|
4
4
|
import "./BaseLayer.js";
|
|
5
|
-
import "../variable-
|
|
6
|
-
import "../gather-
|
|
5
|
+
import "../variable-wSS22xj5.js";
|
|
6
|
+
import "../gather-DjyCjmOD.js";
|
|
7
7
|
export {
|
|
8
8
|
e as default
|
|
9
9
|
};
|
|
@@ -2,7 +2,7 @@ import l from "./CausalSelfAttention.js";
|
|
|
2
2
|
import r from "./MLP.js";
|
|
3
3
|
import o from "./RMSNorm.js";
|
|
4
4
|
import d from "./BaseLayer.js";
|
|
5
|
-
import { t as p } from "../index-
|
|
5
|
+
import { t as p } from "../index-BAzbokzv.js";
|
|
6
6
|
class k extends d {
|
|
7
7
|
ln1;
|
|
8
8
|
attn;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as NanoGPT } from '../NanoGPTModel';
|
|
2
|
+
import { ITokeniser } from '../tokeniser/type';
|
|
3
|
+
export declare const VERSION = 2;
|
|
4
|
+
export interface Metadata {
|
|
5
|
+
version: string;
|
|
6
|
+
application: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadModel(data: Blob | Buffer | string): Promise<{
|
|
10
|
+
model: NanoGPT;
|
|
11
|
+
tokeniser: ITokeniser;
|
|
12
|
+
name?: string;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { j as o } from "../jszip.min-CjP2V1VV.js";
|
|
2
|
+
import i from "./oldZipLoad.js";
|
|
3
|
+
import s from "./newZipLoad.js";
|
|
4
|
+
import n from "./loadHF.js";
|
|
5
|
+
const u = 2;
|
|
6
|
+
async function f(t) {
|
|
7
|
+
const e = await fetch(t);
|
|
8
|
+
if (!e.ok)
|
|
9
|
+
throw new Error(`Failed to fetch ${t}: ${e.statusText}`);
|
|
10
|
+
return e.arrayBuffer();
|
|
11
|
+
}
|
|
12
|
+
async function m(t) {
|
|
13
|
+
if (typeof t == "string")
|
|
14
|
+
if (t.startsWith("http://") || t.startsWith("https://")) {
|
|
15
|
+
const e = await f(t), r = await o.loadAsync(e);
|
|
16
|
+
return r.file("manifest.json") ? i(r) : s(r);
|
|
17
|
+
} else
|
|
18
|
+
return n(t);
|
|
19
|
+
else {
|
|
20
|
+
const e = await o.loadAsync(t);
|
|
21
|
+
return e.file("manifest.json") ? i(e) : s(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
u as VERSION,
|
|
26
|
+
m as loadModel
|
|
27
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import w from "./loadTransformers.js";
|
|
2
|
+
async function u(t) {
|
|
3
|
+
const r = `https://huggingface.co/${t}/resolve/main/config.json`, a = `https://huggingface.co/${t}/resolve/main/tokeniser.json`, i = `https://huggingface.co/${t}/resolve/main/meta.json`, c = `https://huggingface.co/${t}/resolve/main/model.safetensors`, [o, e, s, n] = await Promise.all([
|
|
4
|
+
fetch(r),
|
|
5
|
+
fetch(a),
|
|
6
|
+
fetch(i),
|
|
7
|
+
fetch(c)
|
|
8
|
+
]);
|
|
9
|
+
if (!o.ok)
|
|
10
|
+
throw new Error(`Failed to fetch config from ${r}: ${o.statusText}`);
|
|
11
|
+
if (!e.ok)
|
|
12
|
+
throw new Error(`Failed to fetch tokeniser from ${a}: ${e.statusText}`);
|
|
13
|
+
if (!s.ok)
|
|
14
|
+
throw new Error(`Failed to fetch meta from ${i}: ${s.statusText}`);
|
|
15
|
+
if (!n.ok)
|
|
16
|
+
throw new Error(`Failed to fetch weights from ${c}: ${n.statusText}`);
|
|
17
|
+
const f = await o.json(), g = await e.json(), h = await s.json(), l = await n.arrayBuffer();
|
|
18
|
+
return w(f, g, h, l);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
u as default
|
|
22
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { default as zip } from 'jszip';
|
|
2
|
-
import { default as NanoGPT } from '../NanoGPTModel';
|
|
3
1
|
import { ITokeniser } from '../tokeniser/type';
|
|
4
|
-
|
|
2
|
+
import { default as NanoGPT } from '../NanoGPTModel';
|
|
5
3
|
export interface TransformersConfig {
|
|
6
4
|
model_type: string;
|
|
7
5
|
vocab_size: number;
|
|
@@ -15,16 +13,18 @@ export interface TransformersConfig {
|
|
|
15
13
|
mlpFactor: number;
|
|
16
14
|
useRope: boolean;
|
|
17
15
|
}
|
|
18
|
-
export interface
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
export interface TransformersTokeniser {
|
|
17
|
+
type: 'char' | 'bpe';
|
|
18
|
+
vocab: string[];
|
|
19
|
+
merges: [string, string][];
|
|
20
|
+
}
|
|
21
|
+
export interface TransformersMetadata {
|
|
21
22
|
name?: string;
|
|
23
|
+
version: number;
|
|
24
|
+
application: string;
|
|
25
|
+
[key: string]: unknown;
|
|
22
26
|
}
|
|
23
|
-
export
|
|
24
|
-
model: NanoGPT;
|
|
25
|
-
tokeniser: ITokeniser;
|
|
26
|
-
}>;
|
|
27
|
-
export declare function loadModel(data: Blob | Buffer | string): Promise<{
|
|
27
|
+
export default function loadTransformers(config: TransformersConfig, tokeniser: TransformersTokeniser, metadata: TransformersMetadata, weightData: ArrayBuffer): Promise<{
|
|
28
28
|
model: NanoGPT;
|
|
29
29
|
tokeniser: ITokeniser;
|
|
30
30
|
name?: string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import b from "../NanoGPTModel.js";
|
|
2
|
+
import c from "../tokeniser/CharTokeniser.js";
|
|
3
|
+
import l from "../tokeniser/bpe.js";
|
|
4
|
+
import { load_safetensors as u } from "../utilities/safetensors.js";
|
|
5
|
+
import { U as y } from "../index-BAzbokzv.js";
|
|
6
|
+
import { dummyPassAsync as h } from "../utilities/dummy.js";
|
|
7
|
+
async function L(e, a, r, t) {
|
|
8
|
+
const n = {
|
|
9
|
+
vocabSize: e.vocab_size,
|
|
10
|
+
blockSize: e.block_size,
|
|
11
|
+
nLayer: e.num_hidden_layers,
|
|
12
|
+
nHead: e.num_attention_heads,
|
|
13
|
+
nEmbed: e.hidden_size,
|
|
14
|
+
dropout: e.dropout,
|
|
15
|
+
biasInLinear: e.biasInLinear,
|
|
16
|
+
biasInLayerNorm: e.biasInLayerNorm,
|
|
17
|
+
mlpFactor: e.mlpFactor,
|
|
18
|
+
useRope: e.useRope
|
|
19
|
+
}, m = (a.type ?? "char") === "char" ? new c(a.vocab) : new l(a.vocab, a.merges), i = await u(t), s = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const [p, d] of Object.entries(i))
|
|
21
|
+
s.set(p, [d]);
|
|
22
|
+
y();
|
|
23
|
+
const o = new b(n);
|
|
24
|
+
return await h(o), o.loadWeights(s), { model: o, tokeniser: m, name: r.name };
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
L as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import c from "./loadTransformers.js";
|
|
2
|
+
async function g(r) {
|
|
3
|
+
const e = await r.file("config.json")?.async("string");
|
|
4
|
+
if (!e)
|
|
5
|
+
throw new Error("Config file not found in the zip archive");
|
|
6
|
+
const t = JSON.parse(e), n = await r.file("tokeniser.json")?.async("string");
|
|
7
|
+
if (!n)
|
|
8
|
+
throw new Error("Tokeniser file not found in the zip archive");
|
|
9
|
+
const i = JSON.parse(n), s = await r.file("model.safetensors").async("arraybuffer"), o = await r.file("meta.json")?.async("string");
|
|
10
|
+
let a = { version: 0, application: "" };
|
|
11
|
+
if (o)
|
|
12
|
+
try {
|
|
13
|
+
a = JSON.parse(o);
|
|
14
|
+
} catch (f) {
|
|
15
|
+
console.error("Error parsing meta file:", f);
|
|
16
|
+
}
|
|
17
|
+
return c(t, i, a, s);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
g as default
|
|
21
|
+
};
|