@genai-fi/nanogpt 0.18.0 → 0.19.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.js +30 -30
- package/dist/{RealDiv-ioj6Z-ox.js → RealDiv-CGwv0liw.js} +9 -9
- package/dist/{Reshape-BZC-ebeR.js → Reshape-BW__R4mZ.js} +7 -7
- package/dist/{Reshape-pwprEaej.js → Reshape-CPBkTIH2.js} +1 -1
- package/dist/TeachableLLM.js +17 -17
- package/dist/Trainer.js +97 -95
- package/dist/{axis_util-QWWgLjut.js → axis_util-GTVlo58H.js} +1 -1
- package/dist/backend.js +2 -2
- package/dist/{backend_util-qwSFfxYx.js → backend_util-GaFarB78.js} +21 -21
- package/dist/{backend_webgpu-DI2wXEC2.js → backend_webgpu-BqASlsbV.js} +8 -8
- package/dist/{broadcast_to-C_EJTVTZ.js → broadcast_to-eS93CCN_.js} +2 -2
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +5 -5
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/matMulGelu.js +2 -2
- package/dist/checks/normRMS.js +6 -6
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.js +6 -6
- package/dist/checks/qkv.js +2 -2
- package/dist/checks/rope.js +2 -2
- package/dist/{clip_by_value-CLAD4h_I.js → clip_by_value-DDA7rrcT.js} +1 -1
- package/dist/complex-DI35Q-gW.js +11 -0
- package/dist/{concat-Dqk7Xk7h.js → concat-CAQpCret.js} +5 -5
- package/dist/{concat_util-C1Mxe27t.js → concat_util-D18dJ4fD.js} +1 -1
- package/dist/{dataset-DlqAN81i.js → dataset-CGGp1z9P.js} +3 -3
- package/dist/{dropout_util-N0z8Os-K.js → dropout_util--NxWuYg2.js} +1 -1
- package/dist/{expand_dims-D0rBtgT1.js → expand_dims-Bkd1YD5x.js} +4 -4
- package/dist/{exports_initializers-DIOZQt_L.js → exports_initializers-CYzKLjN7.js} +1 -1
- package/dist/{floor-CymuCmTO.js → floor-BQtb-Azg.js} +1 -1
- package/dist/{gather-DEyjXNb1.js → gather-qIqEqaGn.js} +1 -1
- package/dist/{gelu-DpTCC3eB.js → gelu-B220X1Go.js} +1 -1
- package/dist/{gpgpu_math-3bCb5ooU.js → gpgpu_math-BwvV12df.js} +25 -25
- package/dist/{index-DSGwv2Yx.js → index-CUXkjxiT.js} +33 -33
- package/dist/{index-BQvB7LCC.js → index-CjOWnMXP.js} +15 -15
- package/dist/{kernel_funcs_utils-DGqzNlHT.js → kernel_funcs_utils-pq0CK9co.js} +6 -6
- package/dist/layers/BaseLayer.js +4 -4
- package/dist/layers/CausalSelfAttention.d.ts +1 -0
- package/dist/layers/CausalSelfAttention.js +14 -14
- package/dist/layers/LoRA.js +4 -4
- package/dist/layers/MLP.js +4 -4
- package/dist/layers/PositionEmbedding.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.js +6 -6
- package/dist/layers/TransformerBlock.d.ts +1 -0
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/layers/WeightStore.js +2 -2
- package/dist/loader/loadTransformers.js +9 -9
- package/dist/loader/oldZipLoad.js +9 -9
- package/dist/loader/save.js +38 -30
- package/dist/loader/types.d.ts +1 -0
- package/dist/main.js +9 -9
- package/dist/{matMul16-BIT70Vya.js → matMul16-BcVC_E62.js} +3 -3
- package/dist/{matMulGelu-CsZnh18H.js → matMulGelu-JNLZqKQp.js} +18 -18
- package/dist/mat_mul-DhG0Newp.js +11 -0
- package/dist/mod-CSdCpRjf.js +11 -0
- package/dist/models/NanoGPTV1.js +2 -2
- package/dist/models/NanoGPTV2.js +2 -2
- package/dist/models/model.d.ts +1 -0
- package/dist/models/model.js +9 -9
- package/dist/{not_equal-CkQKkKZy.js → not_equal-hurPF26l.js} +15 -15
- package/dist/{ones-DbVB5N58.js → ones-BytntneX.js} +3 -3
- package/dist/ops/adamAdjust.js +3 -3
- package/dist/ops/adamMoments.js +3 -3
- package/dist/ops/add16.js +1 -1
- package/dist/ops/appendCache.js +6 -6
- package/dist/ops/attentionMask.js +3 -3
- package/dist/ops/concat16.js +3 -3
- package/dist/ops/cpu/adamAdjust.js +9 -9
- package/dist/ops/cpu/adamMoments.js +5 -5
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +6 -6
- package/dist/ops/cpu/fusedSoftmax.js +4 -4
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +4 -4
- package/dist/ops/cpu/matMul16.js +2 -2
- package/dist/ops/cpu/matMulGelu.js +7 -7
- package/dist/ops/cpu/matMulMul.js +2 -2
- package/dist/ops/cpu/mulDropout.js +5 -5
- 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 +5 -5
- package/dist/ops/dot16.js +2 -2
- package/dist/ops/dropout.js +6 -6
- package/dist/ops/dropout16.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/globalNorm.js +7 -7
- package/dist/ops/grads/add16.js +1 -1
- package/dist/ops/grads/attentionMask.js +2 -2
- package/dist/ops/grads/dropout16.js +1 -1
- package/dist/ops/grads/gelu.js +2 -2
- package/dist/ops/grads/matMul16.js +3 -3
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/mul16.js +1 -1
- package/dist/ops/grads/normRMS.js +7 -7
- package/dist/ops/grads/pack16.js +3 -3
- package/dist/ops/grads/qkv.js +11 -11
- package/dist/ops/grads/rope.js +2 -2
- package/dist/ops/grads/softmax16.js +1 -1
- package/dist/ops/grads/unpack16.js +2 -2
- package/dist/ops/matMul16.js +3 -3
- package/dist/ops/matMulGelu.js +6 -6
- package/dist/ops/matMulMul.js +3 -3
- package/dist/ops/mul16.js +1 -1
- package/dist/ops/mulDrop.js +3 -3
- package/dist/ops/normRMS.js +4 -4
- package/dist/ops/pack16.js +2 -2
- package/dist/ops/qkv.js +3 -3
- package/dist/ops/reshape16.js +6 -6
- package/dist/ops/rope.js +2 -2
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.js +2 -2
- package/dist/ops/softmax16.js +1 -1
- package/dist/ops/sub16.js +1 -1
- package/dist/ops/sum16.js +6 -6
- package/dist/ops/transpose16.js +3 -3
- package/dist/ops/unpack16.js +2 -2
- package/dist/ops/webgl/adamAdjust.js +2 -2
- package/dist/ops/webgl/adamMoments.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/dropout16.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +7 -7
- package/dist/ops/webgl/gatherSub.js +3 -3
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMul16.js +13 -13
- package/dist/ops/webgl/matMulGelu.js +4 -4
- package/dist/ops/webgl/matMulMul.js +2 -2
- 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 +2 -2
- package/dist/ops/webgpu/adamAdjust.js +3 -3
- package/dist/ops/webgpu/adamMoments.js +3 -3
- package/dist/ops/webgpu/add16.js +6 -6
- package/dist/ops/webgpu/appendCache.js +3 -3
- package/dist/ops/webgpu/attentionMask.js +2 -2
- package/dist/ops/webgpu/attentionMask32_program.js +2 -2
- package/dist/ops/webgpu/clipScale.js +7 -7
- package/dist/ops/webgpu/concat16.js +5 -5
- package/dist/ops/webgpu/dropout16.js +6 -6
- package/dist/ops/webgpu/gatherSub.js +3 -3
- package/dist/ops/webgpu/gelu.js +8 -8
- package/dist/ops/webgpu/matMul16.js +16 -16
- package/dist/ops/webgpu/matMul16_program.js +2 -2
- package/dist/ops/webgpu/mul16.js +5 -5
- package/dist/ops/webgpu/norm2.js +1 -1
- package/dist/ops/webgpu/normRMS.js +2 -2
- package/dist/ops/webgpu/normRMSGrad.js +4 -4
- package/dist/ops/webgpu/pack16.js +4 -4
- package/dist/ops/webgpu/pack16_program.js +2 -2
- package/dist/ops/webgpu/qkv.js +2 -2
- package/dist/ops/webgpu/rope.js +3 -3
- package/dist/ops/webgpu/scatterSub.js +3 -3
- package/dist/ops/webgpu/slice16.js +4 -4
- package/dist/ops/webgpu/softmax16.js +4 -4
- 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 +4 -4
- package/dist/ops/webgpu/sub16.js +6 -6
- package/dist/ops/webgpu/sum16.js +3 -3
- package/dist/ops/webgpu/transpose16.js +8 -8
- package/dist/ops/webgpu/transpose16_program.js +2 -2
- package/dist/ops/webgpu/transpose16_shared_program.js +3 -3
- package/dist/ops/webgpu/unpack16.js +3 -3
- package/dist/ops/webgpu/utils/binary_op.js +3 -3
- package/dist/ops/webgpu/utils/reductions.js +5 -5
- package/dist/{ops-CURIZSVt.js → ops-CsXeTq1P.js} +100 -100
- package/dist/{pack16-WlOSOuZA.js → pack16-bqltoUlR.js} +2 -2
- package/dist/patches/webgpu_backend.js +6 -6
- package/dist/patches/webgpu_base.js +1 -1
- package/dist/patches/webgpu_program.js +2 -2
- package/dist/{random_normal-CIm8lk2-.js → random_normal-IBRrha8a.js} +1 -1
- package/dist/{random_width-B_fVXhGx.js → random_width-DN5ZtQkM.js} +131 -131
- package/dist/{range-BDxO73mk.js → range-C-CjF-LI.js} +1 -1
- package/dist/relu-J_X6MUzx.js +9 -0
- package/dist/{reshape-BIN71H3p.js → reshape-BDOuCSNW.js} +1 -1
- package/dist/{resize_nearest_neighbor-C6_0dAnK.js → resize_nearest_neighbor-BojqlfRe.js} +41 -41
- package/dist/{rope-CC5RjmKU.js → rope-DcrZM_e6.js} +5 -5
- package/dist/{scatter_nd_util-C-x73Cj6.js → scatter_nd_util-ByNJaL6I.js} +1 -1
- package/dist/{segment_util-4zuHV5IG.js → segment_util-Dasb2Zaf.js} +2 -2
- package/dist/{selu_util-BXdhy_W6.js → selu_util-BLhIqRkw.js} +5 -5
- package/dist/{shared-zTaJ5siv.js → shared-3agzAqQ_.js} +1 -1
- package/dist/{shared-DRWDyk9w.js → shared-CagdqkLh.js} +6 -6
- package/dist/slice-BzS11Qh0.js +12 -0
- package/dist/{slice_util-DPY56GzQ.js → slice_util-CC35pLmT.js} +5 -5
- package/dist/{softmax-BLGJqdwx.js → softmax-D4q1LJN7.js} +1 -1
- package/dist/split-C2Sj255c.js +9 -0
- package/dist/{squeeze-O_YWJpw_.js → squeeze-ho4wLUek.js} +2 -2
- package/dist/{stack-z6QE7kmP.js → stack-DudVrtmG.js} +1 -1
- package/dist/{step-DQY6_ABw.js → step-BTxPtq1r.js} +4 -4
- package/dist/{sum-D39FeU5h.js → sum-BpiwSWvg.js} +3 -3
- package/dist/{tensor-D8e0Gd7c.js → tensor-BWFldCso.js} +1 -1
- package/dist/{tensor1d-BMl0eZYV.js → tensor1d-LMGMIUlr.js} +1 -1
- package/dist/{tensor2d-DTtQ1QcT.js → tensor2d-BnXMKScO.js} +1 -1
- package/dist/{tensor4d-Dj4rDssL.js → tensor4d-C6UCG_u8.js} +1 -1
- package/dist/{tfjs_backend-Bk3PmK91.js → tfjs_backend-BGnG-ppu.js} +65 -65
- package/dist/{tile-CsWlVKKz.js → tile-CFy-xTO6.js} +1 -1
- package/dist/tokeniser/BaseTokeniser.d.ts +5 -1
- package/dist/tokeniser/BaseTokeniser.js +62 -53
- package/dist/tokeniser/type.d.ts +8 -0
- package/dist/training/AdamW.js +2 -2
- package/dist/training/BasicTrainer.d.ts +1 -0
- package/dist/training/BasicTrainer.js +95 -79
- package/dist/training/DatasetBuilder.d.ts +6 -2
- package/dist/training/DatasetBuilder.js +60 -41
- package/dist/training/Evaluator.d.ts +1 -2
- package/dist/training/Evaluator.js +21 -31
- package/dist/training/SFTTrainer.d.ts +3 -2
- package/dist/training/SFTTrainer.js +4 -3
- package/dist/training/orthoGrad.js +1 -1
- package/dist/training/sparseCrossEntropy.js +38 -38
- package/dist/training/tasks/ConversationTask.d.ts +4 -0
- package/dist/training/tasks/ConversationTask.js +7 -7
- package/dist/training/tasks/PretrainingTask.d.ts +4 -0
- package/dist/training/tasks/PretrainingTask.js +11 -7
- package/dist/training/tasks/StartSentenceTask.d.ts +4 -0
- package/dist/training/tasks/StartSentenceTask.js +5 -5
- package/dist/training/tasks/Task.d.ts +12 -0
- package/dist/training/tasks/Task.js +55 -31
- package/dist/training/types.d.ts +1 -0
- package/dist/training/validation.d.ts +1 -1
- package/dist/training/validation.js +33 -32
- package/dist/{transpose-Qxz-4os3.js → transpose-9kRxIXWR.js} +7 -7
- package/dist/{unsorted_segment_sum-BfFVV9Zm.js → unsorted_segment_sum-DJvk5xnh.js} +20 -20
- package/dist/utilities/dummy.js +6 -6
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.js +1 -1
- 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-SSATClyt.js → variable-Ck482e3n.js} +1 -1
- package/dist/{webgpu_program-CbjdYLYk.js → webgpu_program-B4HmApL1.js} +1 -1
- package/dist/{webgpu_util-DuofJBMo.js → webgpu_util-DYlGSwOJ.js} +7 -7
- package/dist/{zeros-Bw0puq_w.js → zeros-DvZpK8s6.js} +2 -2
- package/dist/{zeros_like-rOHr54NY.js → zeros_like-CWjDdwr-.js} +69 -69
- package/package.json +1 -1
- package/dist/complex-3DpPEG9B.js +0 -11
- package/dist/mat_mul-DP86qZtZ.js +0 -11
- package/dist/mod-BXjLYwvM.js +0 -11
- package/dist/readers-17HLdxVM.js +0 -12
- package/dist/relu-DTvZKBsZ.js +0 -9
- package/dist/slice-BvItlgXu.js +0 -12
- package/dist/split-BN9LkEgS.js +0 -9
- package/dist/training/SFTDatasetBuilder.d.ts +0 -23
- package/dist/training/SFTDatasetBuilder.js +0 -85
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { o as g,
|
|
2
|
-
import { t as be } from "./tensor1d-
|
|
3
|
-
import { r as Le } from "./random_normal-
|
|
4
|
-
import { s as P } from "./slice-
|
|
5
|
-
import { r as c } from "./reshape-
|
|
6
|
-
import { g as Ne } from "./gather-
|
|
7
|
-
import { e as Pe } from "./step-
|
|
8
|
-
import { c as
|
|
9
|
-
import { t as
|
|
10
|
-
import { s as
|
|
11
|
-
import { m as $ } from "./mat_mul-
|
|
12
|
-
import { t as
|
|
13
|
-
import { c as j } from "./concat-
|
|
14
|
-
import { g as xe, r as Be } from "./dropout_util
|
|
15
|
-
import { f as Ge } from "./floor-
|
|
16
|
-
function
|
|
1
|
+
import { o as g, q as w, x as A, ag as Te, i as ke, j as M, m as Q, E as J, B as ae, U as ue, _ as le, a2 as fe, bb as he, aD as pe, bc as Ie, t as S, L as $e, a_ as Ee } from "./index-CUXkjxiT.js";
|
|
2
|
+
import { t as be } from "./tensor1d-LMGMIUlr.js";
|
|
3
|
+
import { r as Le } from "./random_normal-IBRrha8a.js";
|
|
4
|
+
import { s as P } from "./slice-BzS11Qh0.js";
|
|
5
|
+
import { r as c } from "./reshape-BDOuCSNW.js";
|
|
6
|
+
import { g as Ne } from "./gather-qIqEqaGn.js";
|
|
7
|
+
import { e as Pe } from "./step-BTxPtq1r.js";
|
|
8
|
+
import { c as Ce } from "./clip_by_value-DDA7rrcT.js";
|
|
9
|
+
import { t as Fe } from "./tile-CFy-xTO6.js";
|
|
10
|
+
import { s as ve, b as Me, c as je, g as Ue } from "./selu_util-BLhIqRkw.js";
|
|
11
|
+
import { m as $ } from "./mat_mul-DhG0Newp.js";
|
|
12
|
+
import { t as Ve } from "./transpose-9kRxIXWR.js";
|
|
13
|
+
import { c as j } from "./concat-CAQpCret.js";
|
|
14
|
+
import { g as xe, r as Be } from "./dropout_util--NxWuYg2.js";
|
|
15
|
+
import { f as Ge } from "./floor-BQtb-Azg.js";
|
|
16
|
+
function qe(e) {
|
|
17
17
|
return j(
|
|
18
18
|
e,
|
|
19
19
|
0
|
|
20
20
|
/* axis */
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const Je = /* @__PURE__ */ g({ concat1d_: qe });
|
|
24
24
|
function Ke(e, n) {
|
|
25
25
|
return j(e, n);
|
|
26
26
|
}
|
|
@@ -52,7 +52,7 @@ function en(e, n, t) {
|
|
|
52
52
|
const s = w(e, "x", "slice4d");
|
|
53
53
|
return A(s.rank === 4, () => `slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`), P(s, n, t);
|
|
54
54
|
}
|
|
55
|
-
const
|
|
55
|
+
const V = /* @__PURE__ */ g({ slice4d_: en });
|
|
56
56
|
function nn(e, n, t, s) {
|
|
57
57
|
const r = w(e, "x", "dropout");
|
|
58
58
|
if (A(r.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${r.dtype} tensor instead.`), A(n >= 0 && n < 1, () => `rate must be a float in the range [0, 1), but got ${n}.`), n === 0)
|
|
@@ -62,7 +62,7 @@ function nn(e, n, t, s) {
|
|
|
62
62
|
}
|
|
63
63
|
const tn = /* @__PURE__ */ g({ dropout_: nn });
|
|
64
64
|
function sn({ a: e, b: n, transposeA: t = !1, transposeB: s = !1, bias: r, activation: o = "linear", preluActivationWeights: i, leakyreluAlpha: f = 0.2 }) {
|
|
65
|
-
if (
|
|
65
|
+
if (ve(J.state.gradientDepth, o) === !1) {
|
|
66
66
|
let _ = $(e, n, t, s);
|
|
67
67
|
return r != null && (_ = M(_, r)), Me(_, o, i, f);
|
|
68
68
|
}
|
|
@@ -70,38 +70,38 @@ function sn({ a: e, b: n, transposeA: t = !1, transposeB: s = !1, bias: r, activ
|
|
|
70
70
|
[a, u] = ae(a, u);
|
|
71
71
|
const m = t ? a.shape[a.rank - 2] : a.shape[a.rank - 1], d = s ? u.shape[u.rank - 1] : u.shape[u.rank - 2], T = t ? a.shape[a.rank - 1] : a.shape[a.rank - 2], h = s ? u.shape[u.rank - 2] : u.shape[u.rank - 1], ne = a.shape.slice(0, -2), I = u.shape.slice(0, -2), te = ue(ne), se = ue(I);
|
|
72
72
|
A(m === d, () => `Error in fused matMul: inner shapes (${m}) and (${d}) of Tensors with shapes ${a.shape} and ${u.shape} and transposeA=${t} and transposeB=${s} must match.`);
|
|
73
|
-
const B = le(a.shape.slice(0, -2), u.shape.slice(0, -2)).concat([T, h]), G = t ? c(a, [te, m, T]) : c(a, [te, T, m]),
|
|
73
|
+
const B = le(a.shape.slice(0, -2), u.shape.slice(0, -2)).concat([T, h]), G = t ? c(a, [te, m, T]) : c(a, [te, T, m]), q = s ? c(u, [se, h, d]) : c(u, [se, d, h]);
|
|
74
74
|
let E;
|
|
75
75
|
r != null && (E = w(r, "bias", "fused matMul"), [E] = ae(E, a), le(B, E.shape));
|
|
76
76
|
let re;
|
|
77
77
|
i != null && (re = w(i, "prelu weights", "fused matMul"));
|
|
78
|
-
const oe = (_,
|
|
79
|
-
const [O, D, y,
|
|
78
|
+
const oe = (_, C) => {
|
|
79
|
+
const [O, D, y, U] = C, k = je(c(_, y.shape), y, o);
|
|
80
80
|
let b, L;
|
|
81
81
|
if (!t && !s ? (b = $(k, D, !1, !0), L = $(O, k, !0, !1)) : !t && s ? (b = $(k, D, !1, !1), L = $(k, O, !0, !1)) : t && !s ? (b = $(D, k, !1, !0), L = $(O, k, !1, !1)) : (b = $(D, k, !0, !0), L = $(k, O, !0, !0)), r != null) {
|
|
82
|
-
const ye =
|
|
82
|
+
const ye = Ue(U, k);
|
|
83
83
|
return [b, L, ye];
|
|
84
84
|
} else
|
|
85
85
|
return [b, L];
|
|
86
86
|
}, ie = {
|
|
87
87
|
a: G,
|
|
88
|
-
b:
|
|
88
|
+
b: q,
|
|
89
89
|
bias: E,
|
|
90
90
|
preluActivationWeights: re
|
|
91
91
|
}, ce = { transposeA: t, transposeB: s, activation: o, leakyreluAlpha: f };
|
|
92
|
-
return r == null ? fe((
|
|
92
|
+
return r == null ? fe((C, O, D) => {
|
|
93
93
|
const y = (
|
|
94
94
|
// tslint:disable-next-line: no-unnecessary-type-assertion
|
|
95
|
-
|
|
95
|
+
J.runKernel(he, ie, ce)
|
|
96
96
|
);
|
|
97
|
-
return D([
|
|
98
|
-
})(G,
|
|
99
|
-
const
|
|
97
|
+
return D([C, O, y]), { value: c(y, B), gradFunc: oe };
|
|
98
|
+
})(G, q) : fe((C, O, D, y) => {
|
|
99
|
+
const U = (
|
|
100
100
|
// tslint:disable-next-line: no-unnecessary-type-assertion
|
|
101
|
-
|
|
101
|
+
J.runKernel(he, ie, ce)
|
|
102
102
|
);
|
|
103
|
-
return y([
|
|
104
|
-
})(G,
|
|
103
|
+
return y([C, O, U, D]), { value: c(U, B), gradFunc: oe };
|
|
104
|
+
})(G, q, E);
|
|
105
105
|
}
|
|
106
106
|
const de = /* @__PURE__ */ g({ fusedMatMul_: sn });
|
|
107
107
|
class Ae extends Error {
|
|
@@ -119,9 +119,9 @@ class l extends Error {
|
|
|
119
119
|
super(n), Object.setPrototypeOf(this, l.prototype);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
class
|
|
122
|
+
class v extends Error {
|
|
123
123
|
constructor(n) {
|
|
124
|
-
super(n), Object.setPrototypeOf(this,
|
|
124
|
+
super(n), Object.setPrototypeOf(this, v.prototype);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
class ee extends Error {
|
|
@@ -144,16 +144,16 @@ function me(e, n) {
|
|
|
144
144
|
if (!e)
|
|
145
145
|
throw new ee(n);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function Cn(e, n) {
|
|
148
148
|
let t = 0;
|
|
149
149
|
for (const s of e)
|
|
150
150
|
s === n && t++;
|
|
151
151
|
return t;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function Fn(e) {
|
|
154
154
|
return e.length === 1 ? e[0] : e;
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function vn(e) {
|
|
157
157
|
return Array.isArray(e) ? e : [e];
|
|
158
158
|
}
|
|
159
159
|
function Mn(e) {
|
|
@@ -164,7 +164,7 @@ function jn(e) {
|
|
|
164
164
|
return e.length <= 1 || e.indexOf("_") === -1 ? e : e.replace(/[_]+(\w|$)/g, (n, t) => t.toUpperCase());
|
|
165
165
|
}
|
|
166
166
|
let p = {};
|
|
167
|
-
function
|
|
167
|
+
function Un(e) {
|
|
168
168
|
if (e == null)
|
|
169
169
|
return null;
|
|
170
170
|
const n = {};
|
|
@@ -182,7 +182,7 @@ function W(e) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function Vn(e, n = {}, t = {}, s = "object", r = !1) {
|
|
186
186
|
if (typeof e == "string") {
|
|
187
187
|
const o = e;
|
|
188
188
|
let i;
|
|
@@ -255,7 +255,7 @@ function x(e, n, t) {
|
|
|
255
255
|
if (t != null && e.indexOf(t) < 0)
|
|
256
256
|
throw new l(`${t} is not a valid ${n}. Valid values are ${e} or null/undefined.`);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function qn(e, n, t = 0, s = 1 / 0) {
|
|
259
259
|
return me(t >= 0), me(s >= t), Array.isArray(e) && e.length >= t && e.length <= s && e.every((r) => typeof r === n);
|
|
260
260
|
}
|
|
261
261
|
function on(e, n) {
|
|
@@ -264,7 +264,7 @@ function on(e, n) {
|
|
|
264
264
|
function Oe(e) {
|
|
265
265
|
return e === null ? "null" : Array.isArray(e) ? "[" + e.map((n) => Oe(n)).join(",") + "]" : typeof e == "string" ? `"${e}"` : `${e}`;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function Jn(e, n, t) {
|
|
268
268
|
let s = t != null ? t() : pe(), r;
|
|
269
269
|
return (...i) => {
|
|
270
270
|
const f = t != null ? t() : pe();
|
|
@@ -288,18 +288,18 @@ function Wn(e) {
|
|
|
288
288
|
function Yn(e) {
|
|
289
289
|
x(ln, "PoolMode", e);
|
|
290
290
|
}
|
|
291
|
-
const
|
|
291
|
+
const F = [], ge = "/";
|
|
292
292
|
function Hn(e, n) {
|
|
293
|
-
|
|
293
|
+
F.push(e);
|
|
294
294
|
try {
|
|
295
295
|
const t = n();
|
|
296
|
-
return
|
|
296
|
+
return F.pop(), t;
|
|
297
297
|
} catch (t) {
|
|
298
|
-
throw
|
|
298
|
+
throw F.pop(), t;
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
function hn() {
|
|
302
|
-
return
|
|
302
|
+
return F.length === 0 ? "" : F.join(ge) + ge;
|
|
303
303
|
}
|
|
304
304
|
function Qn(e) {
|
|
305
305
|
if (!De(e))
|
|
@@ -401,7 +401,7 @@ function R(e, n, t) {
|
|
|
401
401
|
case 3:
|
|
402
402
|
return z(e, [n, 0, 0], [t, e.shape[1], e.shape[2]]);
|
|
403
403
|
case 4:
|
|
404
|
-
return
|
|
404
|
+
return V(e, [n, 0, 0, 0], [t, e.shape[1], e.shape[2], e.shape[3]]);
|
|
405
405
|
case 5:
|
|
406
406
|
return P(e, [n, 0, 0, 0, 0], [
|
|
407
407
|
t,
|
|
@@ -434,7 +434,7 @@ function Z(e, n, t) {
|
|
|
434
434
|
case 3:
|
|
435
435
|
return z(e, [0, 0, n], [e.shape[0], e.shape[1], t]);
|
|
436
436
|
case 4:
|
|
437
|
-
return
|
|
437
|
+
return V(e, [0, 0, 0, n], [e.shape[0], e.shape[1], e.shape[2], t]);
|
|
438
438
|
default:
|
|
439
439
|
throw new l(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`);
|
|
440
440
|
}
|
|
@@ -470,9 +470,9 @@ function at(e, n, t, s) {
|
|
|
470
470
|
case 1:
|
|
471
471
|
return R(e, n, t);
|
|
472
472
|
case 2:
|
|
473
|
-
return
|
|
473
|
+
return V(e, [0, n, 0, 0], [e.shape[0], t, e.shape[2], e.shape[3]]);
|
|
474
474
|
case 3:
|
|
475
|
-
return
|
|
475
|
+
return V(e, [0, 0, n, 0], [e.shape[0], e.shape[1], t, e.shape[3]]);
|
|
476
476
|
case 4:
|
|
477
477
|
return Z(e, n, t);
|
|
478
478
|
default:
|
|
@@ -490,7 +490,7 @@ function ut(e, n = -1) {
|
|
|
490
490
|
function lt(e, n) {
|
|
491
491
|
switch (e.rank) {
|
|
492
492
|
case 1:
|
|
493
|
-
return
|
|
493
|
+
return Je([e, n]);
|
|
494
494
|
case 2:
|
|
495
495
|
return Re([e, n], 0);
|
|
496
496
|
case 3:
|
|
@@ -504,18 +504,18 @@ function lt(e, n) {
|
|
|
504
504
|
function mn(e, n) {
|
|
505
505
|
if (Array.isArray(n) || (n = [n]), e.rank !== n.length)
|
|
506
506
|
throw new l(`The length of input n (${n.length}) does not match the number of dimensions in input x (${e.rank})`);
|
|
507
|
-
return
|
|
507
|
+
return Fe(e, n);
|
|
508
508
|
}
|
|
509
509
|
function ft(e, n = 0, t = 1, s, r) {
|
|
510
510
|
return Le(e, n, t, s, r);
|
|
511
511
|
}
|
|
512
512
|
function ht(e, n, t, s) {
|
|
513
513
|
if (e.rank < 2 || n.rank < 2)
|
|
514
|
-
throw new
|
|
514
|
+
throw new v(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${n.shape}`);
|
|
515
515
|
if (n.rank >= 3) {
|
|
516
516
|
const r = e.shape.slice(-1)[0], o = n.shape.slice(-2)[0];
|
|
517
517
|
if (r !== o)
|
|
518
|
-
throw new
|
|
518
|
+
throw new v(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${n.shape}`);
|
|
519
519
|
}
|
|
520
520
|
if (e.rank === 2 && n.rank === 2)
|
|
521
521
|
return de({
|
|
@@ -530,7 +530,7 @@ function ht(e, n, t, s) {
|
|
|
530
530
|
const r = e.shape.slice(), o = r.pop();
|
|
531
531
|
e = c(e, [-1, o]);
|
|
532
532
|
const i = n.shape.slice(), f = i.pop(), a = i.pop(), u = [...i, f], m = Array.from({ length: n.rank }, (ne, I) => I === 0 ? n.rank - 2 : I <= n.rank - 2 ? I - 1 : I);
|
|
533
|
-
n = c(
|
|
533
|
+
n = c(Ve(n, m), [a, -1]);
|
|
534
534
|
const d = [...r, ...u];
|
|
535
535
|
return c(de({
|
|
536
536
|
a: e,
|
|
@@ -576,7 +576,7 @@ function mt(e, n, t) {
|
|
|
576
576
|
}
|
|
577
577
|
function gt(e, n = 1) {
|
|
578
578
|
if (n !== 1)
|
|
579
|
-
throw new
|
|
579
|
+
throw new v(`Support for alpha values other than 1 (${n}) is not implemented yet.`);
|
|
580
580
|
return Pe(e);
|
|
581
581
|
}
|
|
582
582
|
function kt(e) {
|
|
@@ -588,7 +588,7 @@ function $t(e, n, t, s) {
|
|
|
588
588
|
function wt(e) {
|
|
589
589
|
return S(() => {
|
|
590
590
|
const n = M(0.5, Q(0.2, e));
|
|
591
|
-
return
|
|
591
|
+
return Ce(n, 0, 1);
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
594
|
function At(e, n, t = !1) {
|
|
@@ -599,17 +599,17 @@ export {
|
|
|
599
599
|
Ae as A,
|
|
600
600
|
pt as B,
|
|
601
601
|
tt as C,
|
|
602
|
-
|
|
602
|
+
Cn as D,
|
|
603
603
|
gt as E,
|
|
604
604
|
wt as F,
|
|
605
605
|
kt as G,
|
|
606
606
|
nt as H,
|
|
607
607
|
zn as I,
|
|
608
|
-
|
|
608
|
+
qn as J,
|
|
609
609
|
mt as K,
|
|
610
610
|
at as L,
|
|
611
611
|
Zn as M,
|
|
612
|
-
|
|
612
|
+
v as N,
|
|
613
613
|
on as O,
|
|
614
614
|
Kn as P,
|
|
615
615
|
Wn as Q,
|
|
@@ -629,13 +629,13 @@ export {
|
|
|
629
629
|
_e as b,
|
|
630
630
|
x as c,
|
|
631
631
|
ht as d,
|
|
632
|
-
|
|
632
|
+
Vn as e,
|
|
633
633
|
Xn as f,
|
|
634
634
|
Qn as g,
|
|
635
|
-
|
|
636
|
-
|
|
635
|
+
Fn as h,
|
|
636
|
+
vn as i,
|
|
637
637
|
st as j,
|
|
638
|
-
|
|
638
|
+
Jn as k,
|
|
639
639
|
it as l,
|
|
640
640
|
dt as m,
|
|
641
641
|
Hn as n,
|
|
@@ -643,7 +643,7 @@ export {
|
|
|
643
643
|
rt as p,
|
|
644
644
|
jn as q,
|
|
645
645
|
ft as r,
|
|
646
|
-
|
|
646
|
+
Un as s,
|
|
647
647
|
Mn as t,
|
|
648
648
|
Bn as u,
|
|
649
649
|
xn as v,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as e,
|
|
1
|
+
import { o as e, q as a, x as i, E as c, T as l } from "./index-CUXkjxiT.js";
|
|
2
2
|
function u(r, t) {
|
|
3
3
|
const n = a(r, "x", "tile", "string_or_numeric");
|
|
4
4
|
i(n.rank === t.length, () => `Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`);
|
|
@@ -14,7 +14,7 @@ export default abstract class BaseTokeniser extends EE<'trainStatus'> implements
|
|
|
14
14
|
isSpecialToken(index: number): boolean;
|
|
15
15
|
protected addSpecialTokens(): void;
|
|
16
16
|
protected addSpecialToken(token: string, index: number): void;
|
|
17
|
-
|
|
17
|
+
generateID(): void;
|
|
18
18
|
abstract train(text: Conversation[][], cb?: (vocab: number) => void, datasetID?: string): Promise<number>;
|
|
19
19
|
abstract getVocab(): string[];
|
|
20
20
|
abstract getMerges(): [string, string][];
|
|
@@ -23,6 +23,10 @@ export default abstract class BaseTokeniser extends EE<'trainStatus'> implements
|
|
|
23
23
|
encodeSequence(text: string): number[];
|
|
24
24
|
encodeAsSequence(conversation: Conversation[], completion?: boolean): number[];
|
|
25
25
|
encodeConversation(conversation: Conversation[], completion?: boolean): number[];
|
|
26
|
+
encodeConversation(conversation: Conversation[], completion: boolean, masking: boolean): {
|
|
27
|
+
tokens: number[];
|
|
28
|
+
mask: boolean[];
|
|
29
|
+
};
|
|
26
30
|
abstract decode(tokens: number[]): string;
|
|
27
31
|
decodeConversation(tokens: number[] | Uint16Array): Conversation[];
|
|
28
32
|
getSpecialTokenIndex(token: string): number | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
const
|
|
1
|
+
import { E as d } from "../index-DvYrXKkX.js";
|
|
2
|
+
const u = [
|
|
3
3
|
"<eos>",
|
|
4
4
|
"<bos>",
|
|
5
5
|
"",
|
|
@@ -11,105 +11,114 @@ const l = [
|
|
|
11
11
|
"<|system_start|>",
|
|
12
12
|
"<|system_end|>"
|
|
13
13
|
];
|
|
14
|
-
class T extends
|
|
14
|
+
class T extends d {
|
|
15
15
|
id = "untrained";
|
|
16
16
|
datasetID;
|
|
17
17
|
specialTokens = /* @__PURE__ */ new Map();
|
|
18
18
|
specialTokenSet = /* @__PURE__ */ new Set();
|
|
19
|
-
isSpecialToken(
|
|
20
|
-
return this.specialTokenSet.has(
|
|
19
|
+
isSpecialToken(t) {
|
|
20
|
+
return this.specialTokenSet.has(t);
|
|
21
21
|
}
|
|
22
22
|
addSpecialTokens() {
|
|
23
|
-
|
|
24
|
-
this.addToken(
|
|
23
|
+
u.forEach((t, n) => {
|
|
24
|
+
this.addToken(t, n), this.specialTokens.set(t, n), this.specialTokenSet.add(n);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
addSpecialToken(
|
|
28
|
-
this.specialTokens.set(
|
|
27
|
+
addSpecialToken(t, n) {
|
|
28
|
+
this.specialTokens.set(t, n), this.specialTokenSet.add(n);
|
|
29
29
|
}
|
|
30
30
|
generateID() {
|
|
31
|
-
const
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
const t = this.getVocab();
|
|
32
|
+
let n = 2166136261, e = 2654435769;
|
|
33
|
+
if (t.length === 0) {
|
|
34
|
+
this.id = "untrained";
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
for (let a = 0; a < t.length; a++) {
|
|
38
|
+
const i = t[a];
|
|
39
|
+
n ^= i.length, n = Math.imul(n, 16777619), e ^= a, e = Math.imul(e, 2246822507);
|
|
40
|
+
for (let h = 0; h < i.length; h++) {
|
|
41
|
+
const c = i.charCodeAt(h);
|
|
42
|
+
n ^= c, n = Math.imul(n, 16777619), e ^= c, e = Math.imul(e, 3266489909);
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
|
-
const o = (
|
|
42
|
-
this.id = "tokeniser_" + o + "_" +
|
|
45
|
+
const o = (n >>> 0).toString(36), s = (e >>> 0).toString(36);
|
|
46
|
+
this.id = "tokeniser_" + o + "_" + s;
|
|
43
47
|
}
|
|
44
|
-
encodeSequence(
|
|
45
|
-
const
|
|
46
|
-
return [this.bosToken, ...
|
|
48
|
+
encodeSequence(t) {
|
|
49
|
+
const n = this.encode(t);
|
|
50
|
+
return [this.bosToken, ...n, this.eosToken];
|
|
47
51
|
}
|
|
48
|
-
encodeAsSequence(
|
|
49
|
-
const e =
|
|
50
|
-
return
|
|
52
|
+
encodeAsSequence(t, n) {
|
|
53
|
+
const e = t.flatMap((o) => this.encode(o.content));
|
|
54
|
+
return n ? [this.bosToken, ...e, this.eosToken, this.bosToken] : [this.bosToken, ...e, this.eosToken];
|
|
51
55
|
}
|
|
52
|
-
encodeConversation(
|
|
53
|
-
const
|
|
56
|
+
encodeConversation(t, n, e) {
|
|
57
|
+
const o = [[this.bosToken]];
|
|
58
|
+
let s;
|
|
59
|
+
e && (s = [[!1]]);
|
|
60
|
+
const a = [
|
|
54
61
|
this.getSpecialTokenIndex("<|user_start|>"),
|
|
55
62
|
this.getSpecialTokenIndex("<|assistant_start|>"),
|
|
56
63
|
this.getSpecialTokenIndex("<|system_start|>")
|
|
57
|
-
],
|
|
64
|
+
], i = [
|
|
58
65
|
this.getSpecialTokenIndex("<|user_end|>"),
|
|
59
66
|
this.getSpecialTokenIndex("<|assistant_end|>"),
|
|
60
67
|
this.getSpecialTokenIndex("<|system_end|>")
|
|
61
68
|
];
|
|
62
|
-
for (const
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
for (const c of t) {
|
|
70
|
+
let l = !1;
|
|
71
|
+
const r = this.encode(c.content);
|
|
72
|
+
switch (c.role) {
|
|
65
73
|
case "user":
|
|
66
|
-
|
|
74
|
+
o.push([a[0]]), l = !0;
|
|
67
75
|
break;
|
|
68
76
|
case "assistant":
|
|
69
|
-
|
|
77
|
+
o.push([a[1]]);
|
|
70
78
|
break;
|
|
71
79
|
case "system":
|
|
72
|
-
|
|
80
|
+
o.push([a[2]]), l = !0;
|
|
73
81
|
break;
|
|
74
82
|
}
|
|
75
|
-
switch (
|
|
83
|
+
switch (o.push(r), c.role) {
|
|
76
84
|
case "user":
|
|
77
|
-
|
|
85
|
+
o.push([i[0]]);
|
|
78
86
|
break;
|
|
79
87
|
case "assistant":
|
|
80
|
-
|
|
88
|
+
o.push([i[1]]);
|
|
81
89
|
break;
|
|
82
90
|
case "system":
|
|
83
|
-
|
|
91
|
+
o.push([i[2]]);
|
|
84
92
|
break;
|
|
85
93
|
}
|
|
94
|
+
e && s && l ? (s.push([!1]), s.push(r.map(() => !1)), s.push([!1])) : e && s && (s.push([!1]), s.push(r.map(() => !0)), s.push([!0]));
|
|
86
95
|
}
|
|
87
|
-
const
|
|
88
|
-
return
|
|
96
|
+
const h = o.flat();
|
|
97
|
+
return n ? (h.push(a[1]), e && s && s.push([!1])) : (h.push(this.eosToken), e && s && s.push([!0])), e && s ? { tokens: h, mask: s.flat() } : h;
|
|
89
98
|
}
|
|
90
|
-
decodeConversation(
|
|
91
|
-
const
|
|
99
|
+
decodeConversation(t) {
|
|
100
|
+
const n = [];
|
|
92
101
|
let e = 0;
|
|
93
|
-
for (; e <
|
|
94
|
-
const o =
|
|
95
|
-
let
|
|
96
|
-
if (o === this.getSpecialTokenIndex("<|user_start|>") ?
|
|
102
|
+
for (; e < t.length; ) {
|
|
103
|
+
const o = t[e];
|
|
104
|
+
let s = null;
|
|
105
|
+
if (o === this.getSpecialTokenIndex("<|user_start|>") ? s = "user" : o === this.getSpecialTokenIndex("<|assistant_start|>") ? s = "assistant" : o === this.getSpecialTokenIndex("<|system_start|>") ? s = "system" : o === this.bosToken || (o === this.eosToken ? s = null : (s = "text", e--)), s) {
|
|
97
106
|
e++;
|
|
98
107
|
const a = [];
|
|
99
|
-
for (; e <
|
|
100
|
-
a.push(
|
|
108
|
+
for (; e < t.length && t[e] !== this.getSpecialTokenIndex(`<|${s}_end|>`) && t[e] !== this.eosToken; )
|
|
109
|
+
a.push(t[e]), e++;
|
|
101
110
|
const i = this.decode(a);
|
|
102
|
-
|
|
111
|
+
n.push({ role: s, content: i });
|
|
103
112
|
}
|
|
104
113
|
e++;
|
|
105
114
|
}
|
|
106
|
-
return
|
|
115
|
+
return n;
|
|
107
116
|
}
|
|
108
|
-
getSpecialTokenIndex(
|
|
109
|
-
return this.specialTokens.get(
|
|
117
|
+
getSpecialTokenIndex(t) {
|
|
118
|
+
return this.specialTokens.get(t);
|
|
110
119
|
}
|
|
111
120
|
}
|
|
112
121
|
export {
|
|
113
|
-
|
|
122
|
+
u as SPECIALS,
|
|
114
123
|
T as default
|
|
115
124
|
};
|
package/dist/tokeniser/type.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ export interface ITokeniser extends EE<'trainStatus'> {
|
|
|
13
13
|
destroy(): void;
|
|
14
14
|
encode(text: string): number[];
|
|
15
15
|
encodeConversation(conversation: Conversation[], completion?: boolean): number[];
|
|
16
|
+
encodeConversation(conversation: Conversation[], completion: boolean, masking: boolean): {
|
|
17
|
+
tokens: number[];
|
|
18
|
+
mask: boolean[];
|
|
19
|
+
};
|
|
20
|
+
encodeConversation(conversation: Conversation[], completion?: boolean, masking?: boolean): number[] | {
|
|
21
|
+
tokens: number[];
|
|
22
|
+
mask: boolean[];
|
|
23
|
+
};
|
|
16
24
|
encodeSequence(text: string): number[];
|
|
17
25
|
encodeAsSequence(conversation: Conversation[], completion?: boolean): number[];
|
|
18
26
|
decode(tokens: number[] | Uint16Array): string;
|
package/dist/training/AdamW.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { adamAdjust as B } from "../ops/adamAdjust.js";
|
|
2
2
|
import { adamMoments as N } from "../ops/adamMoments.js";
|
|
3
|
-
import { O as S,
|
|
3
|
+
import { O as S, h as b, t as c, a as M, d as w } from "../index-CUXkjxiT.js";
|
|
4
4
|
import R from "./LRScheduler.js";
|
|
5
5
|
import { clipScale as f } from "../ops/globalNorm.js";
|
|
6
6
|
import { save_safetensors as v, load_safetensors as A } from "../utilities/safetensors.js";
|
|
7
|
-
import { z as O } from "../zeros-
|
|
7
|
+
import { z as O } from "../zeros-DvZpK8s6.js";
|
|
8
8
|
class _ extends S {
|
|
9
9
|
constructor(t) {
|
|
10
10
|
super(), this.config = t, this.accBeta1 = t.accBeta1 ?? t.beta1, this.accBeta2 = t.accBeta2 ?? t.beta2, this.learningRate = t.learningRate, this.beta1 = t.beta1, this.beta2 = t.beta2, this.weightDecay = t.weightDecay, this.lossScaling = t.lossScaling, this.clipNorm = t.clipNorm, this.orthGrad = t.orthoGrad ?? !1, t.epsilon === null || t.epsilon === void 0 ? this.epsilon = b().backend.epsilon() : this.epsilon = t.epsilon, this.lrScheduler = new R(t.learningRate, t);
|
|
@@ -19,6 +19,7 @@ export default class BasicTrainer {
|
|
|
19
19
|
protected _layerDrop: number;
|
|
20
20
|
protected _dropout: number;
|
|
21
21
|
constructor(model: Model<ModelForwardAttributes>, tokenizer: ITokeniser, optConfig?: Partial<AdamWOptimizerConfig>, optimizer?: AdamWOptimizer);
|
|
22
|
+
setLossMasking(): void;
|
|
22
23
|
setGradientCheckpointing(enabled: boolean): void;
|
|
23
24
|
setMixedPrecision(enabled: boolean): void;
|
|
24
25
|
setLabelSmoothing(smoothing: number): void;
|