@genai-fi/nanogpt 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DatasetBuilder-DU1G1OKX.js → DatasetBuilder-DRDW8tcM.js} +85 -86
- package/dist/Generator-8IK28IWR.js +316 -0
- package/dist/{RealDiv-CSnvtN2E.js → RealDiv-Cl8k3YTx.js} +54 -62
- package/dist/{Reshape-BlylqwWy.js → Reshape-CKxKPKqi.js} +9 -12
- package/dist/Reshape-H5zZRgr9.js +16 -0
- package/dist/RoPECache-dYscFINl.js +722 -0
- package/dist/TeachableLLM.js +29 -34
- package/dist/api/beamer.js +5 -6
- package/dist/api/responses.js +11 -12
- package/dist/api/training.js +12 -14
- package/dist/axis_util-rF9RnwKE.js +37 -0
- package/dist/backend.js +5 -6
- package/dist/{backend_util-DAV0I34P.js → backend_util-Cpp0Gwlp.js} +180 -185
- package/dist/{binary_op_util-CrYk9LXL.js → binary_op_util-WY9YIl0q.js} +3 -7
- package/dist/broadcast_to-CGvLNiQ0.js +20 -0
- package/dist/checks/appendCache.js +7 -7
- package/dist/checks/attentionMask.js +9 -8
- package/dist/checks/check.js +1 -2
- package/dist/checks/gelu.js +6 -6
- package/dist/checks/index.js +24 -25
- package/dist/checks/matMulGelu.js +7 -7
- package/dist/checks/normRMS.js +14 -12
- package/dist/checks/normRMSGrad.js +9 -8
- package/dist/checks/packUnpack.js +7 -7
- package/dist/checks/qkv.js +1 -34
- package/dist/checks/rope.js +6 -6
- package/dist/checks/weights.js +1 -2
- package/dist/clip_by_value-D-UX9am5.js +13 -0
- package/dist/complex-Cl904TqN.js +13 -0
- package/dist/{complex_util-CkazZsaH.js → complex_util-BBlPAm-s.js} +1 -2
- package/dist/concat-Oip5acVY.js +14 -0
- package/dist/{concat_util-CWzvQQlK.js → concat_util-CY45Hf4F.js} +2 -3
- package/dist/data/docx.js +3 -4
- package/dist/data/pdf.js +11 -14
- package/dist/data/stream.js +1 -2
- package/dist/data/textLoader.js +16 -15
- package/dist/data-CV_i_H6B.js +11 -0
- package/dist/data.js +5 -12
- package/dist/dist-CMMLi-qO.js +2675 -0
- package/dist/{dist-BGVm64AY.js → dist-DeVH1nGn.js} +1465 -1573
- package/dist/{dist-CwK5S7Ls.js → dist-DyL7qSLJ.js} +2664 -2400
- package/dist/dropout16-CA31Ud5a.js +20 -0
- package/dist/dropout_util-SiFMbFXz.js +22 -0
- package/dist/{eventemitter3-D_qV3Lof.js → eventemitter3-wmfmOP_f.js} +2 -3
- package/dist/expand_dims-Dh3Fulyn.js +10 -0
- package/dist/floor-BwjmUb7X.js +8 -0
- package/dist/gather-B5Z1RFt5.js +14 -0
- package/dist/gatherSub-CRUfUzBa.js +22 -0
- package/dist/gelu-Xx9-ohH9.js +25 -0
- package/dist/{gpgpu_math-20tPK8LM.js → gpgpu_math-48m8q3jI.js} +265 -286
- package/dist/inference/Beamer.js +34 -27
- package/dist/inference/Generator.js +1 -273
- package/dist/inference/tokenisePrompt.js +5 -4
- package/dist/inference/types.d.ts +6 -0
- package/dist/inference/utilities.js +1 -2
- package/dist/{jszip.min-DKa1Rjyn.js → jszip.min-Btv48m44.js} +68 -64
- package/dist/{kernel_funcs_utils-ql8Y8qPn.js → kernel_funcs_utils-BYRpSfV_.js} +39 -42
- package/dist/layers/BaseLayer.js +9 -10
- package/dist/layers/GQA.js +45 -44
- package/dist/layers/HeadLayer.js +13 -13
- package/dist/layers/LoRA.js +17 -20
- package/dist/layers/MHA.d.ts +2 -2
- package/dist/layers/MHA.js +46 -45
- package/dist/layers/MLP.js +22 -21
- package/dist/layers/PositionEmbedding.js +14 -13
- package/dist/layers/RMSNorm.js +14 -13
- package/dist/layers/RoPECache.js +1 -338
- package/dist/layers/TiedEmbedding.js +15 -14
- package/dist/layers/TransformerBlock.d.ts +3 -9
- package/dist/layers/TransformerBlock.js +29 -30
- package/dist/layers/WeightStore.js +4 -5
- package/dist/layers-CFqEip3s.js +13 -0
- package/dist/layers.js +3 -11
- package/dist/loader/load.js +27 -24
- package/dist/loader/loadHF.js +3 -3
- package/dist/loader/loadTransformers.js +5 -6
- package/dist/loader/loadZipMeta.js +1 -2
- package/dist/loader/newZipLoad.js +1 -2
- package/dist/loader/oldZipLoad.js +8 -9
- package/dist/loader/save.js +15 -16
- package/dist/main.js +3281 -3463
- package/dist/{matMul16-CO1QhsRt.js → matMul16-tE26fnhf.js} +29 -27
- package/dist/{matMulGelu-CBoqTZM7.js → matMulGelu-ASUWlKqu.js} +33 -33
- package/dist/mat_mul-R9_DWmIT.js +16 -0
- package/dist/models/Llama.js +48 -49
- package/dist/models/NanoGPTV1.js +53 -54
- package/dist/models/NanoGPTV2.js +48 -49
- package/dist/models/Qwen3.js +48 -49
- package/dist/models/config.js +3 -8
- package/dist/models/factory.js +7 -8
- package/dist/models/model.d.ts +5 -7
- package/dist/models/model.js +1 -2
- package/dist/models-DyBpJJwM.js +13 -0
- package/dist/models.js +6 -14
- package/dist/mul16-C7sqgqik.js +41 -0
- package/dist/non_max_suppression_impl-B0H318rb.js +72 -0
- package/dist/not_equal-Bu3O8rh_.js +67 -0
- package/dist/one_hot-TEMPumJj.js +14 -0
- package/dist/ones-DpPXWa6A.js +13 -0
- package/dist/ops/adamAdjust.js +2 -3
- package/dist/ops/adamMoments.js +2 -3
- package/dist/ops/add16.js +2 -3
- package/dist/ops/appendCache.js +9 -8
- package/dist/ops/attentionMask.d.ts +1 -1
- package/dist/ops/attentionMask.js +8 -5
- package/dist/ops/concat16.js +5 -5
- package/dist/ops/cpu/adamAdjust.js +7 -8
- package/dist/ops/cpu/adamMoments.js +5 -5
- package/dist/ops/cpu/appendCache.js +3 -3
- package/dist/ops/cpu/attentionMask.js +12 -8
- package/dist/ops/cpu/fusedSoftmax.js +3 -3
- package/dist/ops/cpu/gatherSub.js +1 -12
- package/dist/ops/cpu/gelu.js +12 -13
- package/dist/ops/cpu/matMul16.js +7 -7
- package/dist/ops/cpu/matMulGelu.js +21 -18
- package/dist/ops/cpu/matMulMul.js +8 -9
- package/dist/ops/cpu/mulDropout.js +8 -9
- package/dist/ops/cpu/normRMS.js +12 -13
- package/dist/ops/cpu/qkv.js +14 -13
- package/dist/ops/cpu/rope.js +11 -8
- package/dist/ops/cpu/scatterSub.js +1 -12
- package/dist/ops/dot16.js +16 -17
- package/dist/ops/dropout.js +9 -8
- package/dist/ops/dropout16.js +1 -22
- package/dist/ops/gatherSub.js +3 -4
- package/dist/ops/gelu.js +1 -2
- package/dist/ops/globalNorm.js +10 -10
- package/dist/ops/grads/add16.js +16 -17
- package/dist/ops/grads/attentionMask.js +6 -7
- package/dist/ops/grads/dropout16.js +1 -1
- package/dist/ops/grads/gelu.js +1 -2
- package/dist/ops/grads/matMul16.js +1 -2
- package/dist/ops/grads/matMulGelu.js +6 -7
- package/dist/ops/grads/mul16.js +1 -1
- package/dist/ops/grads/normRMS.js +8 -9
- package/dist/ops/grads/pack16.js +1 -2
- package/dist/ops/grads/qkv.js +10 -10
- package/dist/ops/grads/rope.js +1 -2
- package/dist/ops/grads/silu.js +1 -2
- package/dist/ops/grads/softmax16.js +6 -7
- package/dist/ops/grads/unpack16.js +1 -2
- package/dist/ops/grads/utils.js +1 -2
- package/dist/ops/matMul16.d.ts +1 -1
- package/dist/ops/matMul16.js +1 -2
- package/dist/ops/matMulGelu.js +3 -4
- package/dist/ops/matMulMul.js +2 -3
- package/dist/ops/mul16.js +1 -43
- package/dist/ops/mulDrop.js +2 -3
- package/dist/ops/normRMS.js +2 -3
- package/dist/ops/pack16.js +1 -2
- package/dist/ops/qkv.js +2 -3
- package/dist/ops/reshape16.js +11 -11
- package/dist/ops/rope.js +1 -2
- package/dist/ops/scatterSub.js +3 -4
- package/dist/ops/silu.js +1 -2
- package/dist/ops/slice16.js +5 -5
- package/dist/ops/softmax16.js +3 -4
- package/dist/ops/sub16.js +3 -4
- package/dist/ops/sum16.js +3 -3
- package/dist/ops/transpose16.js +16 -15
- package/dist/ops/unpack16.js +1 -2
- package/dist/ops/webgl/adamAdjust.js +8 -9
- package/dist/ops/webgl/adamMoments.js +2 -3
- package/dist/ops/webgl/appendCache.js +2 -3
- package/dist/ops/webgl/attentionMask.js +2 -3
- package/dist/ops/webgl/dropout16.js +2 -3
- package/dist/ops/webgl/fusedSoftmax.js +13 -13
- package/dist/ops/webgl/gatherSub.js +2 -3
- package/dist/ops/webgl/gelu.js +11 -12
- package/dist/ops/webgl/log.js +10 -10
- package/dist/ops/webgl/matMul16.js +31 -24
- package/dist/ops/webgl/matMulGelu.js +1 -2
- package/dist/ops/webgl/matMulMul.js +3 -4
- package/dist/ops/webgl/mulDropout.js +2 -3
- package/dist/ops/webgl/normRMS.js +11 -10
- package/dist/ops/webgl/qkv.js +2 -3
- package/dist/ops/webgl/rope.js +4 -5
- package/dist/ops/webgl/scatterSub.js +2 -3
- package/dist/ops/webgpu/adamAdjust.js +13 -14
- package/dist/ops/webgpu/adamMoments.js +13 -14
- package/dist/ops/webgpu/add16.js +3 -4
- package/dist/ops/webgpu/appendCache.js +20 -21
- package/dist/ops/webgpu/attentionMask.js +18 -19
- package/dist/ops/webgpu/attentionMask32_program.js +7 -8
- package/dist/ops/webgpu/clipScale.js +11 -12
- package/dist/ops/webgpu/concat16.js +17 -18
- package/dist/ops/webgpu/dropout16.js +6 -7
- package/dist/ops/webgpu/gatherSub.js +11 -12
- package/dist/ops/webgpu/gelu.js +10 -11
- package/dist/ops/webgpu/index.js +17 -17
- package/dist/ops/webgpu/matMul16.js +74 -63
- package/dist/ops/webgpu/matMul16_program.d.ts +2 -1
- package/dist/ops/webgpu/matMul16_program.js +29 -21
- package/dist/ops/webgpu/mul16.js +3 -4
- package/dist/ops/webgpu/norm2.js +9 -10
- package/dist/ops/webgpu/normRMS.js +9 -10
- package/dist/ops/webgpu/normRMS16_program.js +1 -2
- package/dist/ops/webgpu/normRMS32_program.js +1 -2
- package/dist/ops/webgpu/normRMSGrad.js +30 -30
- package/dist/ops/webgpu/pack16.js +2 -3
- package/dist/ops/webgpu/pack16_program.js +3 -4
- package/dist/ops/webgpu/qkv.js +10 -11
- package/dist/ops/webgpu/rope.js +26 -27
- package/dist/ops/webgpu/scatterSub.js +12 -13
- package/dist/ops/webgpu/silu.js +10 -11
- package/dist/ops/webgpu/slice16.js +17 -18
- package/dist/ops/webgpu/softmax16.js +9 -9
- package/dist/ops/webgpu/softmax16_program.js +9 -10
- package/dist/ops/webgpu/softmax16_subgroup_program.js +11 -12
- package/dist/ops/webgpu/softmax16grad.js +8 -9
- package/dist/ops/webgpu/sub16.js +3 -4
- package/dist/ops/webgpu/sum16.js +16 -15
- package/dist/ops/webgpu/transpose16.js +13 -12
- package/dist/ops/webgpu/transpose16_program.js +3 -4
- package/dist/ops/webgpu/transpose16_shared_program.js +17 -18
- package/dist/ops/webgpu/unpack16.js +8 -9
- package/dist/ops/webgpu/utils/binary_op.js +20 -21
- package/dist/ops/webgpu/utils/deviceInfo.js +1 -2
- package/dist/ops/webgpu/utils/reductions.js +21 -20
- package/dist/ops-Be5ACU5R.js +13 -0
- package/dist/ops-C1UpdEYM.js +509 -0
- package/dist/{pack16-BhuXNUS7.js → pack16-BHO4t1-M.js} +14 -17
- package/dist/pad-Dy-1IP3A.js +13 -0
- package/dist/patches/webgpu_backend.js +18 -19
- package/dist/patches/webgpu_base.js +2 -3
- package/dist/patches/webgpu_program.js +21 -22
- package/dist/{pdf-Bzuk68Vy.js → pdf-CbnQ75VG.js} +380 -701
- package/dist/{picomatch-BO4HbNfo.js → picomatch--TW6gyBJ.js} +229 -291
- package/dist/qkv-BQfNPucX.js +42 -0
- package/dist/rand_util-_vCY93Uw.js +44 -0
- package/dist/random_normal-DUIT8kyC.js +11 -0
- package/dist/range-CYvQC3fW.js +13 -0
- package/dist/relu-C4XULT8A.js +8 -0
- package/dist/reshape-DJb1jgMt.js +8 -0
- package/dist/resize_nearest_neighbor-DAqcTYUe.js +188 -0
- package/dist/{chunk-CWhphoD1.js → rolldown-runtime-CwxnZyOB.js} +4 -5
- package/dist/{rope-BPu_uooz.js → rope-JjBVufF_.js} +6 -8
- package/dist/scatterSub-BOnqk-uY.js +27 -0
- package/dist/scatter_nd_util-BepMCpLY.js +34 -0
- package/dist/seedrandom-SHEGFK6H.js +282 -0
- package/dist/selu_util-DeOTf-sc.js +27 -0
- package/dist/shared-BIDMUBCs.js +1864 -0
- package/dist/{shared-CfTzpULd.js → shared-CX_iPI5K.js} +2 -3
- package/dist/silu-DsAE2cJ5.js +23 -0
- package/dist/slice-Dlb1FlzG.js +13 -0
- package/dist/{slice_util-Dve4TkDn.js → slice_util-BVgPRoij.js} +3 -4
- package/dist/softmax-Dpav_dWw.js +10 -0
- package/dist/split-DYnT8chz.js +11 -0
- package/dist/squeeze-B3XYGAlg.js +9 -0
- package/dist/stack-Dbbt9mIk.js +10 -0
- package/dist/step-DA-5DNu9.js +348 -0
- package/dist/{stream-BpAwcvHz.js → stream-BBe2apn4.js} +68 -88
- package/dist/sum-C8qNbFNp.js +13 -0
- package/dist/tensor-ALxWZfmz.js +7 -0
- package/dist/tensor1d-BHgkkhTE.js +9 -0
- package/dist/tensor2d-ARItvqVn.js +10 -0
- package/dist/tensor4d-D1zRBipJ.js +10 -0
- package/dist/tfjs_backend-CsXOum0h.js +685 -0
- package/dist/tile-DfyQ0KX-.js +10 -0
- package/dist/tokenise-DbS2Ea-T.js +14 -0
- package/dist/tokenise.js +6 -15
- package/dist/tokeniser/BaseTokeniser.js +5 -9
- package/dist/tokeniser/CharTokeniser.js +1 -2
- package/dist/tokeniser/bpe.js +19 -20
- package/dist/topk-BrU2pkrR.js +19 -0
- package/dist/training/AdamW.js +35 -31
- package/dist/training/BasicTrainer.js +56 -56
- package/dist/training/DatasetBuilder.js +1 -2
- package/dist/training/Evaluator.js +4 -4
- package/dist/training/LRScheduler.js +1 -2
- package/dist/training/PreTrainer.js +7 -8
- package/dist/training/SFTTrainer.js +7 -8
- package/dist/training/configure.js +16 -15
- package/dist/training/factory.js +1 -2
- package/dist/training/loss.js +1 -2
- package/dist/training/orthoGrad.js +2 -3
- package/dist/training/prepareData.js +18 -17
- package/dist/training/sparseCrossEntropy.js +38 -32
- package/dist/training/tasks/TokenStore.js +21 -22
- package/dist/training/tasks/tokenStream.js +1 -2
- package/dist/training/validateOptions.js +1 -2
- package/dist/training/validation.js +1 -2
- package/dist/transpose-BC-M_OoT.js +34 -0
- package/dist/unsorted_segment_sum-BelC7R-q.js +408 -0
- package/dist/utilities/arrayClose.js +5 -4
- package/dist/utilities/arrayShape.js +1 -2
- package/dist/utilities/datasetID.js +1 -2
- package/dist/utilities/dummy.js +15 -15
- package/dist/utilities/float16.js +10 -10
- package/dist/utilities/maxHeap.js +1 -2
- package/dist/utilities/multinomialCPU.d.ts +1 -2
- package/dist/utilities/multinomialCPU.js +6 -8
- package/dist/utilities/packed.js +2 -3
- package/dist/utilities/parameters.js +3 -4
- package/dist/utilities/performance.js +2 -3
- package/dist/utilities/profile.js +3 -4
- package/dist/utilities/random.js +1 -2
- package/dist/utilities/safetensors.js +14 -14
- package/dist/utilities/sentences.js +16 -13
- package/dist/utilities/tokenParse.js +1 -2
- package/dist/utilities/tokens.js +5 -6
- package/dist/utilities/topP.d.ts +1 -0
- package/dist/utilities/topP.js +20 -13
- package/dist/utilities/waitForModel.js +1 -2
- package/dist/utilities/weights.js +4 -4
- package/dist/utilities/yielder.js +1 -2
- package/dist/{v4-BK7K-jy_.js → v4-YCkfo8OR.js} +4 -7
- package/dist/{webgpu-IAn9VotJ.js → webgpu-BHX-uBym.js} +156 -163
- package/dist/{webgpu_program-B0PokuRJ.js → webgpu_program-DvkFqRlR.js} +28 -29
- package/dist/{webgpu_util-DfODg6XI.js → webgpu_util-5QTyovaf.js} +2 -3
- package/dist/zeros-hxKGkRfl.js +12 -0
- package/package.json +3 -3
- package/dist/Reshape-CwxdaU8n.js +0 -17
- package/dist/dist-Da20xy8E.js +0 -6375
- package/dist/gelu-B6637MKa.js +0 -27
- package/dist/selu_util-B_AFEfoz.js +0 -24
- package/dist/shared-24EoeHJl.js +0 -1314
- package/dist/silu-B6bvCgJ7.js +0 -25
- package/dist/tfjs_backend-h5weiy1O.js +0 -614
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { i as e } from "./
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { i as e } from "./rolldown-runtime-CwxnZyOB.js";
|
|
2
|
+
import { B as t, F as n, Y as r, _i as i, _t as a, at as o, ot as s, ut as c, vt as l, yi as ee } from "./dist-CMMLi-qO.js";
|
|
3
|
+
import { t as u } from "./tensor-ALxWZfmz.js";
|
|
4
|
+
import { t as d } from "./seedrandom-SHEGFK6H.js";
|
|
5
|
+
import { t as f } from "./stack-Dbbt9mIk.js";
|
|
6
|
+
// node_modules/@tensorflow/tfjs-data/dist/util/deep_map.js
|
|
7
|
+
var p = /* @__PURE__ */ e(d());
|
|
8
|
+
function m(e, t) {
|
|
9
|
+
return h(e, t);
|
|
7
10
|
}
|
|
8
|
-
function
|
|
11
|
+
function h(e, t, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set()) {
|
|
9
12
|
if (e == null) return null;
|
|
10
13
|
if (typeof Blob == "function" && e instanceof Blob) return e.slice();
|
|
11
14
|
if (r.has(e)) throw Error("Circular references are not supported.");
|
|
@@ -13,34 +16,36 @@ function g(e, t, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set()) {
|
|
|
13
16
|
let i = t(e);
|
|
14
17
|
if (i.recurse && i.value !== null) throw Error("A deep map function may not return both a value and recurse=true.");
|
|
15
18
|
if (!i.recurse) return n.set(e, i.value), i.value;
|
|
16
|
-
if (
|
|
19
|
+
if (v(e)) {
|
|
17
20
|
let i = Array.isArray(e) ? [] : {};
|
|
18
21
|
r.add(e);
|
|
19
22
|
for (let a in e) {
|
|
20
23
|
let o = e[a];
|
|
21
|
-
i[a] =
|
|
24
|
+
i[a] = h(o, t, n, r);
|
|
22
25
|
}
|
|
23
26
|
return r.delete(e), e.__proto__ && (i.__proto__ = e.__proto__), i;
|
|
24
|
-
}
|
|
27
|
+
}
|
|
28
|
+
throw Error(`Can't recurse into non-iterable type: ${e}`);
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
30
|
+
function te(e, t = _) {
|
|
31
|
+
return g(e, t);
|
|
28
32
|
}
|
|
29
|
-
function
|
|
33
|
+
function g(e, t, n = /* @__PURE__ */ new Set()) {
|
|
30
34
|
let r = e[0];
|
|
31
35
|
if (n.has(r)) throw Error("Circular references are not supported.");
|
|
32
36
|
let i = t(e);
|
|
33
37
|
if (i.recurse && i.value !== null) throw Error("A deep zip function may not return both a value and recurse=true.");
|
|
34
38
|
if (!i.recurse) return i.value;
|
|
35
|
-
if (
|
|
39
|
+
if (v(r)) {
|
|
36
40
|
let i = Array.isArray(r) ? [] : {};
|
|
37
41
|
n.add(r);
|
|
38
|
-
for (let a in r) i[a] =
|
|
42
|
+
for (let a in r) i[a] = g(e.map((e) => e[a]), t, n);
|
|
39
43
|
return n.delete(r), i;
|
|
40
|
-
}
|
|
44
|
+
}
|
|
45
|
+
throw Error(`Can't recurse into non-iterable type: ${r}`);
|
|
41
46
|
}
|
|
42
|
-
function
|
|
43
|
-
return e === null ? null :
|
|
47
|
+
function _(e) {
|
|
48
|
+
return e === null ? null : v(e[0]) ? {
|
|
44
49
|
value: null,
|
|
45
50
|
recurse: !0
|
|
46
51
|
} : {
|
|
@@ -48,31 +53,30 @@ function y(e) {
|
|
|
48
53
|
recurse: !1
|
|
49
54
|
};
|
|
50
55
|
}
|
|
51
|
-
function
|
|
56
|
+
function v(e) {
|
|
52
57
|
let t = !1;
|
|
53
|
-
if (
|
|
58
|
+
if (i().get("IS_BROWSER")) t = e instanceof TextDecoder;
|
|
54
59
|
else {
|
|
55
|
-
let { StringDecoder:
|
|
56
|
-
t = e instanceof
|
|
60
|
+
let { StringDecoder: r } = n();
|
|
61
|
+
t = e instanceof r;
|
|
57
62
|
}
|
|
58
|
-
return e != null && !ArrayBuffer.isView(e) && (Array.isArray(e) || typeof e == "object" && !(e instanceof
|
|
63
|
+
return e != null && !ArrayBuffer.isView(e) && (Array.isArray(e) || typeof e == "object" && !(e instanceof c) && !(e instanceof Promise) && !t);
|
|
59
64
|
}
|
|
60
|
-
function
|
|
61
|
-
return e == null ||
|
|
65
|
+
function y(e) {
|
|
66
|
+
return e == null || b(e) || Array.isArray(e) || typeof e == "object" && e instanceof c || a(e);
|
|
62
67
|
}
|
|
63
|
-
function
|
|
68
|
+
function b(e) {
|
|
64
69
|
return e === null || typeof e != "object" && typeof e != "function";
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return h(e, C);
|
|
71
|
+
// node_modules/@tensorflow/tfjs-data/dist/util/deep_clone.js
|
|
72
|
+
function x(e) {
|
|
73
|
+
return m(e, S);
|
|
70
74
|
}
|
|
71
|
-
function
|
|
72
|
-
return e instanceof
|
|
75
|
+
function S(e) {
|
|
76
|
+
return e instanceof c ? {
|
|
73
77
|
value: e.clone(),
|
|
74
78
|
recurse: !1
|
|
75
|
-
} :
|
|
79
|
+
} : v(e) ? {
|
|
76
80
|
value: null,
|
|
77
81
|
recurse: !0
|
|
78
82
|
} : {
|
|
@@ -80,9 +84,8 @@ function C(e) {
|
|
|
80
84
|
recurse: !1
|
|
81
85
|
};
|
|
82
86
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var w = class {
|
|
87
|
+
// node_modules/@tensorflow/tfjs-data/dist/util/ring_buffer.js
|
|
88
|
+
var C = class {
|
|
86
89
|
constructor(e) {
|
|
87
90
|
if (this.capacity = e, this.begin = 0, this.end = 0, e == null) throw RangeError("Can't create a ring buffer of unknown capacity.");
|
|
88
91
|
if (e < 1) throw RangeError("Can't create ring buffer of capacity < 1.");
|
|
@@ -137,7 +140,7 @@ var w = class {
|
|
|
137
140
|
let t = this.wrap(this.begin + e), n = this.get(t);
|
|
138
141
|
return this.set(t, this.pop()), n;
|
|
139
142
|
}
|
|
140
|
-
},
|
|
143
|
+
}, w = class e extends C {
|
|
141
144
|
constructor() {
|
|
142
145
|
super(e.INITIAL_CAPACITY);
|
|
143
146
|
}
|
|
@@ -156,16 +159,15 @@ var w = class {
|
|
|
156
159
|
this.data = t, this.capacity = e, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end = n;
|
|
157
160
|
}
|
|
158
161
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
function E(e) {
|
|
162
|
+
w.INITIAL_CAPACITY = 32;
|
|
163
|
+
// node_modules/@tensorflow/tfjs-data/dist/iterators/lazy_iterator.js
|
|
164
|
+
function T(e) {
|
|
163
165
|
return new k(e);
|
|
164
166
|
}
|
|
165
|
-
function
|
|
167
|
+
function E(e) {
|
|
166
168
|
return new A(e);
|
|
167
169
|
}
|
|
168
|
-
function
|
|
170
|
+
function D(e, t) {
|
|
169
171
|
return new V(e, t);
|
|
170
172
|
}
|
|
171
173
|
var O = class {
|
|
@@ -214,11 +216,11 @@ var O = class {
|
|
|
214
216
|
rowMajorBatch(e, t = !0) {
|
|
215
217
|
return new P(this, e, t);
|
|
216
218
|
}
|
|
217
|
-
columnMajorBatch(e, t = !0, n =
|
|
218
|
-
return this.rowMajorBatch(e, t).map((e) =>
|
|
219
|
+
columnMajorBatch(e, t = !0, n = _) {
|
|
220
|
+
return this.rowMajorBatch(e, t).map((e) => te(e, n));
|
|
219
221
|
}
|
|
220
222
|
concatenate(e, t) {
|
|
221
|
-
return new V(
|
|
223
|
+
return new V(T([this, e]), t);
|
|
222
224
|
}
|
|
223
225
|
take(e) {
|
|
224
226
|
return e < 0 || e == null ? this : new N(this, e);
|
|
@@ -249,7 +251,7 @@ var O = class {
|
|
|
249
251
|
};
|
|
250
252
|
let e = this.items[this.trav];
|
|
251
253
|
return this.trav++, {
|
|
252
|
-
value:
|
|
254
|
+
value: x(e),
|
|
253
255
|
done: !1
|
|
254
256
|
};
|
|
255
257
|
}
|
|
@@ -300,7 +302,7 @@ var O = class {
|
|
|
300
302
|
for (; this.count++ < this.maxCount;) {
|
|
301
303
|
let e = await this.upstream.next();
|
|
302
304
|
if (e.done) return e;
|
|
303
|
-
|
|
305
|
+
t(e.value);
|
|
304
306
|
}
|
|
305
307
|
return this.upstream.next();
|
|
306
308
|
}
|
|
@@ -365,7 +367,7 @@ var O = class {
|
|
|
365
367
|
for (;;) {
|
|
366
368
|
let e = await this.upstream.next();
|
|
367
369
|
if (e.done || this.predicate(e.value)) return e;
|
|
368
|
-
|
|
370
|
+
t(e.value);
|
|
369
371
|
}
|
|
370
372
|
}
|
|
371
373
|
}, I = class extends O {
|
|
@@ -381,8 +383,8 @@ var O = class {
|
|
|
381
383
|
value: null,
|
|
382
384
|
done: !0
|
|
383
385
|
};
|
|
384
|
-
let t =
|
|
385
|
-
for (let e of t)
|
|
386
|
+
let t = o(e.value), n = this.transform(e.value), r = o(n);
|
|
387
|
+
for (let e of t) s(e, r) || e.dispose();
|
|
386
388
|
return {
|
|
387
389
|
value: n,
|
|
388
390
|
done: !1
|
|
@@ -424,8 +426,8 @@ var O = class {
|
|
|
424
426
|
value: null,
|
|
425
427
|
done: !0
|
|
426
428
|
};
|
|
427
|
-
let t =
|
|
428
|
-
for (let e of t)
|
|
429
|
+
let t = o(e.value), n = await this.transform(e.value), r = o(n);
|
|
430
|
+
for (let e of t) s(e, r) || e.dispose();
|
|
429
431
|
return {
|
|
430
432
|
value: n,
|
|
431
433
|
done: !1
|
|
@@ -433,7 +435,7 @@ var O = class {
|
|
|
433
435
|
}
|
|
434
436
|
}, z = class extends O {
|
|
435
437
|
constructor() {
|
|
436
|
-
super(), this.outputQueue = new
|
|
438
|
+
super(), this.outputQueue = new w(), this.lastRead = Promise.resolve({
|
|
437
439
|
value: null,
|
|
438
440
|
done: !1
|
|
439
441
|
});
|
|
@@ -461,9 +463,9 @@ var O = class {
|
|
|
461
463
|
async pump() {
|
|
462
464
|
let e = await this.upstream.next();
|
|
463
465
|
if (e.done) return !1;
|
|
464
|
-
let t =
|
|
466
|
+
let t = o(e.value), n = this.transform(e.value), r = o(n);
|
|
465
467
|
this.outputQueue.pushAll(n);
|
|
466
|
-
for (let e of t)
|
|
468
|
+
for (let e of t) s(e, r) || e.dispose();
|
|
467
469
|
return !0;
|
|
468
470
|
}
|
|
469
471
|
}, V = class extends O {
|
|
@@ -494,7 +496,7 @@ var O = class {
|
|
|
494
496
|
})(H ||= {});
|
|
495
497
|
var U = class extends O {
|
|
496
498
|
constructor(e, t) {
|
|
497
|
-
super(), this.upstream = e, this.bufferSize = t, this.buffer = new
|
|
499
|
+
super(), this.upstream = e, this.bufferSize = t, this.buffer = new C(t);
|
|
498
500
|
}
|
|
499
501
|
summary() {
|
|
500
502
|
return `${this.upstream.summary()} -> Prefetch`;
|
|
@@ -509,8 +511,8 @@ var U = class extends O {
|
|
|
509
511
|
return this.refill(), this.buffer.shift();
|
|
510
512
|
}
|
|
511
513
|
}, W = class extends U {
|
|
512
|
-
constructor(e,
|
|
513
|
-
super(e,
|
|
514
|
+
constructor(e, t, n) {
|
|
515
|
+
super(e, t), this.upstream = e, this.windowSize = t, this.upstreamExhausted = !1, this.random = p.alea(n || l().toString()), this.lastRead = Promise.resolve({
|
|
514
516
|
value: null,
|
|
515
517
|
done: !1
|
|
516
518
|
});
|
|
@@ -541,10 +543,10 @@ var U = class extends O {
|
|
|
541
543
|
}
|
|
542
544
|
batch(e, t = !0) {
|
|
543
545
|
let n = this;
|
|
544
|
-
|
|
546
|
+
ee(e > 0, () => `batchSize needs to be positive, but it is
|
|
545
547
|
${e}`);
|
|
546
|
-
let
|
|
547
|
-
return
|
|
548
|
+
let r;
|
|
549
|
+
return r = this.size === Infinity || this.size == null ? this.size : t ? Math.ceil(this.size / e) : Math.floor(this.size / e), K(async () => (await n.iterator()).columnMajorBatch(e, t, q), r);
|
|
548
550
|
}
|
|
549
551
|
concatenate(e) {
|
|
550
552
|
let t = this, n;
|
|
@@ -552,14 +554,14 @@ var U = class extends O {
|
|
|
552
554
|
}
|
|
553
555
|
filter(e) {
|
|
554
556
|
let t = this, n;
|
|
555
|
-
return n = this.size === Infinity ? Infinity : null, K(async () => (await t.iterator()).filter((t) =>
|
|
557
|
+
return n = this.size === Infinity ? Infinity : null, K(async () => (await t.iterator()).filter((t) => r(() => e(t))), n);
|
|
556
558
|
}
|
|
557
559
|
async forEachAsync(e) {
|
|
558
560
|
return (await this.iterator()).forEachAsync(e);
|
|
559
561
|
}
|
|
560
562
|
map(e) {
|
|
561
563
|
let t = this;
|
|
562
|
-
return K(async () => (await t.iterator()).map((t) =>
|
|
564
|
+
return K(async () => (await t.iterator()).map((t) => r(() => e(t))), this.size);
|
|
563
565
|
}
|
|
564
566
|
mapAsync(e) {
|
|
565
567
|
let t = this;
|
|
@@ -572,7 +574,7 @@ var U = class extends O {
|
|
|
572
574
|
}
|
|
573
575
|
repeat(e) {
|
|
574
576
|
let t = this, n;
|
|
575
|
-
return n = this.size != null && e > 0 ? this.size * e : e === 0 ? 0 : this.size != null && (e === void 0 || e < 0) ? Infinity : null, K(async () =>
|
|
577
|
+
return n = this.size != null && e > 0 ? this.size * e : e === 0 ? 0 : this.size != null && (e === void 0 || e < 0) ? Infinity : null, K(async () => D(E(async () => ({
|
|
576
578
|
value: await t.iterator(),
|
|
577
579
|
done: !1
|
|
578
580
|
})).take(e)), n);
|
|
@@ -581,12 +583,12 @@ var U = class extends O {
|
|
|
581
583
|
let t = this, n;
|
|
582
584
|
return n = this.size != null && e >= 0 && this.size >= e ? this.size - e : this.size != null && (this.size < e || e === void 0 || e < 0) ? 0 : null, K(async () => (await t.iterator()).skip(e), n);
|
|
583
585
|
}
|
|
584
|
-
shuffle(e,
|
|
586
|
+
shuffle(e, t, n = !0) {
|
|
585
587
|
if (e == null || e < 0) throw this.size == null ? RangeError("`Dataset.shuffle()` requires bufferSize to be specified.") : RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);
|
|
586
|
-
let
|
|
588
|
+
let r = this, i = p.alea(t || l().toString());
|
|
587
589
|
return K(async () => {
|
|
588
|
-
let t =
|
|
589
|
-
return
|
|
590
|
+
let t = i.int32();
|
|
591
|
+
return n && (t += i.int32()), (await r.iterator()).shuffle(e, t.toString());
|
|
590
592
|
}, this.size);
|
|
591
593
|
}
|
|
592
594
|
take(e) {
|
|
@@ -616,7 +618,7 @@ function K(e, t = null) {
|
|
|
616
618
|
function q(e) {
|
|
617
619
|
if (e === null) return null;
|
|
618
620
|
let t = e[0];
|
|
619
|
-
return
|
|
621
|
+
return y(t) ? {
|
|
620
622
|
value: J(e),
|
|
621
623
|
recurse: !1
|
|
622
624
|
} : {
|
|
@@ -626,18 +628,16 @@ function q(e) {
|
|
|
626
628
|
}
|
|
627
629
|
function J(e) {
|
|
628
630
|
if (e.length === 0) throw Error("Can't make a batch of zero elements.");
|
|
629
|
-
return e[0] instanceof
|
|
631
|
+
return e[0] instanceof c ? f(e) : u(e);
|
|
630
632
|
}
|
|
631
|
-
|
|
632
|
-
//#region node_modules/@tensorflow/tfjs-data/dist/readers.js
|
|
633
|
+
// node_modules/@tensorflow/tfjs-data/dist/readers.js
|
|
633
634
|
function Y(e) {
|
|
634
635
|
return K(async () => {
|
|
635
636
|
let t = await e();
|
|
636
|
-
return
|
|
637
|
+
return E(() => t.next());
|
|
637
638
|
});
|
|
638
639
|
}
|
|
639
|
-
|
|
640
|
-
//#region lib/training/DatasetBuilder.ts
|
|
640
|
+
// lib/training/DatasetBuilder.ts
|
|
641
641
|
function X(e, t) {
|
|
642
642
|
let n = e.map((e) => t.encodeConversation(e)).flat();
|
|
643
643
|
return new Uint16Array(n);
|
|
@@ -680,11 +680,11 @@ var ne = class {
|
|
|
680
680
|
this.tokenizer = e, this.blockSize = t;
|
|
681
681
|
}
|
|
682
682
|
async createTextDataset(e, t) {
|
|
683
|
-
let { batchSize: n = 32, noShuffle:
|
|
684
|
-
if (
|
|
685
|
-
let
|
|
683
|
+
let { batchSize: n = 32, noShuffle: i = !1, ignoreIndex: a = 65535 } = t || {}, o = e.getTokenCount();
|
|
684
|
+
if (o < this.blockSize + 1) throw Error(`Not enough tokens (${o}) for block size ${this.blockSize}`);
|
|
685
|
+
let s = Math.ceil(e.shardSize / this.blockSize), c = {
|
|
686
686
|
shuffledShards: new Uint16Array(e.getShardCount()),
|
|
687
|
-
shuffledIndexes: new Uint16Array(
|
|
687
|
+
shuffledIndexes: new Uint16Array(s),
|
|
688
688
|
lastShardIndexes: new Uint16Array(Math.ceil(e.getShardLength(e.getShardCount() - 1) / this.blockSize)),
|
|
689
689
|
currentMask: null,
|
|
690
690
|
nextMask: null,
|
|
@@ -703,13 +703,13 @@ var ne = class {
|
|
|
703
703
|
})), {
|
|
704
704
|
dataset: Y(async function* () {
|
|
705
705
|
for (;;) {
|
|
706
|
-
let t = (c.shardIndex === c.shuffledShards.length - 1 ? c.lastShardIndexes : c.shuffledIndexes)[c.step] * this.blockSize, n = c.currentShard,
|
|
706
|
+
let t = (c.shardIndex === c.shuffledShards.length - 1 ? c.lastShardIndexes : c.shuffledIndexes)[c.step] * this.blockSize, n = c.currentShard, r = c.currentMask, o = $(c, e, i);
|
|
707
707
|
if (!n) break;
|
|
708
708
|
t + this.blockSize + 1 > n.length && (t = n.length - this.blockSize - 1);
|
|
709
709
|
let s = new Int32Array(n.slice(t, t + this.blockSize)), l = new Int32Array(n.slice(t + 1, t + this.blockSize + 1));
|
|
710
|
-
if (
|
|
711
|
-
let e = 0, n =
|
|
712
|
-
for (let t = 0; t < l.length; t++) n[t] === 0 && (l[t] =
|
|
710
|
+
if (r) {
|
|
711
|
+
let e = 0, n = r.slice(t + 1, t + this.blockSize + 1);
|
|
712
|
+
for (let t = 0; t < l.length; t++) n[t] === 0 && (l[t] = a, e++);
|
|
713
713
|
if (e === l.length) continue;
|
|
714
714
|
}
|
|
715
715
|
yield {
|
|
@@ -719,7 +719,7 @@ var ne = class {
|
|
|
719
719
|
}
|
|
720
720
|
}.bind(this)).batch(n).map((e) => {
|
|
721
721
|
let t = e;
|
|
722
|
-
return
|
|
722
|
+
return r(() => ({
|
|
723
723
|
xs: t.xs.cast("int32"),
|
|
724
724
|
ys: t.ys.cast("int32")
|
|
725
725
|
}));
|
|
@@ -728,5 +728,4 @@ var ne = class {
|
|
|
728
728
|
};
|
|
729
729
|
}
|
|
730
730
|
};
|
|
731
|
-
//#endregion
|
|
732
731
|
export { Q as a, $ as i, X as n, Z as r, ne as t };
|