@genai-fi/nanogpt 1.4.1 → 1.6.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/{DatasetBuilder-DU1G1OKX.js → DatasetBuilder-DRDW8tcM.js} +85 -86
- package/dist/Generator-BcR_14Cj.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.d.ts +1 -0
- package/dist/api/beamer.js +19 -10
- 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.d.ts +14 -2
- package/dist/inference/Beamer.js +170 -105
- package/dist/inference/Generator.js +1 -259
- package/dist/inference/tokenisePrompt.d.ts +2 -1
- package/dist/inference/tokenisePrompt.js +15 -11
- package/dist/inference/types.d.ts +7 -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/{CausalSelfAttention.d.ts → GQA.d.ts} +8 -3
- package/dist/layers/GQA.js +102 -0
- package/dist/layers/HeadLayer.d.ts +12 -0
- package/dist/layers/HeadLayer.js +28 -0
- package/dist/layers/LoRA.js +17 -20
- package/dist/layers/MHA.d.ts +43 -0
- package/dist/layers/MHA.js +102 -0
- package/dist/layers/MLP.d.ts +5 -1
- package/dist/layers/MLP.js +33 -20
- package/dist/layers/PositionEmbedding.js +14 -13
- package/dist/layers/RMSNorm.d.ts +2 -0
- package/dist/layers/RMSNorm.js +16 -11
- package/dist/layers/RoPECache.js +1 -337
- package/dist/layers/TiedEmbedding.js +15 -14
- package/dist/layers/TransformerBlock.d.ts +4 -10
- package/dist/layers/TransformerBlock.js +29 -30
- package/dist/layers/WeightStore.js +4 -5
- package/dist/layers-CFqEip3s.js +13 -0
- package/dist/layers.d.ts +1 -1
- package/dist/layers.js +4 -12
- package/dist/loader/load.js +27 -24
- package/dist/loader/loadHF.js +3 -3
- package/dist/loader/loadTransformers.js +22 -7
- 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 +31 -17
- package/dist/loader/types.d.ts +8 -2
- package/dist/main.js +3281 -3463
- package/dist/matMul16-tE26fnhf.js +87 -0
- package/dist/{matMulGelu-CBoqTZM7.js → matMulGelu-ASUWlKqu.js} +33 -33
- package/dist/mat_mul-R9_DWmIT.js +16 -0
- package/dist/models/Llama.d.ts +16 -0
- package/dist/models/Llama.js +88 -0
- package/dist/models/NanoGPTV1.js +53 -54
- package/dist/models/NanoGPTV2.js +48 -49
- package/dist/models/Qwen3.d.ts +16 -0
- package/dist/models/Qwen3.js +88 -0
- package/dist/models/config.d.ts +18 -1
- package/dist/models/config.js +3 -8
- package/dist/models/factory.js +14 -11
- 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 +14 -14
- 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.d.ts +2 -0
- package/dist/ops/grads/silu.js +1 -0
- 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 +2 -2
- 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.d.ts +1 -1
- package/dist/ops/normRMS.js +10 -11
- 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.d.ts +1 -1
- package/dist/ops/rope.js +1 -2
- package/dist/ops/scatterSub.js +3 -4
- package/dist/ops/silu.d.ts +3 -0
- package/dist/ops/silu.js +1 -0
- 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 +10 -9
- 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 -16
- package/dist/ops/webgpu/matMul16.js +74 -57
- package/dist/ops/webgpu/matMul16_program.d.ts +4 -3
- package/dist/ops/webgpu/matMul16_program.js +30 -22
- package/dist/ops/webgpu/mul16.js +3 -4
- package/dist/ops/webgpu/norm2.js +9 -10
- package/dist/ops/webgpu/normRMS.js +13 -14
- package/dist/ops/webgpu/normRMS16_program.d.ts +2 -1
- package/dist/ops/webgpu/normRMS16_program.js +5 -5
- package/dist/ops/webgpu/normRMS32_program.d.ts +2 -1
- package/dist/ops/webgpu/normRMS32_program.js +5 -5
- 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 +113 -49
- package/dist/ops/webgpu/scatterSub.js +12 -13
- package/dist/ops/webgpu/silu.d.ts +14 -0
- package/dist/ops/webgpu/silu.js +117 -0
- 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-JjBVufF_.js +24 -0
- 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 +8 -5
- 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.d.ts +16 -0
- package/dist/utilities/maxHeap.js +54 -0
- 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 +34 -19
- 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/layers/CausalSelfAttention.js +0 -99
- package/dist/matMul16-DGtlziMn.js +0 -81
- package/dist/rope-C8EAiSGY.js +0 -25
- package/dist/selu_util-B_AFEfoz.js +0 -24
- package/dist/shared-24EoeHJl.js +0 -1314
- package/dist/tfjs_backend-h5weiy1O.js +0 -614
package/dist/layers/RoPECache.js
CHANGED
|
@@ -1,337 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//#endregion
|
|
3
|
-
//#region node_modules/@tensorflow/tfjs-core/dist/public/chained_ops/zeros_like.js
|
|
4
|
-
l().prototype.abs = function() {
|
|
5
|
-
return this.throwIfDisposed(), z(this);
|
|
6
|
-
}, l().prototype.acos = function() {
|
|
7
|
-
return this.throwIfDisposed(), ue(this);
|
|
8
|
-
}, l().prototype.acosh = function() {
|
|
9
|
-
return this.throwIfDisposed(), fe(this);
|
|
10
|
-
}, l().prototype.add = function(e) {
|
|
11
|
-
return this.throwIfDisposed(), st(this, e);
|
|
12
|
-
}, l().prototype.all = function(e, t) {
|
|
13
|
-
return this.throwIfDisposed(), s(this, e, t);
|
|
14
|
-
}, l().prototype.any = function(e, t) {
|
|
15
|
-
return this.throwIfDisposed(), St(this, e, t);
|
|
16
|
-
}, l().prototype.argMax = function(e) {
|
|
17
|
-
return this.throwIfDisposed(), N(this, e);
|
|
18
|
-
}, l().prototype.argMin = function(e) {
|
|
19
|
-
return this.throwIfDisposed(), v(this, e);
|
|
20
|
-
}, l().prototype.asScalar = function() {
|
|
21
|
-
return this.throwIfDisposed(), O(this.size === 1, () => "The array must have only 1 element."), G(this, []);
|
|
22
|
-
}, l().prototype.asType = function(e) {
|
|
23
|
-
return this.throwIfDisposed(), U(this, e);
|
|
24
|
-
}, l().prototype.as1D = function() {
|
|
25
|
-
return this.throwIfDisposed(), G(this, [this.size]);
|
|
26
|
-
}, l().prototype.as2D = function(e, t) {
|
|
27
|
-
return this.throwIfDisposed(), G(this, [e, t]);
|
|
28
|
-
}, l().prototype.as3D = function(e, t, n) {
|
|
29
|
-
return this.throwIfDisposed(), G(this, [
|
|
30
|
-
e,
|
|
31
|
-
t,
|
|
32
|
-
n
|
|
33
|
-
]);
|
|
34
|
-
}, l().prototype.as4D = function(e, t, n, r) {
|
|
35
|
-
return this.throwIfDisposed(), G(this, [
|
|
36
|
-
e,
|
|
37
|
-
t,
|
|
38
|
-
n,
|
|
39
|
-
r
|
|
40
|
-
]);
|
|
41
|
-
}, l().prototype.as5D = function(e, t, n, r, i) {
|
|
42
|
-
return this.throwIfDisposed(), G(this, [
|
|
43
|
-
e,
|
|
44
|
-
t,
|
|
45
|
-
n,
|
|
46
|
-
r,
|
|
47
|
-
i
|
|
48
|
-
]);
|
|
49
|
-
}, l().prototype.asin = function() {
|
|
50
|
-
return this.throwIfDisposed(), d(this);
|
|
51
|
-
}, l().prototype.asinh = function() {
|
|
52
|
-
return this.throwIfDisposed(), ae(this);
|
|
53
|
-
}, l().prototype.atan = function() {
|
|
54
|
-
return this.throwIfDisposed(), D(this);
|
|
55
|
-
}, l().prototype.atan2 = function(e) {
|
|
56
|
-
return this.throwIfDisposed(), C(this, e);
|
|
57
|
-
}, l().prototype.atanh = function() {
|
|
58
|
-
return this.throwIfDisposed(), x(this);
|
|
59
|
-
}, l().prototype.avgPool = function(e, t, n, r) {
|
|
60
|
-
return this.throwIfDisposed(), vt(this, e, t, n, r);
|
|
61
|
-
}, l().prototype.batchToSpaceND = function(e, t) {
|
|
62
|
-
return this.throwIfDisposed(), Pe(this, e, t);
|
|
63
|
-
}, l().prototype.batchNorm = function(e, t, n, r, i) {
|
|
64
|
-
return this.throwIfDisposed(), q(this, e, t, n, r, i);
|
|
65
|
-
}, l().prototype.broadcastTo = function(e) {
|
|
66
|
-
return this.throwIfDisposed(), ut(this, e);
|
|
67
|
-
}, l().prototype.cast = function(e) {
|
|
68
|
-
return this.throwIfDisposed(), U(this, e);
|
|
69
|
-
}, l().prototype.ceil = function() {
|
|
70
|
-
return this.throwIfDisposed(), nt(this);
|
|
71
|
-
}, l().prototype.clipByValue = function(e, t) {
|
|
72
|
-
return this.throwIfDisposed(), We(this, e, t);
|
|
73
|
-
}, l().prototype.concat = function(e, t) {
|
|
74
|
-
return this.throwIfDisposed(), e instanceof $ && (e = [e]), Se([this, ...e], t);
|
|
75
|
-
}, l().prototype.conv1d = function(e, t, n, r, i, a) {
|
|
76
|
-
return this.throwIfDisposed(), A(this, e, t, n, r, i, a);
|
|
77
|
-
}, l().prototype.conv2dTranspose = function(e, t, n, r, i) {
|
|
78
|
-
return this.throwIfDisposed(), _e(this, e, t, n, r, i);
|
|
79
|
-
}, l().prototype.conv2d = function(t, n, r, i, a, o) {
|
|
80
|
-
return this.throwIfDisposed(), e(this, t, n, r, i, a, o);
|
|
81
|
-
}, l().prototype.cos = function() {
|
|
82
|
-
return this.throwIfDisposed(), g(this);
|
|
83
|
-
}, l().prototype.cosh = function() {
|
|
84
|
-
return this.throwIfDisposed(), ce(this);
|
|
85
|
-
}, l().prototype.cumprod = function(e, t, n) {
|
|
86
|
-
return this.throwIfDisposed(), he(this, e, t, n);
|
|
87
|
-
}, l().prototype.cumsum = function(e, t, n) {
|
|
88
|
-
return this.throwIfDisposed(), R(this, e, t, n);
|
|
89
|
-
}, l().prototype.depthToSpace = function(e, t) {
|
|
90
|
-
return this.throwIfDisposed(), H(this, e, t);
|
|
91
|
-
}, l().prototype.depthwiseConv2d = function(e, t, n, r, i, a) {
|
|
92
|
-
return this.throwIfDisposed(), o(this, e, t, n, r, i, a);
|
|
93
|
-
}, l().prototype.dilation2d = function(e, t, n, r, i) {
|
|
94
|
-
return this.throwIfDisposed(), xt(this, e, t, n, r, i);
|
|
95
|
-
}, l().prototype.divNoNan = function(e) {
|
|
96
|
-
return this.throwIfDisposed(), b(this, e);
|
|
97
|
-
}, l().prototype.div = function(e) {
|
|
98
|
-
return this.throwIfDisposed(), u(this, e);
|
|
99
|
-
}, l().prototype.dot = function(e) {
|
|
100
|
-
return this.throwIfDisposed(), Ke(this, e);
|
|
101
|
-
}, l().prototype.elu = function() {
|
|
102
|
-
return this.throwIfDisposed(), r(this);
|
|
103
|
-
}, l().prototype.equal = function(e) {
|
|
104
|
-
return this.throwIfDisposed(), ie(this, e);
|
|
105
|
-
}, l().prototype.erf = function() {
|
|
106
|
-
return this.throwIfDisposed(), Je(this);
|
|
107
|
-
}, l().prototype.euclideanNorm = function(e, t) {
|
|
108
|
-
return this.throwIfDisposed(), Ne(this, e, t);
|
|
109
|
-
}, l().prototype.exp = function() {
|
|
110
|
-
return this.throwIfDisposed(), Ae(this);
|
|
111
|
-
}, l().prototype.expandDims = function(e) {
|
|
112
|
-
return this.throwIfDisposed(), pt(this, e);
|
|
113
|
-
}, l().prototype.expm1 = function() {
|
|
114
|
-
return this.throwIfDisposed(), Ye(this);
|
|
115
|
-
}, l().prototype.fft = function() {
|
|
116
|
-
return this.throwIfDisposed(), p(this);
|
|
117
|
-
}, l().prototype.flatten = function() {
|
|
118
|
-
return this.throwIfDisposed(), G(this, [this.size]);
|
|
119
|
-
}, l().prototype.floor = function() {
|
|
120
|
-
return this.throwIfDisposed(), tt(this);
|
|
121
|
-
}, l().prototype.floorDiv = function(e) {
|
|
122
|
-
return this.throwIfDisposed(), _(this, e);
|
|
123
|
-
}, l().prototype.gather = function(e, t, n) {
|
|
124
|
-
return this.throwIfDisposed(), we(this, e, t, n);
|
|
125
|
-
}, l().prototype.greaterEqual = function(e) {
|
|
126
|
-
return this.throwIfDisposed(), ct(this, e);
|
|
127
|
-
}, l().prototype.greater = function(e) {
|
|
128
|
-
return this.throwIfDisposed(), Ue(this, e);
|
|
129
|
-
}, l().prototype.ifft = function() {
|
|
130
|
-
return this.throwIfDisposed(), ot(this);
|
|
131
|
-
}, l().prototype.irfft = function() {
|
|
132
|
-
return this.throwIfDisposed(), h(this);
|
|
133
|
-
}, l().prototype.isFinite = function() {
|
|
134
|
-
return this.throwIfDisposed(), $e(this);
|
|
135
|
-
}, l().prototype.isInf = function() {
|
|
136
|
-
return this.throwIfDisposed(), ft(this);
|
|
137
|
-
}, l().prototype.isNaN = function() {
|
|
138
|
-
return this.throwIfDisposed(), je(this);
|
|
139
|
-
}, l().prototype.leakyRelu = function(e) {
|
|
140
|
-
return this.throwIfDisposed(), t(this, e);
|
|
141
|
-
}, l().prototype.lessEqual = function(e) {
|
|
142
|
-
return this.throwIfDisposed(), xe(this, e);
|
|
143
|
-
}, l().prototype.less = function(e) {
|
|
144
|
-
return this.throwIfDisposed(), j(this, e);
|
|
145
|
-
}, l().prototype.localResponseNormalization = function(e, t, n, r) {
|
|
146
|
-
return this.throwIfDisposed(), ve(this, e, t, n, r);
|
|
147
|
-
}, l().prototype.logSigmoid = function() {
|
|
148
|
-
return this.throwIfDisposed(), pe(this);
|
|
149
|
-
}, l().prototype.logSoftmax = function(e) {
|
|
150
|
-
return this.throwIfDisposed(), Ct(this, e);
|
|
151
|
-
}, l().prototype.logSumExp = function(e, t) {
|
|
152
|
-
return this.throwIfDisposed(), P(this, e, t);
|
|
153
|
-
}, l().prototype.log = function() {
|
|
154
|
-
return this.throwIfDisposed(), be(this);
|
|
155
|
-
}, l().prototype.log1p = function() {
|
|
156
|
-
return this.throwIfDisposed(), m(this);
|
|
157
|
-
}, l().prototype.logicalAnd = function(e) {
|
|
158
|
-
return this.throwIfDisposed(), y(this, e);
|
|
159
|
-
}, l().prototype.logicalNot = function() {
|
|
160
|
-
return this.throwIfDisposed(), f(this);
|
|
161
|
-
}, l().prototype.logicalOr = function(e) {
|
|
162
|
-
return this.throwIfDisposed(), oe(this, e);
|
|
163
|
-
}, l().prototype.logicalXor = function(e) {
|
|
164
|
-
return this.throwIfDisposed(), k(this, e);
|
|
165
|
-
}, l().prototype.matMul = function(e, t, n) {
|
|
166
|
-
return this.throwIfDisposed(), Le(this, e, t, n);
|
|
167
|
-
}, l().prototype.maxPool = function(e, t, n, r) {
|
|
168
|
-
return this.throwIfDisposed(), w(this, e, t, n, r);
|
|
169
|
-
}, l().prototype.max = function(e, t) {
|
|
170
|
-
return this.throwIfDisposed(), Ee(this, e, t);
|
|
171
|
-
}, l().prototype.maximum = function(e) {
|
|
172
|
-
return this.throwIfDisposed(), qe(this, e);
|
|
173
|
-
}, l().prototype.mean = function(e, t) {
|
|
174
|
-
return this.throwIfDisposed(), i(this, e, t);
|
|
175
|
-
}, l().prototype.min = function(e, t) {
|
|
176
|
-
return this.throwIfDisposed(), _t(this, e, t);
|
|
177
|
-
}, l().prototype.minimum = function(e) {
|
|
178
|
-
return this.throwIfDisposed(), c(this, e);
|
|
179
|
-
}, l().prototype.mirrorPad = function(e, t) {
|
|
180
|
-
return this.throwIfDisposed(), re(this, e, t);
|
|
181
|
-
}, l().prototype.mod = function(e) {
|
|
182
|
-
return this.throwIfDisposed(), I(this, e);
|
|
183
|
-
}, l().prototype.mul = function(e) {
|
|
184
|
-
return this.throwIfDisposed(), ge(this, e);
|
|
185
|
-
}, l().prototype.neg = function() {
|
|
186
|
-
return this.throwIfDisposed(), B(this);
|
|
187
|
-
}, l().prototype.norm = function(e, t, n) {
|
|
188
|
-
return this.throwIfDisposed(), it(this, e, t, n);
|
|
189
|
-
}, l().prototype.notEqual = function(e) {
|
|
190
|
-
return this.throwIfDisposed(), F(this, e);
|
|
191
|
-
}, l().prototype.oneHot = function(e, t = 1, n = 0) {
|
|
192
|
-
return this.throwIfDisposed(), gt(this, e, t, n);
|
|
193
|
-
}, l().prototype.onesLike = function() {
|
|
194
|
-
return this.throwIfDisposed(), De(this);
|
|
195
|
-
}, l().prototype.pad = function(e, t) {
|
|
196
|
-
return this.throwIfDisposed(), yt(this, e, t);
|
|
197
|
-
}, l().prototype.pool = function(e, t, n, r, i, a) {
|
|
198
|
-
return this.throwIfDisposed(), Ce(this, e, t, n, r, i, a);
|
|
199
|
-
}, l().prototype.pow = function(e) {
|
|
200
|
-
return this.throwIfDisposed(), Q(this, e);
|
|
201
|
-
}, l().prototype.prelu = function(e) {
|
|
202
|
-
return this.throwIfDisposed(), Re(this, e);
|
|
203
|
-
}, l().prototype.prod = function(e, t) {
|
|
204
|
-
return this.throwIfDisposed(), He(this, e, t);
|
|
205
|
-
}, l().prototype.reciprocal = function() {
|
|
206
|
-
return this.throwIfDisposed(), Z(this);
|
|
207
|
-
}, l().prototype.relu = function() {
|
|
208
|
-
return this.throwIfDisposed(), Xe(this);
|
|
209
|
-
}, l().prototype.relu6 = function() {
|
|
210
|
-
return this.throwIfDisposed(), ke(this);
|
|
211
|
-
}, l().prototype.reshapeAs = function(e) {
|
|
212
|
-
return this.throwIfDisposed(), G(this, e.shape);
|
|
213
|
-
}, l().prototype.reshape = function(e) {
|
|
214
|
-
return this.throwIfDisposed(), G(this, e);
|
|
215
|
-
}, l().prototype.resizeBilinear = function(e, t, n) {
|
|
216
|
-
return this.throwIfDisposed(), Fe(this, e, t, n);
|
|
217
|
-
}, l().prototype.resizeNearestNeighbor = function(e, t, n) {
|
|
218
|
-
return this.throwIfDisposed(), ze(this, e, t, n);
|
|
219
|
-
}, l().prototype.reverse = function(e) {
|
|
220
|
-
return this.throwIfDisposed(), dt(this, e);
|
|
221
|
-
}, l().prototype.rfft = function() {
|
|
222
|
-
return this.throwIfDisposed(), me(this);
|
|
223
|
-
}, l().prototype.round = function() {
|
|
224
|
-
return this.throwIfDisposed(), rt(this);
|
|
225
|
-
}, l().prototype.rsqrt = function() {
|
|
226
|
-
return this.throwIfDisposed(), Te(this);
|
|
227
|
-
}, l().prototype.selu = function() {
|
|
228
|
-
return this.throwIfDisposed(), Ge(this);
|
|
229
|
-
}, l().prototype.separableConv2d = function(e, t, n, r, i, a) {
|
|
230
|
-
return this.throwIfDisposed(), lt(this, e, t, n, r, i, a);
|
|
231
|
-
}, l().prototype.sigmoid = function() {
|
|
232
|
-
return this.throwIfDisposed(), Ve(this);
|
|
233
|
-
}, l().prototype.sign = function() {
|
|
234
|
-
return this.throwIfDisposed(), et(this);
|
|
235
|
-
}, l().prototype.sin = function() {
|
|
236
|
-
return this.throwIfDisposed(), X(this);
|
|
237
|
-
}, l().prototype.sinh = function() {
|
|
238
|
-
return this.throwIfDisposed(), Me(this);
|
|
239
|
-
}, l().prototype.slice = function(e, t) {
|
|
240
|
-
return this.throwIfDisposed(), Qe(this, e, t);
|
|
241
|
-
}, l().prototype.softmax = function(e) {
|
|
242
|
-
return this.throwIfDisposed(), ye(this, e);
|
|
243
|
-
}, l().prototype.softplus = function() {
|
|
244
|
-
return this.throwIfDisposed(), de(this);
|
|
245
|
-
}, l().prototype.spaceToBatchND = function(e, t) {
|
|
246
|
-
return this.throwIfDisposed(), mt(this, e, t);
|
|
247
|
-
}, l().prototype.split = function(e, t) {
|
|
248
|
-
return this.throwIfDisposed(), se(this, e, t);
|
|
249
|
-
}, l().prototype.sqrt = function() {
|
|
250
|
-
return this.throwIfDisposed(), Ie(this);
|
|
251
|
-
}, l().prototype.square = function() {
|
|
252
|
-
return this.throwIfDisposed(), Be(this);
|
|
253
|
-
}, l().prototype.squaredDifference = function(e) {
|
|
254
|
-
return this.throwIfDisposed(), L(this, e);
|
|
255
|
-
}, l().prototype.squeeze = function(e) {
|
|
256
|
-
return this.throwIfDisposed(), le(this, e);
|
|
257
|
-
}, l().prototype.stack = function(e, t) {
|
|
258
|
-
return this.throwIfDisposed(), V(e instanceof $ ? [this, e] : [this, ...e], t);
|
|
259
|
-
}, l().prototype.step = function(e) {
|
|
260
|
-
return this.throwIfDisposed(), a(this, e);
|
|
261
|
-
}, l().prototype.stridedSlice = function(e, t, n, r, i, a, o, s) {
|
|
262
|
-
return this.throwIfDisposed(), bt(this, e, t, n, r, i, a, o, s);
|
|
263
|
-
}, l().prototype.sub = function(e) {
|
|
264
|
-
return this.throwIfDisposed(), ee(this, e);
|
|
265
|
-
}, l().prototype.sum = function(e, t) {
|
|
266
|
-
return this.throwIfDisposed(), Ze(this, e, t);
|
|
267
|
-
}, l().prototype.tan = function() {
|
|
268
|
-
return this.throwIfDisposed(), M(this);
|
|
269
|
-
}, l().prototype.tanh = function() {
|
|
270
|
-
return this.throwIfDisposed(), at(this);
|
|
271
|
-
}, l().prototype.tile = function(e) {
|
|
272
|
-
return this.throwIfDisposed(), Oe(this, e);
|
|
273
|
-
}, l().prototype.toBool = function() {
|
|
274
|
-
return this.throwIfDisposed(), U(this, "bool");
|
|
275
|
-
}, l().prototype.toFloat = function() {
|
|
276
|
-
return this.throwIfDisposed(), U(this, "float32");
|
|
277
|
-
}, l().prototype.toInt = function() {
|
|
278
|
-
return this.throwIfDisposed(), U(this, "int32");
|
|
279
|
-
}, l().prototype.topk = function(e, t) {
|
|
280
|
-
return this.throwIfDisposed(), n(this, e, t);
|
|
281
|
-
}, l().prototype.transpose = function(e) {
|
|
282
|
-
return this.throwIfDisposed(), ht(this, e);
|
|
283
|
-
}, l().prototype.unique = function(e) {
|
|
284
|
-
return this.throwIfDisposed(), T(this, e);
|
|
285
|
-
}, l().prototype.unsortedSegmentSum = function(e, t) {
|
|
286
|
-
return this.throwIfDisposed(), te(this, e, t);
|
|
287
|
-
}, l().prototype.unstack = function(e) {
|
|
288
|
-
return this.throwIfDisposed(), ne(this, e);
|
|
289
|
-
}, l().prototype.where = function(e, t) {
|
|
290
|
-
return this.throwIfDisposed(), E(e, this, t);
|
|
291
|
-
}, l().prototype.zerosLike = function() {
|
|
292
|
-
return this.throwIfDisposed(), S(this);
|
|
293
|
-
};
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region lib/layers/RoPECache.ts
|
|
296
|
-
var wt = class {
|
|
297
|
-
config;
|
|
298
|
-
rotaryDim;
|
|
299
|
-
ropeBase;
|
|
300
|
-
ropeInvFreq;
|
|
301
|
-
ropeCos = null;
|
|
302
|
-
ropeSin = null;
|
|
303
|
-
ropeNegSin = null;
|
|
304
|
-
ropeCacheLen = 0;
|
|
305
|
-
constructor(e) {
|
|
306
|
-
this.config = e;
|
|
307
|
-
let t = this.config.nEmbed / this.config.nHead;
|
|
308
|
-
if (this.rotaryDim = t, this.rotaryDim % 2 != 0) throw Error("rotaryDim must be even");
|
|
309
|
-
this.ropeBase = 1e4;
|
|
310
|
-
let n = J(0, this.rotaryDim, 2, "float32"), r = u(n, W(this.rotaryDim, "float32")), i = Q(W(this.ropeBase, "float32"), r);
|
|
311
|
-
this.ropeInvFreq = Z(i), r.dispose(), i.dispose(), n.dispose(), (this.config.modelType === "GenAI_NanoGPT_v1" ? this.config.useRope ?? !0 : !0) === !1 ? (this.ropeCos = null, this.ropeSin = null, this.ropeNegSin = null, this.ropeCacheLen = 0) : K(() => {
|
|
312
|
-
this.ensureRopeCache(this.config.blockSize * 4);
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
ensureRopeCache(e) {
|
|
316
|
-
K(() => {
|
|
317
|
-
if (e <= this.ropeCacheLen) return;
|
|
318
|
-
this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose();
|
|
319
|
-
let t = Math.max(e, this.ropeCacheLen + this.config.blockSize * 4), n = J(0, t, 1, "float32").expandDims(1).mul(this.ropeInvFreq.expandDims(0));
|
|
320
|
-
this.ropeCos = Y(g(n).expandDims(-1)), this.ropeSin = Y(X(n).expandDims(-1)), this.ropeNegSin = Y(this.ropeSin.neg()), this.ropeCacheLen = t;
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
getCos() {
|
|
324
|
-
return this.ropeCos;
|
|
325
|
-
}
|
|
326
|
-
getSin() {
|
|
327
|
-
return this.ropeSin;
|
|
328
|
-
}
|
|
329
|
-
getNegSin() {
|
|
330
|
-
return this.ropeNegSin;
|
|
331
|
-
}
|
|
332
|
-
dispose() {
|
|
333
|
-
this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose(), this.ropeInvFreq.dispose();
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
//#endregion
|
|
337
|
-
export { wt as default };
|
|
1
|
+
export { t as default } from "../RoPECache-dYscFINl.js";
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { n as e } from "../dist-DyL7qSLJ.js";
|
|
2
|
+
import "../dist-CMMLi-qO.js";
|
|
3
|
+
import { t } from "../gather-B5Z1RFt5.js";
|
|
4
|
+
import { n } from "../picomatch--TW6gyBJ.js";
|
|
5
|
+
import r from "./BaseLayer.js";
|
|
6
|
+
import { dot16 as i } from "../ops/dot16.js";
|
|
7
|
+
import { isPackedTensor as a } from "../utilities/packed.js";
|
|
8
|
+
import { t as o } from "../pack16-BHO4t1-M.js";
|
|
9
|
+
import { transpose16 as s } from "../ops/transpose16.js";
|
|
10
|
+
// lib/layers/TiedEmbedding.ts
|
|
11
|
+
var c = class extends r {
|
|
10
12
|
vocabSize;
|
|
11
13
|
embedDim;
|
|
12
14
|
initializer;
|
|
13
15
|
WEIGHTS;
|
|
14
16
|
constructor(t, r, i) {
|
|
15
|
-
super(t, i), this.WEIGHTS = r, this.vocabSize = t.vocabSize, this.embedDim = t.nEmbed, this.initializer =
|
|
17
|
+
super(t, i), this.WEIGHTS = r, this.vocabSize = t.vocabSize, this.embedDim = t.nEmbed, this.initializer = e({
|
|
16
18
|
mean: 0,
|
|
17
19
|
stddev: .02
|
|
18
|
-
}), this.addVariable(this.WEIGHTS,
|
|
20
|
+
}), this.addVariable(this.WEIGHTS, n(this.initializer.apply([this.vocabSize, this.embedDim]), !0, r));
|
|
19
21
|
}
|
|
20
22
|
embed(e) {
|
|
21
23
|
return t(this.getVariable(this.WEIGHTS), e, 0);
|
|
22
24
|
}
|
|
23
25
|
project(e) {
|
|
24
|
-
let t =
|
|
25
|
-
return
|
|
26
|
+
let t = a(e) ? o(this.getVariable(this.WEIGHTS), void 0, 32) : this.getVariable(this.WEIGHTS), n = s(t);
|
|
27
|
+
return a(e) && t.dispose(), i(e, n);
|
|
26
28
|
}
|
|
27
29
|
forward(e, t) {
|
|
28
30
|
return this.project(t);
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
|
-
//#endregion
|
|
32
33
|
export { c as default };
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MHAConfig, AttentionForwardAttributes } from './MHA';
|
|
2
2
|
import { MLPConfig } from './MLP';
|
|
3
3
|
import { RMSNormConfig } from './RMSNorm';
|
|
4
|
-
import { default as BaseLayer
|
|
4
|
+
import { default as BaseLayer } from './BaseLayer';
|
|
5
5
|
import { Tensor } from '@tensorflow/tfjs-core';
|
|
6
6
|
import { GPTConfig } from '../../models/config';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
seed?: number;
|
|
10
|
-
attentionScores?: AttentionScores;
|
|
11
|
-
ropePositionOffset?: number;
|
|
12
|
-
}
|
|
13
|
-
export type TransformerBlockConfig = MLPConfig & RMSNormConfig & CausalSelfAttentionConfig;
|
|
7
|
+
export type BlockAttributes = AttentionForwardAttributes;
|
|
8
|
+
export type TransformerBlockConfig = MLPConfig & RMSNormConfig & MHAConfig;
|
|
14
9
|
export default class Block extends BaseLayer<BlockAttributes> {
|
|
15
10
|
private ln1;
|
|
16
11
|
private attn;
|
|
@@ -24,4 +19,3 @@ export default class Block extends BaseLayer<BlockAttributes> {
|
|
|
24
19
|
forward(attrs: BlockAttributes, x: Tensor): Tensor;
|
|
25
20
|
dispose(): void;
|
|
26
21
|
}
|
|
27
|
-
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import a from "
|
|
1
|
+
import e from "./MHA.js";
|
|
2
|
+
import t from "./MLP.js";
|
|
3
|
+
import n from "./RMSNorm.js";
|
|
4
|
+
import r from "./BaseLayer.js";
|
|
5
|
+
import { W as i, Y as a } from "../dist-CMMLi-qO.js";
|
|
6
6
|
import { add16 as o } from "../ops/add16.js";
|
|
7
|
-
|
|
8
|
-
var s = class extends
|
|
7
|
+
// lib/layers/TransformerBlock.ts
|
|
8
|
+
var s = class extends r {
|
|
9
9
|
ln1;
|
|
10
10
|
attn;
|
|
11
11
|
ln2;
|
|
@@ -13,39 +13,38 @@ var s = class extends n {
|
|
|
13
13
|
index;
|
|
14
14
|
skipped = !1;
|
|
15
15
|
blockConfig;
|
|
16
|
-
constructor(
|
|
17
|
-
super(
|
|
16
|
+
constructor(r, i, a, o) {
|
|
17
|
+
super(i, o), this.index = r, this.blockConfig = a, this.ln1 = new n(i, this.blockConfig, `block_${this.index}_rms1`, this), this.attn = new e(this.index, i, this.blockConfig, this), this.ln2 = new n(i, this.blockConfig, `block_${this.index}_rms2`, this), this.mlp = new t(this.index, i, this.blockConfig, this);
|
|
18
18
|
}
|
|
19
|
-
getMLPOutput(e,
|
|
20
|
-
let
|
|
21
|
-
|
|
19
|
+
getMLPOutput(e, t) {
|
|
20
|
+
let n = this.ln2.call({ training: t.training }, e), r = this.mlp.call(t, n);
|
|
21
|
+
t.outputEmbeddings ? (i(n), t.embeddings.push({
|
|
22
22
|
name: `block_ln2_${this.index}`,
|
|
23
|
-
tensor:
|
|
24
|
-
})) :
|
|
25
|
-
let a = o(e,
|
|
26
|
-
return e.dispose(),
|
|
23
|
+
tensor: n
|
|
24
|
+
})) : n.dispose();
|
|
25
|
+
let a = o(e, r);
|
|
26
|
+
return e.dispose(), t.outputEmbeddings ? (i(r), t.embeddings.push({
|
|
27
27
|
name: `block_mlp_out_${this.index}`,
|
|
28
|
-
tensor:
|
|
29
|
-
})) :
|
|
28
|
+
tensor: r
|
|
29
|
+
})) : r.dispose(), a;
|
|
30
30
|
}
|
|
31
|
-
forward(
|
|
32
|
-
return
|
|
33
|
-
if (this.skipped) return
|
|
34
|
-
let
|
|
35
|
-
|
|
31
|
+
forward(e, t) {
|
|
32
|
+
return a(() => {
|
|
33
|
+
if (this.skipped) return t;
|
|
34
|
+
let n = this.ln1.call(e, t), r = this.attn.call(e, n);
|
|
35
|
+
e.outputEmbeddings ? (i(n), e.embeddings.push({
|
|
36
36
|
name: `block_ln1_${this.index}`,
|
|
37
|
-
tensor:
|
|
38
|
-
})) :
|
|
39
|
-
let a = o(
|
|
40
|
-
return
|
|
37
|
+
tensor: n
|
|
38
|
+
})) : n.dispose();
|
|
39
|
+
let a = o(t, r);
|
|
40
|
+
return e.outputEmbeddings ? (i(r), e.embeddings.push({
|
|
41
41
|
name: `block_attn_out_${this.index}`,
|
|
42
|
-
tensor:
|
|
43
|
-
})) :
|
|
42
|
+
tensor: r
|
|
43
|
+
})) : r.dispose(), this.getMLPOutput(a, e);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
dispose() {
|
|
47
47
|
this.ln1.dispose(), this.attn.dispose(), this.ln2.dispose(), this.mlp.dispose();
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
//#endregion
|
|
51
50
|
export { s as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as e } from "../
|
|
2
|
-
import {
|
|
3
|
-
import { t as r } from "../picomatch
|
|
4
|
-
|
|
1
|
+
import { i as e } from "../rolldown-runtime-CwxnZyOB.js";
|
|
2
|
+
import { M as t } from "../dist-CMMLi-qO.js";
|
|
3
|
+
import { n, t as r } from "../picomatch--TW6gyBJ.js";
|
|
4
|
+
// lib/layers/WeightStore.ts
|
|
5
5
|
var i = /* @__PURE__ */ e(r(), 1), a = class {
|
|
6
6
|
_variables = /* @__PURE__ */ new Map();
|
|
7
7
|
touchedVariables = /* @__PURE__ */ new Set();
|
|
@@ -65,5 +65,4 @@ var i = /* @__PURE__ */ e(r(), 1), a = class {
|
|
|
65
65
|
}), this._variables.clear();
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
//#endregion
|
|
69
68
|
export { a as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as e } from "./rolldown-runtime-CwxnZyOB.js";
|
|
2
|
+
import t from "./layers/MHA.js";
|
|
3
|
+
import n from "./layers/MLP.js";
|
|
4
|
+
import r from "./layers/TransformerBlock.js";
|
|
5
|
+
import { t as i } from "./RoPECache-dYscFINl.js";
|
|
6
|
+
// lib/layers.ts
|
|
7
|
+
var a = /* @__PURE__ */ e({
|
|
8
|
+
CausalSelfAttention: () => t,
|
|
9
|
+
MLP: () => n,
|
|
10
|
+
RoPECache: () => i,
|
|
11
|
+
TransformerBlock: () => r
|
|
12
|
+
});
|
|
13
|
+
export { a as t };
|
package/dist/layers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as CausalSelfAttention } from './layers/
|
|
1
|
+
export { default as CausalSelfAttention } from './layers/MHA';
|
|
2
2
|
export { default as MLP } from './layers/MLP';
|
|
3
3
|
export { default as TransformerBlock } from './layers/TransformerBlock';
|
|
4
4
|
export { default as RoPECache } from './layers/RoPECache';
|
package/dist/layers.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import t from "./layers/
|
|
1
|
+
import { t as e } from "./RoPECache-dYscFINl.js";
|
|
2
|
+
import t from "./layers/MHA.js";
|
|
3
3
|
import n from "./layers/MLP.js";
|
|
4
4
|
import r from "./layers/TransformerBlock.js";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
var a = /* @__PURE__ */ e({
|
|
8
|
-
CausalSelfAttention: () => t,
|
|
9
|
-
MLP: () => n,
|
|
10
|
-
RoPECache: () => i,
|
|
11
|
-
TransformerBlock: () => r
|
|
12
|
-
});
|
|
13
|
-
//#endregion
|
|
14
|
-
export { t as CausalSelfAttention, n as MLP, i as RoPECache, r as TransformerBlock, a as t };
|
|
5
|
+
import "./layers-CFqEip3s.js";
|
|
6
|
+
export { t as CausalSelfAttention, n as MLP, e as RoPECache, r as TransformerBlock };
|
package/dist/loader/load.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { i as e } from "../
|
|
2
|
-
import { t } from "../jszip.min-
|
|
3
|
-
import
|
|
4
|
-
import r from "./
|
|
5
|
-
import i from "./
|
|
6
|
-
import a from "./
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
import { i as e } from "../rolldown-runtime-CwxnZyOB.js";
|
|
2
|
+
import { t } from "../jszip.min-Btv48m44.js";
|
|
3
|
+
import n from "./oldZipLoad.js";
|
|
4
|
+
import r from "./newZipLoad.js";
|
|
5
|
+
import i from "./loadHF.js";
|
|
6
|
+
import { loadZipMeta as a } from "./loadZipMeta.js";
|
|
7
|
+
import { load_safetensors as o } from "../utilities/safetensors.js";
|
|
8
|
+
// lib/loader/load.ts
|
|
9
9
|
var s = /* @__PURE__ */ e(t(), 1), c = 2;
|
|
10
10
|
async function l(e) {
|
|
11
11
|
let t = await fetch(e);
|
|
12
12
|
if (!t.ok) throw Error(`Failed to fetch ${e}: ${t.statusText}`);
|
|
13
13
|
return t.arrayBuffer();
|
|
14
14
|
}
|
|
15
|
-
async function u(e, t,
|
|
16
|
-
let
|
|
17
|
-
if (!
|
|
18
|
-
let
|
|
19
|
-
for (let [e, t] of Object.entries(a))
|
|
20
|
-
t.weightStore.loadWeights(
|
|
15
|
+
async function u(e, t, n) {
|
|
16
|
+
let r = e.file("model.safetensors");
|
|
17
|
+
if (!r) return;
|
|
18
|
+
let i = await r.async("arraybuffer"), a = await o(i), s = /* @__PURE__ */ new Map();
|
|
19
|
+
for (let [e, t] of Object.entries(a)) s.set(e, [t]);
|
|
20
|
+
t.weightStore.loadWeights(s, n);
|
|
21
21
|
}
|
|
22
22
|
async function d(e, t) {
|
|
23
23
|
let n = e.file("config.json");
|
|
@@ -40,21 +40,24 @@ async function f(e, t) {
|
|
|
40
40
|
...t
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
}
|
|
44
|
+
if (e.file("manifest.json")) return n(e, t);
|
|
45
|
+
{
|
|
46
|
+
let n = await r(e, t);
|
|
46
47
|
return n.model.config.loraName && n.model.attachLoRA(n.model.config.loraName), n;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
async function p(e, t) {
|
|
50
|
-
if (typeof e == "string")
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
if (typeof e == "string") {
|
|
52
|
+
if (e.startsWith("http://") || e.startsWith("https://")) {
|
|
53
|
+
let t = await l(e), n = await s.default.loadAsync(t), r = await a(n);
|
|
54
|
+
return r.url = e, f(n, r);
|
|
55
|
+
}
|
|
56
|
+
return i(e);
|
|
57
|
+
}
|
|
58
|
+
{
|
|
59
|
+
let n = await s.default.loadAsync(e), r = await a(n);
|
|
56
60
|
return r.url = t?.sourceURL || void 0, f(n, r);
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
|
-
//#endregion
|
|
60
63
|
export { c as VERSION, p as loadModel };
|
package/dist/loader/loadHF.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "./loadTransformers.js";
|
|
2
|
-
|
|
2
|
+
// lib/loader/loadHF.ts
|
|
3
3
|
async function t(t) {
|
|
4
4
|
let n = `https://huggingface.co/${t}/resolve/main/config.json`, r = `https://huggingface.co/${t}/resolve/main/tokeniser.json`, i = `https://huggingface.co/${t}/resolve/main/meta.json`, a = `https://huggingface.co/${t}/resolve/main/model.safetensors`, [o, s, c, l] = await Promise.all([
|
|
5
5
|
fetch(n),
|
|
@@ -11,7 +11,7 @@ async function t(t) {
|
|
|
11
11
|
if (!s.ok) throw Error(`Failed to fetch tokeniser from ${r}: ${s.statusText}`);
|
|
12
12
|
if (!c.ok) throw Error(`Failed to fetch meta from ${i}: ${c.statusText}`);
|
|
13
13
|
if (!l.ok) throw Error(`Failed to fetch weights from ${a}: ${l.statusText}`);
|
|
14
|
-
|
|
14
|
+
let u = await o.json(), d = await s.json(), f = await c.json(), p = await l.arrayBuffer();
|
|
15
|
+
return e(u, d, f, p);
|
|
15
16
|
}
|
|
16
|
-
//#endregion
|
|
17
17
|
export { t as default };
|