@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,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t as
|
|
3
|
-
import
|
|
4
|
-
import { createTensorStatistics as
|
|
5
|
-
import { calculateLoss as
|
|
1
|
+
import S from "./Evaluator.js";
|
|
2
|
+
import { t as k, v as x, k as y, d as u, a as w } from "../index-CUXkjxiT.js";
|
|
3
|
+
import v from "../utilities/profile.js";
|
|
4
|
+
import { createTensorStatistics as N } from "../checks/weights.js";
|
|
5
|
+
import { calculateLoss as b, calculateAccuracy as P } from "./loss.js";
|
|
6
6
|
import { AdamWOptimizer as T } from "./AdamW.js";
|
|
7
|
-
import { z as
|
|
7
|
+
import { z as L } from "../zeros-DvZpK8s6.js";
|
|
8
8
|
const z = {
|
|
9
9
|
logInterval: 1,
|
|
10
10
|
maxEpochs: 100,
|
|
@@ -22,15 +22,15 @@ const z = {
|
|
|
22
22
|
minLearningRate: 1e-5,
|
|
23
23
|
lossScaling: 1
|
|
24
24
|
};
|
|
25
|
-
class
|
|
26
|
-
constructor(s,
|
|
27
|
-
this.tokenizer =
|
|
25
|
+
class B {
|
|
26
|
+
constructor(s, i, n, l) {
|
|
27
|
+
this.tokenizer = i, this.model = s, this.optimizerConfig = {
|
|
28
28
|
...D,
|
|
29
29
|
...n,
|
|
30
30
|
lossScaling: s.lossScaling
|
|
31
31
|
};
|
|
32
|
-
const
|
|
33
|
-
l && l.updateConfig(this.optimizerConfig), this.optimizer =
|
|
32
|
+
const d = l || new T(this.optimizerConfig);
|
|
33
|
+
l && l.updateConfig(this.optimizerConfig), this.optimizer = d;
|
|
34
34
|
}
|
|
35
35
|
model;
|
|
36
36
|
optimizer;
|
|
@@ -44,6 +44,9 @@ class G {
|
|
|
44
44
|
_labelSmoothing = 0;
|
|
45
45
|
_layerDrop = 0;
|
|
46
46
|
_dropout = 0;
|
|
47
|
+
setLossMasking() {
|
|
48
|
+
this.maskedLoss = !0;
|
|
49
|
+
}
|
|
47
50
|
setGradientCheckpointing(s) {
|
|
48
51
|
this._gradientCheckpointing = s;
|
|
49
52
|
}
|
|
@@ -92,44 +95,45 @@ class G {
|
|
|
92
95
|
});
|
|
93
96
|
}
|
|
94
97
|
// A single forward pass, backward pass, and optimizer step
|
|
95
|
-
trainStep(s,
|
|
96
|
-
return
|
|
98
|
+
trainStep(s, i, n = !1, l = !1) {
|
|
99
|
+
return k(() => {
|
|
97
100
|
this.model.getProfiler()?.startMemory();
|
|
98
|
-
const { xs:
|
|
99
|
-
const
|
|
101
|
+
const { xs: d, ys: r } = i, m = () => {
|
|
102
|
+
const a = this.model.forward(
|
|
100
103
|
{
|
|
101
104
|
training: !0,
|
|
102
105
|
checkpointing: this._gradientCheckpointing,
|
|
103
106
|
mixedPrecision: this._mixedPrecision,
|
|
104
107
|
dropout: this._dropout,
|
|
105
|
-
layerDrop: this._layerDrop
|
|
108
|
+
layerDrop: this._layerDrop,
|
|
109
|
+
ropePositionOffset: 0
|
|
106
110
|
},
|
|
107
|
-
|
|
108
|
-
), o =
|
|
109
|
-
this.metrics.has("accuracy") && (s.accuracy = P(
|
|
110
|
-
const
|
|
111
|
-
return o.dispose(),
|
|
112
|
-
}, { value: t, grads: c } =
|
|
111
|
+
d
|
|
112
|
+
), o = b(a, r, this.maskedLoss, !1, this._labelSmoothing);
|
|
113
|
+
this.metrics.has("accuracy") && (s.accuracy = P(a, r), y(s.accuracy)), a.dispose();
|
|
114
|
+
const e = o.mul(w(this.optimizerConfig.lossScaling));
|
|
115
|
+
return o.dispose(), e;
|
|
116
|
+
}, { value: t, grads: c } = x(m);
|
|
113
117
|
if (n)
|
|
114
118
|
this.model.getProfiler()?.endMemory("Training");
|
|
115
119
|
else {
|
|
116
|
-
const
|
|
117
|
-
this.metrics.has("gradientNorm") ? (s.gradientNorm =
|
|
120
|
+
const a = this.optimizer.applyGradients(c);
|
|
121
|
+
this.metrics.has("gradientNorm") ? (s.gradientNorm = a, y(a)) : (s.gradientNorm = void 0, a.dispose());
|
|
118
122
|
const o = Object.keys(c);
|
|
119
|
-
this.model.weightStore.touchVariables(o), this.model.getProfiler()?.endMemory("Training"), l ? (s.gradients = c, Object.values(c).forEach((
|
|
123
|
+
this.model.weightStore.touchVariables(o), this.model.getProfiler()?.endMemory("Training"), l ? (s.gradients = c, Object.values(c).forEach((e) => y(e))) : u(c);
|
|
120
124
|
}
|
|
121
|
-
return t.mul(
|
|
125
|
+
return t.mul(w(1 / this.optimizerConfig.lossScaling));
|
|
122
126
|
});
|
|
123
127
|
}
|
|
124
128
|
async dummyPass() {
|
|
125
|
-
const s =
|
|
129
|
+
const s = L([1, this.model.config.blockSize], "int32"), i = L([1, this.model.config.blockSize], "int32");
|
|
126
130
|
try {
|
|
127
|
-
const n = this.trainStep({}, { xs: s, ys:
|
|
131
|
+
const n = this.trainStep({}, { xs: s, ys: i }, !0);
|
|
128
132
|
await n.data(), n.dispose();
|
|
129
133
|
} catch (n) {
|
|
130
134
|
console.error("Error during dummy pass:", n);
|
|
131
135
|
} finally {
|
|
132
|
-
s.dispose(),
|
|
136
|
+
s.dispose(), i.dispose();
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
dispose() {
|
|
@@ -147,40 +151,46 @@ class G {
|
|
|
147
151
|
...this.lastState || {}
|
|
148
152
|
};
|
|
149
153
|
}
|
|
150
|
-
async stepDataset(s,
|
|
154
|
+
async stepDataset(s, i, n) {
|
|
151
155
|
const { logInterval: l = 10 } = {
|
|
152
156
|
...z,
|
|
153
|
-
...
|
|
157
|
+
...i
|
|
154
158
|
};
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
this.lastState =
|
|
158
|
-
const
|
|
159
|
+
i.metrics && this.setMetrics(i.metrics);
|
|
160
|
+
const d = Date.now(), r = this.createEmptyState();
|
|
161
|
+
this.lastState = r, await this.dummyPass(), this.metrics.has("memoryUsage") && (this.model.getProfiler() || this.model.setProfiler(new v())), this.running = !0, r.logStartTime = d;
|
|
162
|
+
const m = n ? new S(this.model, n, this.maskedLoss) : void 0, t = await s.iterator();
|
|
159
163
|
try {
|
|
160
164
|
for (; this.running; ) {
|
|
161
165
|
const c = await t.next();
|
|
162
166
|
if (c.done) break;
|
|
163
|
-
const
|
|
164
|
-
|
|
167
|
+
const a = c.value, o = this.trainStep(r, a, !1);
|
|
168
|
+
if (i.debug) {
|
|
169
|
+
const e = (await o.data())[0];
|
|
170
|
+
if (isNaN(e) || !isFinite(e))
|
|
171
|
+
throw console.error("Invalid loss value:", e), console.error("Batch xs:", a.xs.toString()), console.error("Batch ys:", a.ys.toString()), console.error("State:", r), new Error("Loss is NaN or Infinity");
|
|
172
|
+
console.log(`Step ${r.step}: Loss = ${e}`);
|
|
173
|
+
}
|
|
174
|
+
a.xs.dispose(), a.ys.dispose(), r.step++, r.totalSteps++, r.step % l === 0 ? await this.performLogging(o, a.xs.shape[0], i, m) : (r.gradientNorm && (r.gradientNorm.dispose(), r.gradientNorm = void 0), r.accuracy && (r.accuracy.dispose(), r.accuracy = void 0)), o.dispose();
|
|
165
175
|
}
|
|
166
176
|
} catch (c) {
|
|
167
177
|
throw console.error("Training error:", c), c;
|
|
168
178
|
}
|
|
169
179
|
throw this.model.trainingState = {
|
|
170
|
-
steps:
|
|
180
|
+
steps: r.totalSteps,
|
|
171
181
|
learningRate: this.optimizer.lr,
|
|
172
|
-
batchSize:
|
|
173
|
-
loss:
|
|
174
|
-
tokensProcessed:
|
|
175
|
-
duration:
|
|
176
|
-
},
|
|
177
|
-
}
|
|
178
|
-
async performLogging(s,
|
|
179
|
-
const
|
|
180
|
-
t.lastLoss =
|
|
182
|
+
batchSize: i.batchSize || 32,
|
|
183
|
+
loss: r.lastLoss,
|
|
184
|
+
tokensProcessed: r.totalSteps * (i.batchSize || 32) * this.model.config.blockSize,
|
|
185
|
+
duration: r.trainingDuration
|
|
186
|
+
}, u(), this.running = !1, new Error("No log returned before training stopped.");
|
|
187
|
+
}
|
|
188
|
+
async performLogging(s, i, n, l) {
|
|
189
|
+
const d = n?.onStep, r = this.metrics.has("gradientStatistics"), m = (await s.data())[0], t = this.lastState;
|
|
190
|
+
t.lastLoss = m;
|
|
181
191
|
const c = Date.now();
|
|
182
192
|
t.trainingDuration += c - t.logStartTime;
|
|
183
|
-
const
|
|
193
|
+
const a = t.totalSteps * i * this.model.config.blockSize, o = {
|
|
184
194
|
trainingMetrics: {
|
|
185
195
|
loss: t.lastLoss,
|
|
186
196
|
perplexity: this.metrics.has("perplexity") ? Math.exp(t.lastLoss) : void 0,
|
|
@@ -189,61 +199,67 @@ class G {
|
|
|
189
199
|
step: t.step,
|
|
190
200
|
time: Date.now() - t.logStartTime,
|
|
191
201
|
gradientNorm: t.gradientNorm ? (await t.gradientNorm.data())[1] : void 0,
|
|
192
|
-
batchSize:
|
|
202
|
+
batchSize: i,
|
|
193
203
|
learningRate: this.metrics.has("learningRate") ? this.optimizer.lr : void 0,
|
|
194
204
|
duration: t.trainingDuration,
|
|
195
|
-
totalTokens:
|
|
196
|
-
tokensPerSecond:
|
|
205
|
+
totalTokens: a,
|
|
206
|
+
tokensPerSecond: a / (t.trainingDuration / 1e3),
|
|
197
207
|
memoryUsage: this.metrics.has("memoryUsage") ? this.model.getProfiler()?.getPeakMemory() || 0 : void 0
|
|
198
208
|
};
|
|
199
209
|
if (t.gradientNorm && (t.gradientNorm.dispose(), t.gradientNorm = void 0), t.accuracy && (t.accuracy.dispose(), t.accuracy = void 0), this.model.trainingState = {
|
|
200
210
|
steps: t.totalSteps,
|
|
201
211
|
learningRate: this.optimizer.lr,
|
|
202
|
-
batchSize:
|
|
212
|
+
batchSize: i,
|
|
203
213
|
loss: t.lastLoss,
|
|
204
|
-
tokensProcessed:
|
|
214
|
+
tokensProcessed: a,
|
|
205
215
|
duration: t.trainingDuration
|
|
206
|
-
},
|
|
207
|
-
const
|
|
216
|
+
}, r && t.gradients) {
|
|
217
|
+
const e = /* @__PURE__ */ new Map();
|
|
208
218
|
for (const [h, g] of Object.entries(t.gradients))
|
|
209
|
-
|
|
210
|
-
o.gradientMetrics =
|
|
219
|
+
e.set(h, await N(g)), g.dispose();
|
|
220
|
+
o.gradientMetrics = e;
|
|
211
221
|
}
|
|
212
222
|
if (l)
|
|
213
223
|
try {
|
|
214
|
-
const
|
|
215
|
-
Array.isArray(
|
|
216
|
-
accuracy:
|
|
217
|
-
loss:
|
|
218
|
-
perplexity: this.metrics.has("perplexity") ? Math.exp(
|
|
224
|
+
const e = await l.evaluate(5);
|
|
225
|
+
Array.isArray(e) ? o.validationMetrics = { loss: e[0].loss, accuracy: e[0].accuracy } : (t.validationLosses.push(e.loss), o.validationMetrics = {
|
|
226
|
+
accuracy: e.accuracy,
|
|
227
|
+
loss: e.loss,
|
|
228
|
+
perplexity: this.metrics.has("perplexity") ? Math.exp(e.loss) : void 0
|
|
219
229
|
});
|
|
220
|
-
} catch (
|
|
221
|
-
console.error("Validation error:",
|
|
230
|
+
} catch (e) {
|
|
231
|
+
console.error("Validation error:", e);
|
|
222
232
|
}
|
|
223
|
-
|
|
233
|
+
d && await d(o), t.logStartTime = Date.now();
|
|
224
234
|
}
|
|
225
|
-
async trainOnDataset(s,
|
|
226
|
-
const { logInterval: l = 10, maxEpochs:
|
|
235
|
+
async trainOnDataset(s, i, n) {
|
|
236
|
+
const { logInterval: l = 10, maxEpochs: d = 1 / 0 } = {
|
|
227
237
|
...z,
|
|
228
|
-
...
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
this.lastState = t, await this.dummyPass(),
|
|
233
|
-
const c = n ? new
|
|
238
|
+
...i
|
|
239
|
+
}, r = d * (i?.epochSteps || 1e3);
|
|
240
|
+
i.metrics && this.setMetrics(i.metrics);
|
|
241
|
+
const m = Date.now(), t = this.createEmptyState();
|
|
242
|
+
this.lastState = t, await this.dummyPass(), i?.metrics?.includes("memoryUsage") && (this.model.getProfiler() || this.model.setProfiler(new v())), this.running = !0, t.logStartTime = m;
|
|
243
|
+
const c = n ? new S(this.model, n, this.maskedLoss) : void 0, a = await s.iterator();
|
|
234
244
|
try {
|
|
235
245
|
for (; this.running; ) {
|
|
236
|
-
const o = await
|
|
246
|
+
const o = await a.next();
|
|
237
247
|
if (o.done) break;
|
|
238
|
-
const
|
|
239
|
-
|
|
248
|
+
const e = o.value, h = t.step % l === 0, g = (i?.metrics?.includes("gradientStatistics") || !1) && h, f = this.trainStep(t, e, !1, g);
|
|
249
|
+
if (i.debug) {
|
|
250
|
+
const p = (await f.data())[0];
|
|
251
|
+
if (isNaN(p) || !isFinite(p))
|
|
252
|
+
throw console.error("Invalid loss value:", p), console.error("Batch xs:", await e.xs.array()), console.error("Batch ys:", await e.ys.array()), console.error("State:", t), new Error("Loss is NaN or Infinity");
|
|
253
|
+
console.log(`Step ${t.step}: Loss = ${p}`);
|
|
254
|
+
}
|
|
255
|
+
e.xs.dispose(), e.ys.dispose(), t.step++, t.totalSteps++, h ? await this.performLogging(f, e.xs.shape[0], i, c) : (t.gradientNorm && (t.gradientNorm.dispose(), t.gradientNorm = void 0), t.accuracy && (t.accuracy.dispose(), t.accuracy = void 0)), f.dispose(), t.step >= r && this.stop();
|
|
240
256
|
}
|
|
241
257
|
} catch (o) {
|
|
242
|
-
throw console.error("Training error:", o),
|
|
258
|
+
throw console.error("Training error:", o), u(), o;
|
|
243
259
|
}
|
|
244
|
-
return
|
|
260
|
+
return u(), this.running = !1, { losses: t.losses, validationLosses: t.validationLosses };
|
|
245
261
|
}
|
|
246
262
|
}
|
|
247
263
|
export {
|
|
248
|
-
|
|
264
|
+
B as default
|
|
249
265
|
};
|
|
@@ -2,7 +2,11 @@ import { Tensor } from '@tensorflow/tfjs-core';
|
|
|
2
2
|
import { Conversation, ITokeniser } from '../tokeniser/type';
|
|
3
3
|
import { Dataset } from '@tensorflow/tfjs-data';
|
|
4
4
|
export declare const PAGE_FACTOR = 8;
|
|
5
|
-
export declare function flattenTokens(textData: Conversation[][], tokenizer: ITokeniser):
|
|
5
|
+
export declare function flattenTokens(textData: Conversation[][], tokenizer: ITokeniser): Uint16Array;
|
|
6
|
+
export declare function flattenTokensWithMask(textData: Conversation[][], tokenizer: ITokeniser): {
|
|
7
|
+
tokens: Uint16Array;
|
|
8
|
+
mask: Uint8Array;
|
|
9
|
+
};
|
|
6
10
|
export declare function shuffle(array: Uint32Array): Uint32Array;
|
|
7
11
|
export interface DatasetState {
|
|
8
12
|
shuffledIndexes: Uint32Array;
|
|
@@ -12,7 +16,7 @@ export declare class DatasetBuilder {
|
|
|
12
16
|
tokenizer: ITokeniser;
|
|
13
17
|
blockSize: number;
|
|
14
18
|
constructor(tokenizer: ITokeniser, blockSize?: number);
|
|
15
|
-
createTextDataset(flatTokens: Uint16Array, batchSize?: number, indexes?: Uint32Array): Promise<{
|
|
19
|
+
createTextDataset(flatTokens: Uint16Array, batchSize?: number, indexes?: Uint32Array, mask?: Uint8Array, ignoreIndex?: number): Promise<{
|
|
16
20
|
dataset: Dataset<{
|
|
17
21
|
xs: Tensor;
|
|
18
22
|
ys: Tensor;
|
|
@@ -1,67 +1,86 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import "../dataset-
|
|
3
|
-
import { g as a } from "../readers-17HLdxVM.js";
|
|
1
|
+
import { t as x } from "../index-CUXkjxiT.js";
|
|
2
|
+
import { d as g, i as m } from "../dataset-CGGp1z9P.js";
|
|
4
3
|
import "../index-Cp39cXWe.js";
|
|
5
|
-
|
|
6
|
-
async
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
function p(e) {
|
|
5
|
+
return g(async () => {
|
|
6
|
+
const t = await e();
|
|
7
|
+
return m(() => t.next());
|
|
8
|
+
});
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const I = 8;
|
|
11
|
+
function z(e, t) {
|
|
12
|
+
const r = e.map((c) => t.encodeConversation(c)).flat();
|
|
13
|
+
return new Uint16Array(r);
|
|
14
|
+
}
|
|
15
|
+
function A(e, t) {
|
|
16
|
+
const s = e.map((i) => t.encodeConversation(i, !1, !0));
|
|
17
|
+
console.log("Tokenised Texts with Mask:", s);
|
|
18
|
+
const r = s.map((i) => i.tokens).flat(), c = s.map((i) => i.mask).flat();
|
|
19
|
+
return { tokens: new Uint16Array(r), mask: new Uint8Array(c.map((i) => i ? 1 : 0)) };
|
|
20
|
+
}
|
|
21
|
+
function u(e) {
|
|
22
|
+
for (let t = e.length - 1; t > 0; t--) {
|
|
23
|
+
const s = Math.floor(Math.random() * (t + 1));
|
|
24
|
+
[e[t], e[s]] = [e[s], e[t]];
|
|
14
25
|
}
|
|
15
|
-
return
|
|
26
|
+
return e;
|
|
16
27
|
}
|
|
17
|
-
class
|
|
28
|
+
class S {
|
|
18
29
|
tokenizer;
|
|
19
30
|
blockSize;
|
|
20
|
-
constructor(
|
|
21
|
-
this.tokenizer =
|
|
31
|
+
constructor(t, s = 128) {
|
|
32
|
+
this.tokenizer = t, this.blockSize = s;
|
|
22
33
|
}
|
|
23
34
|
// Create dataset from text files
|
|
24
|
-
async createTextDataset(
|
|
25
|
-
if (
|
|
26
|
-
throw new Error(`Not enough tokens (${
|
|
27
|
-
const
|
|
28
|
-
shuffledIndexes: new Uint32Array(
|
|
35
|
+
async createTextDataset(t, s = 32, r, c, i = 65535) {
|
|
36
|
+
if (t.length < this.blockSize + 1)
|
|
37
|
+
throw new Error(`Not enough tokens (${t.length}) for block size ${this.blockSize}`);
|
|
38
|
+
const o = {
|
|
39
|
+
shuffledIndexes: new Uint32Array(t.length),
|
|
29
40
|
step: 0
|
|
30
41
|
};
|
|
31
|
-
if (
|
|
32
|
-
|
|
42
|
+
if (r)
|
|
43
|
+
o.shuffledIndexes = r;
|
|
33
44
|
else {
|
|
34
|
-
|
|
35
|
-
for (let
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
o.shuffledIndexes = new Uint32Array(t.length);
|
|
46
|
+
for (let n = 0; n < t.length; n++)
|
|
47
|
+
o.shuffledIndexes[n] = n;
|
|
48
|
+
u(o.shuffledIndexes);
|
|
38
49
|
}
|
|
39
|
-
const
|
|
50
|
+
const d = (function* () {
|
|
40
51
|
for (; ; ) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
52
|
+
const n = o.shuffledIndexes[o.step++];
|
|
53
|
+
if (o.step >= o.shuffledIndexes.length && (o.step = 0, u(o.shuffledIndexes)), n + this.blockSize + 1 > t.length)
|
|
43
54
|
continue;
|
|
44
|
-
const
|
|
45
|
-
|
|
55
|
+
const a = new Int32Array(t.subarray(n, n + this.blockSize)), k = t.subarray(n + 1, n + this.blockSize + 1), l = new Int32Array(k);
|
|
56
|
+
if (c) {
|
|
57
|
+
let h = 0;
|
|
58
|
+
for (let f = 0; f < l.length; f++)
|
|
59
|
+
c[n + 1 + f] === 0 && (l[f] = i, h++);
|
|
60
|
+
if (h === l.length)
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
yield { xs: a, ys: l };
|
|
46
64
|
}
|
|
47
65
|
}).bind(this);
|
|
48
66
|
return {
|
|
49
|
-
dataset:
|
|
50
|
-
const
|
|
51
|
-
return
|
|
52
|
-
xs:
|
|
53
|
-
ys:
|
|
67
|
+
dataset: p(d).batch(s).map((n) => {
|
|
68
|
+
const a = n;
|
|
69
|
+
return x(() => ({
|
|
70
|
+
xs: a.xs.cast("int32"),
|
|
71
|
+
ys: a.ys.cast("int32")
|
|
54
72
|
// this.tf.oneHot(batchData.ys.cast('int32'), this.tokenizer.vocabSize),
|
|
55
73
|
}));
|
|
56
74
|
}).prefetch(2),
|
|
57
75
|
// Smaller prefetch to reduce memory pressure
|
|
58
|
-
state:
|
|
76
|
+
state: o
|
|
59
77
|
};
|
|
60
78
|
}
|
|
61
79
|
}
|
|
62
80
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
81
|
+
S as DatasetBuilder,
|
|
82
|
+
I as PAGE_FACTOR,
|
|
83
|
+
z as flattenTokens,
|
|
84
|
+
A as flattenTokensWithMask,
|
|
85
|
+
u as shuffle
|
|
67
86
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dataset } from '@tensorflow/tfjs-data';
|
|
2
2
|
import { TensorContainer } from '@tensorflow/tfjs-core';
|
|
3
3
|
import { default as Model, ModelForwardAttributes } from '../models/model';
|
|
4
|
-
import { Conversation, ITokeniser } from '../main';
|
|
5
4
|
interface Result {
|
|
6
5
|
loss: number;
|
|
7
6
|
accuracy: number;
|
|
@@ -12,7 +11,7 @@ export default class Evaluator {
|
|
|
12
11
|
private xs?;
|
|
13
12
|
private ys?;
|
|
14
13
|
private masked;
|
|
15
|
-
constructor(model: Model<ModelForwardAttributes>, dataset: Dataset<TensorContainer
|
|
14
|
+
constructor(model: Model<ModelForwardAttributes>, dataset: Dataset<TensorContainer>, masked?: boolean);
|
|
16
15
|
dispose(): void;
|
|
17
16
|
private calculateBatchLoss;
|
|
18
17
|
evaluate(maxBatches?: number): Promise<Result | Result[]>;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { calculateLoss as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
constructor(i, t, o, c) {
|
|
7
|
-
if (this.model = i, this.masked = !!c, Array.isArray(t)) {
|
|
8
|
-
if (!o)
|
|
9
|
-
throw new Error("Tokeniser is required when dataset is an array of conversations");
|
|
10
|
-
const a = t.map((s) => x(s, -100, o, i.config.blockSize)).filter((s) => s !== null);
|
|
11
|
-
if (a.length === 0)
|
|
12
|
-
return;
|
|
13
|
-
this.xs = h(a.map((s) => s.xs)), this.ys = h(a.map((s) => s.ys));
|
|
14
|
-
} else
|
|
15
|
-
this.iterator = t.iterator();
|
|
1
|
+
import { t as d } from "../index-CUXkjxiT.js";
|
|
2
|
+
import { calculateLoss as f, calculateAccuracy as p } from "./loss.js";
|
|
3
|
+
class b {
|
|
4
|
+
constructor(o, t, a) {
|
|
5
|
+
this.model = o, this.masked = !!a, this.iterator = t.iterator();
|
|
16
6
|
}
|
|
17
7
|
iterator;
|
|
18
8
|
xs;
|
|
@@ -21,29 +11,29 @@ class k {
|
|
|
21
11
|
dispose() {
|
|
22
12
|
this.xs && this.xs.dispose(), this.ys && this.ys.dispose();
|
|
23
13
|
}
|
|
24
|
-
async calculateBatchLoss(
|
|
25
|
-
const [
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
}),
|
|
29
|
-
return
|
|
14
|
+
async calculateBatchLoss(o, t, a, r) {
|
|
15
|
+
const [l, e] = d(() => {
|
|
16
|
+
const s = this.model.forward({ training: !1 }, o), h = f(s, t, r, a), y = p(s, t);
|
|
17
|
+
return s.dispose(), [h, y];
|
|
18
|
+
}), u = await l.array(), n = await e.array(), c = u, i = n;
|
|
19
|
+
return e.dispose(), l.dispose(), Array.isArray(c) ? c.map((s) => ({ loss: s, accuracy: i })) : { loss: c, accuracy: i };
|
|
30
20
|
}
|
|
31
|
-
async evaluate(
|
|
32
|
-
let t = 0,
|
|
21
|
+
async evaluate(o = 100) {
|
|
22
|
+
let t = 0, a = 0, r = 0;
|
|
33
23
|
if (this.iterator) {
|
|
34
|
-
const
|
|
35
|
-
for (let
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
|
|
24
|
+
const l = await this.iterator;
|
|
25
|
+
for (let e = 0; e < o; e++) {
|
|
26
|
+
const u = await l.next();
|
|
27
|
+
if (u.done) break;
|
|
28
|
+
const n = u.value, { xs: c, ys: i } = n, s = await this.calculateBatchLoss(c, i, !1, this.masked);
|
|
29
|
+
c.dispose(), i.dispose(), t += s.loss, a += s.accuracy, r++;
|
|
40
30
|
}
|
|
41
|
-
return { loss: t /
|
|
31
|
+
return { loss: t / r, accuracy: a / r };
|
|
42
32
|
} else if (this.xs && this.ys)
|
|
43
33
|
return this.calculateBatchLoss(this.xs, this.ys, !0, !0);
|
|
44
34
|
throw new Error("No data available for evaluation");
|
|
45
35
|
}
|
|
46
36
|
}
|
|
47
37
|
export {
|
|
48
|
-
|
|
38
|
+
b as default
|
|
49
39
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { default as Model, ModelForwardAttributes } from '../models/model';
|
|
2
2
|
import { default as BasicTrainer } from './BasicTrainer';
|
|
3
3
|
import { ITokeniser } from '../tokeniser/type';
|
|
4
|
-
import { SFTDatasetBuilder } from './SFTDatasetBuilder';
|
|
5
4
|
import { AdamWOptimizer } from './AdamW';
|
|
6
5
|
import { AdamWOptimizerConfig } from './types';
|
|
6
|
+
import { DatasetBuilder } from './DatasetBuilder';
|
|
7
7
|
export default class SFTTrainer extends BasicTrainer {
|
|
8
8
|
tokenizer: ITokeniser;
|
|
9
|
-
datasetBuilder:
|
|
9
|
+
datasetBuilder: DatasetBuilder;
|
|
10
|
+
loraName?: string;
|
|
10
11
|
constructor(model: Model<ModelForwardAttributes>, tokenizer: ITokeniser, optConfig?: Partial<AdamWOptimizerConfig>, optimizer?: AdamWOptimizer);
|
|
11
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "./BasicTrainer.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DatasetBuilder as s } from "./DatasetBuilder.js";
|
|
3
3
|
const n = {
|
|
4
4
|
decayEpochs: 100,
|
|
5
5
|
epochSteps: 1e4,
|
|
@@ -10,12 +10,13 @@ const n = {
|
|
|
10
10
|
learningRate: 3e-4
|
|
11
11
|
// clipNorm: 1.0,
|
|
12
12
|
};
|
|
13
|
-
class
|
|
13
|
+
class c extends r {
|
|
14
14
|
constructor(t, e, i, a) {
|
|
15
15
|
super(t, e, { ...n, ...i }, a), this.tokenizer = e, this.optimizerConfig.minLearningRate = i?.minLearningRate ?? this.optimizerConfig.learningRate / 20, this.updateOptimizer(), this.datasetBuilder = new s(e, t.config.blockSize), this.maskedLoss = !0;
|
|
16
16
|
}
|
|
17
17
|
datasetBuilder;
|
|
18
|
+
loraName;
|
|
18
19
|
}
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
c as default
|
|
21
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as d } from "../index-
|
|
1
|
+
import { t as d } from "../index-CUXkjxiT.js";
|
|
2
2
|
function l(m, t, s) {
|
|
3
3
|
return d(() => {
|
|
4
4
|
const r = m.reshape([-1]), o = t.reshape([-1]), e = r.mul(r).sum().add(s), c = r.mul(o).sum().div(e), n = o.sub(r.mul(c)), a = o.norm(), u = n.norm().add(s);
|