@genai-fi/nanogpt 0.23.0 → 1.0.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/README.md +78 -281
- package/dist/{DatasetBuilder-C0iJT29K.js → DatasetBuilder-DU1G1OKX.js} +20 -23
- package/dist/{RealDiv-CNsvC4AU.js → RealDiv-CSnvtN2E.js} +20 -20
- package/dist/{Reshape-dnm9bO3B.js → Reshape-BlylqwWy.js} +12 -12
- package/dist/TeachableLLM.d.ts +10 -15
- package/dist/TeachableLLM.js +201 -2
- package/dist/api/responses.d.ts +81 -0
- package/dist/api/responses.js +169 -0
- package/dist/api/training.d.ts +70 -0
- package/dist/api/training.js +205 -0
- package/dist/data/docx.js +9 -3036
- package/dist/data/stream.d.ts +8 -8
- package/dist/data/stream.js +1 -1
- package/dist/data/textLoader.d.ts +1 -1
- package/dist/data/textLoader.js +2 -2
- package/dist/data.d.ts +3 -0
- package/dist/data.js +12 -0
- package/dist/{dist-BqAU9-yi.js → dist-CwK5S7Ls.js} +2168 -2168
- package/dist/{gpgpu_math-DBYEAAdI.js → gpgpu_math-20tPK8LM.js} +458 -458
- package/dist/{Generator.d.ts → inference/Generator.d.ts} +16 -44
- package/dist/inference/Generator.js +271 -0
- package/dist/inference/tokenisePrompt.d.ts +4 -0
- package/dist/inference/tokenisePrompt.js +13 -0
- package/dist/inference/types.d.ts +44 -8
- package/dist/inference/utilities.d.ts +9 -0
- package/dist/inference/utilities.js +20 -0
- package/dist/jszip.min-DKa1Rjyn.js +3033 -0
- package/dist/{kernel_funcs_utils-D-mATnGR.js → kernel_funcs_utils-ql8Y8qPn.js} +96 -93
- package/dist/layers/MLP.d.ts +1 -1
- package/dist/layers/PositionEmbedding.d.ts +2 -1
- package/dist/layers/PositionEmbedding.js +1 -1
- package/dist/layers/RMSNorm.d.ts +1 -1
- package/dist/layers/TiedEmbedding.js +1 -1
- package/dist/layers.d.ts +4 -0
- package/dist/layers.js +14 -0
- package/dist/loader/load.js +58 -2
- package/dist/loader/loadHF.d.ts +1 -1
- package/dist/loader/loadHF.js +17 -2
- package/dist/loader/loadTransformers.js +46 -2
- package/dist/loader/newZipLoad.js +25 -2
- package/dist/loader/oldZipLoad.d.ts +1 -1
- package/dist/loader/oldZipLoad.js +37 -2
- package/dist/loader/save.js +75 -2
- package/dist/loader/types.d.ts +3 -3
- package/dist/main.d.ts +34 -43
- package/dist/main.js +12327 -20
- package/dist/{matMulGelu-BAIgQaRx.js → matMulGelu-CBoqTZM7.js} +2 -2
- package/dist/models/NanoGPTV1.js +95 -2
- package/dist/models/NanoGPTV2.js +86 -2
- package/dist/models/factory.js +13 -2
- package/dist/models/model.js +76 -2
- package/dist/models.d.ts +4 -0
- package/dist/models.js +14 -0
- package/dist/ops/dot16.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/webgl/adamAdjust.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +2 -2
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +5 -5
- package/dist/ops/webgl/matMulGelu.js +1 -1
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/{stream-BjdpSNqB.js → stream-BpAwcvHz.js} +565 -561
- package/dist/{tfjs_backend-CydPRQTc.js → tfjs_backend-h5weiy1O.js} +36 -36
- package/dist/tokenise.d.ts +4 -0
- package/dist/tokenise.js +15 -0
- package/dist/tokeniser/CharTokeniser.js +18 -20
- package/dist/tokeniser/bpe.js +18 -22
- package/dist/training/BasicTrainer.d.ts +5 -10
- package/dist/training/BasicTrainer.js +80 -88
- package/dist/training/DatasetBuilder.d.ts +4 -4
- package/dist/training/DatasetBuilder.js +1 -1
- package/dist/training/PreTrainer.js +1 -1
- package/dist/training/SFTTrainer.js +1 -1
- package/dist/training/configure.d.ts +3 -0
- package/dist/training/configure.js +32 -0
- package/dist/training/factory.d.ts +6 -0
- package/dist/training/factory.js +8 -0
- package/dist/training/prepareData.d.ts +22 -0
- package/dist/training/prepareData.js +49 -0
- package/dist/training/tasks/TokenStore.d.ts +2 -1
- package/dist/training/tasks/TokenStore.js +8 -5
- package/dist/training/tasks/tokenStream.d.ts +17 -0
- package/dist/training/tasks/tokenStream.js +46 -0
- package/dist/training/types.d.ts +14 -1
- package/dist/training/validateOptions.d.ts +2 -0
- package/dist/training/validateOptions.js +19 -0
- package/dist/training/validation.js +4 -2
- package/dist/utilities/arrayShape.d.ts +1 -0
- package/dist/utilities/arrayShape.js +8 -0
- package/dist/utilities/random.d.ts +1 -0
- package/dist/utilities/random.js +19 -0
- package/dist/utilities/waitForModel.d.ts +1 -1
- package/dist/v4-BK7K-jy_.js +30 -0
- package/package.json +8 -2
- package/dist/Generator.js +0 -2
- package/dist/Trainer-DBsyWJ4s.js +0 -228
- package/dist/Trainer.d.ts +0 -45
- package/dist/Trainer.js +0 -2
- package/dist/main-BSaDGH7I.js +0 -13274
- package/dist/training/tasks/ConversationTask.d.ts +0 -17
- package/dist/training/tasks/ConversationTask.js +0 -29
- package/dist/training/tasks/PretrainingTask.d.ts +0 -17
- package/dist/training/tasks/PretrainingTask.js +0 -42
- package/dist/training/tasks/StartSentenceTask.d.ts +0 -18
- package/dist/training/tasks/StartSentenceTask.js +0 -45
- package/dist/training/tasks/Task.d.ts +0 -29
- package/dist/training/tasks/Task.js +0 -50
- package/dist/training/tasks/splitter.d.ts +0 -5
- package/dist/training/tasks/splitter.js +0 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ci as e, Ii as t, In as n, Ps as r, di as i, gr as a, ii as o, oc as s } from "./dist-Da20xy8E.js";
|
|
2
|
-
import { a as c } from "./gpgpu_math-
|
|
3
|
-
import { t as l } from "./Reshape-
|
|
2
|
+
import { a as c } from "./gpgpu_math-20tPK8LM.js";
|
|
3
|
+
import { t as l } from "./Reshape-BlylqwWy.js";
|
|
4
4
|
//#region node_modules/@tensorflow/tfjs-backend-webgl/dist/mulmat_packed_gpu.js
|
|
5
5
|
var u = class {
|
|
6
6
|
constructor(e, t, n, r = !1, i = !1, a = !1, o = null, s = !1, l = !1) {
|
package/dist/models/NanoGPTV1.js
CHANGED
|
@@ -1,2 +1,95 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { di as e, oi as t } from "../dist-Da20xy8E.js";
|
|
2
|
+
import { packingSupported as n } from "../utilities/packed.js";
|
|
3
|
+
import { r, t as i } from "../pack16-BhuXNUS7.js";
|
|
4
|
+
import a from "../layers/RMSNorm.js";
|
|
5
|
+
import o from "../layers/TransformerBlock.js";
|
|
6
|
+
import s from "../layers/TiedEmbedding.js";
|
|
7
|
+
import c from "../layers/RoPECache.js";
|
|
8
|
+
import l from "./model.js";
|
|
9
|
+
import u from "../layers/PositionEmbedding.js";
|
|
10
|
+
//#region lib/models/NanoGPTV1.ts
|
|
11
|
+
var d = {
|
|
12
|
+
modelType: "GenAI_NanoGPT_v1",
|
|
13
|
+
vocabSize: 2e3,
|
|
14
|
+
blockSize: 128,
|
|
15
|
+
nLayer: 6,
|
|
16
|
+
nHead: 4,
|
|
17
|
+
nEmbed: 256,
|
|
18
|
+
mlpFactor: 4,
|
|
19
|
+
useRope: !0
|
|
20
|
+
}, f = class extends l {
|
|
21
|
+
wte;
|
|
22
|
+
wpe;
|
|
23
|
+
blocks;
|
|
24
|
+
lnF;
|
|
25
|
+
ropeCache;
|
|
26
|
+
constructor(e = {}) {
|
|
27
|
+
super({
|
|
28
|
+
...d,
|
|
29
|
+
...e
|
|
30
|
+
});
|
|
31
|
+
let t = {
|
|
32
|
+
activation: "gelu",
|
|
33
|
+
hiddenFactor: this.config.mlpFactor,
|
|
34
|
+
useGamma: !0,
|
|
35
|
+
useQKNorm: !1
|
|
36
|
+
};
|
|
37
|
+
this.wte = new s(this.config, "token_embedding", this), this.config.useRope === !1 ? this.wpe = new u(this.config, "positional_embedding", this) : this.ropeCache = new c(this.config), this.blocks = [];
|
|
38
|
+
for (let e = 0; e < this.config.nLayer; e++) this.blocks.push(new o(e, this.config, t, this));
|
|
39
|
+
this.lnF = new a(this.config, t, "final_rms_norm", this);
|
|
40
|
+
}
|
|
41
|
+
getClassName() {
|
|
42
|
+
return "GenAI_NanoGPT_v1";
|
|
43
|
+
}
|
|
44
|
+
inputPhase(t, n) {
|
|
45
|
+
return e(() => {
|
|
46
|
+
let e = this.wte.embed(t);
|
|
47
|
+
if (this.config.useRope === !1) {
|
|
48
|
+
let t = this.wpe.call(n, e);
|
|
49
|
+
if (Array.isArray(t)) throw Error("PositionEmbedding output should not be an array");
|
|
50
|
+
return t;
|
|
51
|
+
}
|
|
52
|
+
return e;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
forward(a, o) {
|
|
56
|
+
return this.validateInput(o), a.ropeCache = this.ropeCache, a.outputEmbeddings && (a.embeddings = []), e(() => {
|
|
57
|
+
this.startMemory();
|
|
58
|
+
let e = this.inputPhase(o, a);
|
|
59
|
+
if (a.cache && a.cache.length !== this.blocks.length) throw console.error("Cache", a.cache), Error(`Cache length ${a.cache.length} does not match number of blocks ${this.blocks.length}`);
|
|
60
|
+
let s = a.mixedPrecision === !0 && n(), c = s ? i(e) : e;
|
|
61
|
+
s && e !== c && e.dispose();
|
|
62
|
+
for (let e = 0; e < this.blocks.length; e++) {
|
|
63
|
+
let n = this.blocks[e], r = Math.random() * 1e9, i = {
|
|
64
|
+
...a,
|
|
65
|
+
seed: r,
|
|
66
|
+
pastKV: a.cache ? a.cache[e] : void 0,
|
|
67
|
+
mixedPrecision: s
|
|
68
|
+
}, o = a.checkpointing && a.training ? n.callCheckpoint(i, c) : n.call(i, c);
|
|
69
|
+
a.outputEmbeddings ? (t(c), a.embeddings.push({
|
|
70
|
+
name: `block_output_${e}`,
|
|
71
|
+
tensor: c
|
|
72
|
+
})) : c.dispose(), c = o;
|
|
73
|
+
}
|
|
74
|
+
if (e = this.lnF.call({
|
|
75
|
+
...a,
|
|
76
|
+
mixedPrecision: s
|
|
77
|
+
}, c), c.dispose(), a.skipLogits) return this.endMemory("Forward"), e;
|
|
78
|
+
let l = this.wte.project(e);
|
|
79
|
+
a.outputEmbeddings ? (t(e), a.embeddings.push({
|
|
80
|
+
name: "final_norm_output",
|
|
81
|
+
tensor: e
|
|
82
|
+
})) : e.dispose();
|
|
83
|
+
let u = s ? r(l) : l;
|
|
84
|
+
return s && l !== u && l.dispose(), u;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
project(t) {
|
|
88
|
+
return e(() => this.wte.project(t));
|
|
89
|
+
}
|
|
90
|
+
dispose() {
|
|
91
|
+
this.weightStore.dispose(), this.wte.dispose(), this.wpe && this.wpe.dispose(), this.blocks.forEach((e) => e.dispose()), this.lnF.dispose();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
export { f as default };
|
package/dist/models/NanoGPTV2.js
CHANGED
|
@@ -1,2 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { di as e, oi as t } from "../dist-Da20xy8E.js";
|
|
2
|
+
import { packingSupported as n } from "../utilities/packed.js";
|
|
3
|
+
import { r, t as i } from "../pack16-BhuXNUS7.js";
|
|
4
|
+
import a from "../layers/RMSNorm.js";
|
|
5
|
+
import o from "../layers/TransformerBlock.js";
|
|
6
|
+
import s from "../layers/TiedEmbedding.js";
|
|
7
|
+
import c from "../layers/RoPECache.js";
|
|
8
|
+
import l from "./model.js";
|
|
9
|
+
//#region lib/models/NanoGPTV2.ts
|
|
10
|
+
var u = {
|
|
11
|
+
modelType: "GenAI_NanoGPT_v2",
|
|
12
|
+
vocabSize: 2e3,
|
|
13
|
+
blockSize: 128,
|
|
14
|
+
nLayer: 6,
|
|
15
|
+
nHead: 4,
|
|
16
|
+
nEmbed: 256,
|
|
17
|
+
mlpFactor: 4
|
|
18
|
+
}, d = class extends l {
|
|
19
|
+
wte;
|
|
20
|
+
wpe;
|
|
21
|
+
blocks;
|
|
22
|
+
lnF;
|
|
23
|
+
ropeCache;
|
|
24
|
+
constructor(e = {}) {
|
|
25
|
+
super({
|
|
26
|
+
...u,
|
|
27
|
+
...e
|
|
28
|
+
});
|
|
29
|
+
let t = {
|
|
30
|
+
activation: "relu2",
|
|
31
|
+
hiddenFactor: this.config.mlpFactor,
|
|
32
|
+
useGamma: !1,
|
|
33
|
+
useQKNorm: !0
|
|
34
|
+
};
|
|
35
|
+
this.wte = new s(this.config, "token_embedding", this), this.ropeCache = new c(this.config), this.blocks = [];
|
|
36
|
+
for (let e = 0; e < this.config.nLayer; e++) this.blocks.push(new o(e, this.config, t, this));
|
|
37
|
+
this.lnF = new a(this.config, t, "final_rms_norm", this);
|
|
38
|
+
}
|
|
39
|
+
getClassName() {
|
|
40
|
+
return "GenAI_NanoGPT_v2";
|
|
41
|
+
}
|
|
42
|
+
inputPhase(t) {
|
|
43
|
+
return e(() => this.wte.embed(t));
|
|
44
|
+
}
|
|
45
|
+
forward(a, o) {
|
|
46
|
+
return this.validateInput(o), a.ropeCache = this.ropeCache, a.outputEmbeddings && (a.embeddings = []), e(() => {
|
|
47
|
+
this.startMemory();
|
|
48
|
+
let e = this.inputPhase(o);
|
|
49
|
+
if (a.cache && a.cache.length !== this.blocks.length) throw console.error("Cache", a.cache), Error(`Cache length ${a.cache.length} does not match number of blocks ${this.blocks.length}`);
|
|
50
|
+
let s = a.mixedPrecision === !0 && n(), c = s ? i(e) : e;
|
|
51
|
+
s && e !== c && e.dispose();
|
|
52
|
+
for (let e = 0; e < this.blocks.length; e++) {
|
|
53
|
+
if (a.layerDrop && Math.random() < a.layerDrop * (e / this.blocks.length)) continue;
|
|
54
|
+
let n = this.blocks[e], r = Math.random() * 1e9, i = {
|
|
55
|
+
...a,
|
|
56
|
+
seed: r,
|
|
57
|
+
pastKV: a.cache ? a.cache[e] : void 0,
|
|
58
|
+
mixedPrecision: s
|
|
59
|
+
}, o = a.checkpointing && a.training ? n.callCheckpoint(i, c) : n.call(i, c);
|
|
60
|
+
a.outputEmbeddings ? (t(c), a.embeddings.push({
|
|
61
|
+
name: `block_output_${e}`,
|
|
62
|
+
tensor: c
|
|
63
|
+
})) : c.dispose(), c = o;
|
|
64
|
+
}
|
|
65
|
+
if (e = this.lnF.call({
|
|
66
|
+
...a,
|
|
67
|
+
mixedPrecision: s
|
|
68
|
+
}, c), c.dispose(), a.skipLogits) return this.endMemory("Forward"), e;
|
|
69
|
+
let l = this.wte.project(e);
|
|
70
|
+
a.outputEmbeddings ? (t(e), a.embeddings.push({
|
|
71
|
+
name: "final_norm_output",
|
|
72
|
+
tensor: e
|
|
73
|
+
})) : e.dispose();
|
|
74
|
+
let u = s ? r(l) : l;
|
|
75
|
+
return s && l !== u && l.dispose(), u;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
project(t) {
|
|
79
|
+
return e(() => this.wte.project(t));
|
|
80
|
+
}
|
|
81
|
+
dispose() {
|
|
82
|
+
this.weightStore.dispose(), this.wte.dispose(), this.wpe && this.wpe.dispose(), this.blocks.forEach((e) => e.dispose()), this.lnF.dispose();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { d as default };
|
package/dist/models/factory.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import e from "./NanoGPTV1.js";
|
|
2
|
+
import t from "./NanoGPTV2.js";
|
|
3
|
+
//#region lib/models/factory.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
let r = n.modelType || "GenAI_NanoGPT_v1";
|
|
6
|
+
switch (r) {
|
|
7
|
+
case "GenAI_NanoGPT_v1": return new e(n);
|
|
8
|
+
case "GenAI_NanoGPT_v2": return new t(n);
|
|
9
|
+
default: throw Error(`Unsupported model type: ${r}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as default };
|
package/dist/models/model.js
CHANGED
|
@@ -1,2 +1,76 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import e from "../layers/BaseLayer.js";
|
|
2
|
+
import { estimateParameterCount as t } from "../utilities/parameters.js";
|
|
3
|
+
import n from "../layers/LoRA.js";
|
|
4
|
+
//#region lib/models/model.ts
|
|
5
|
+
var r = class extends e {
|
|
6
|
+
lossScaling = 128;
|
|
7
|
+
trainingState = null;
|
|
8
|
+
metaData = {
|
|
9
|
+
version: 2,
|
|
10
|
+
application: "@genai-fi/nanogpt"
|
|
11
|
+
};
|
|
12
|
+
loraLayer;
|
|
13
|
+
loraMap = /* @__PURE__ */ new Map();
|
|
14
|
+
constructor(e) {
|
|
15
|
+
super(e), e.loraConfig && e.loraConfig.forEach((e, t) => {
|
|
16
|
+
this.createLoRA(t, e);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
createLoRA(e, t) {
|
|
20
|
+
if (this.loraMap.has(e)) return;
|
|
21
|
+
let r = new n(e, this.weightStore, t.alpha, t.rank, t.variables);
|
|
22
|
+
this.loraMap.set(e, r), this.config.loraConfig = this.config.loraConfig || /* @__PURE__ */ new Map(), this.config.loraConfig.set(e, t);
|
|
23
|
+
}
|
|
24
|
+
deleteLoRA(e) {
|
|
25
|
+
let t = this.loraMap.get(e);
|
|
26
|
+
if (!t) throw Error(`No LoRA with name ${e} exists.`);
|
|
27
|
+
this.loraLayer === t && this.detachLoRA(), t.dispose(), this.loraMap.delete(e), this.config.loraConfig && this.config.loraConfig.delete(e);
|
|
28
|
+
}
|
|
29
|
+
renameLoRA(e, t) {
|
|
30
|
+
if (!this.loraMap.has(e)) throw Error(`No LoRA with name ${e} exists.`);
|
|
31
|
+
if (this.loraMap.has(t)) throw Error(`LoRA with name ${t} already exists.`);
|
|
32
|
+
let n = this.loraMap.get(e);
|
|
33
|
+
this.loraMap.set(t, n), this.loraMap.delete(e), this.config.loraConfig && (this.config.loraConfig.delete(e), this.config.loraConfig.set(t, {
|
|
34
|
+
rank: n.rank,
|
|
35
|
+
alpha: n.alpha,
|
|
36
|
+
variables: Array.from(n.variables)
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
mergeLoRA(e) {
|
|
40
|
+
let t = this.loraMap.get(e);
|
|
41
|
+
if (!t) throw Error(`No LoRA with name ${e} exists.`);
|
|
42
|
+
t.merge(), this.deleteLoRA(e);
|
|
43
|
+
}
|
|
44
|
+
attachLoRA(e) {
|
|
45
|
+
if (this.loraLayer) {
|
|
46
|
+
if (this.loraLayer.name === e) return;
|
|
47
|
+
this.detachLoRA();
|
|
48
|
+
}
|
|
49
|
+
let t = this.loraMap.get(e);
|
|
50
|
+
if (!t) throw Error(`No LoRA with name ${e} exists.`);
|
|
51
|
+
t.attach(), this.loraLayer = t, this.config.loraName = e;
|
|
52
|
+
}
|
|
53
|
+
detachLoRA() {
|
|
54
|
+
if (!this.loraLayer) throw Error("No LoRA layer is attached to this model.");
|
|
55
|
+
this.loraLayer.detach(), this.loraLayer = void 0, this.config.loraName = void 0;
|
|
56
|
+
}
|
|
57
|
+
hasLoRA(e) {
|
|
58
|
+
return e ? this.loraMap.has(e) : !!this.loraLayer;
|
|
59
|
+
}
|
|
60
|
+
listLoRAs() {
|
|
61
|
+
return Array.from(this.loraMap.keys());
|
|
62
|
+
}
|
|
63
|
+
get lora() {
|
|
64
|
+
return this.loraLayer || null;
|
|
65
|
+
}
|
|
66
|
+
getNumParams() {
|
|
67
|
+
return t(this.config);
|
|
68
|
+
}
|
|
69
|
+
validateInput(e) {
|
|
70
|
+
if (e.shape.length !== 2) throw Error(`Invalid input shape: expected [batch_size, sequence_length], got ${e.shape}`);
|
|
71
|
+
if (e.shape[1] > this.config.blockSize) throw Error(`Input sequence length ${e.shape[1]} isn't block size ${this.config.blockSize}`);
|
|
72
|
+
if (e.dtype !== "int32") throw Error(`Input tensor must be of type int32, got ${e.dtype}`);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { r as default };
|
package/dist/models.d.ts
ADDED
package/dist/models.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { n as e } from "./chunk-CWhphoD1.js";
|
|
2
|
+
import t from "./models/model.js";
|
|
3
|
+
import n from "./models/NanoGPTV1.js";
|
|
4
|
+
import r from "./models/NanoGPTV2.js";
|
|
5
|
+
import i from "./utilities/waitForModel.js";
|
|
6
|
+
//#region lib/models.ts
|
|
7
|
+
var a = /* @__PURE__ */ e({
|
|
8
|
+
Model: () => t,
|
|
9
|
+
NanoGPTV1: () => n,
|
|
10
|
+
NanoGPTV2: () => r,
|
|
11
|
+
waitForModel: () => i
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { t as Model, n as NanoGPTV1, r as NanoGPTV2, a as t, i as waitForModel };
|
package/dist/ops/dot16.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as e } from "../tfjs_backend-
|
|
1
|
+
import { o as e } from "../tfjs_backend-h5weiy1O.js";
|
|
2
2
|
import { isPackedTensor as t } from "../utilities/packed.js";
|
|
3
3
|
import { transpose16 as n } from "./transpose16.js";
|
|
4
4
|
import { reshape16 as r } from "./reshape16.js";
|
package/dist/ops/matMulGelu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ii as e, Tn as t, nc as n } from "../../dist-Da20xy8E.js";
|
|
2
|
-
import { t as r } from "../../Reshape-
|
|
3
|
-
import { a as i, r as a, t as o } from "../../RealDiv-
|
|
2
|
+
import { t as r } from "../../Reshape-BlylqwWy.js";
|
|
3
|
+
import { a as i, r as a, t as o } from "../../RealDiv-CSnvtN2E.js";
|
|
4
4
|
//#region lib/ops/webgl/fusedSoftmax.ts
|
|
5
5
|
var s = class {
|
|
6
6
|
variableNames = ["logits", "maxLogits"];
|
package/dist/ops/webgl/gelu.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Ii as e } from "../../dist-Da20xy8E.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i as t, s as n } from "../../kernel_funcs_utils-ql8Y8qPn.js";
|
|
3
3
|
//#region lib/ops/webgl/gelu.ts
|
|
4
|
-
var r = .7978845608028654, i = .044715, a =
|
|
4
|
+
var r = .7978845608028654, i = .044715, a = t({ opSnippet: n + `
|
|
5
5
|
float x3 = x * x * x;
|
|
6
6
|
float inner = x + ${i} * x3;
|
|
7
7
|
inner = ${r} * inner;
|
package/dist/ops/webgl/log.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Ii as e } from "../../dist-Da20xy8E.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { i as t, t as n } from "../../kernel_funcs_utils-ql8Y8qPn.js";
|
|
3
|
+
import { y as r } from "../../shared-CfTzpULd.js";
|
|
4
4
|
//#region lib/ops/webgl/log.ts
|
|
5
5
|
e({
|
|
6
6
|
kernelName: "Log",
|
|
7
7
|
backendName: "webgl",
|
|
8
|
-
kernelFunc:
|
|
9
|
-
opSnippet:
|
|
8
|
+
kernelFunc: t({
|
|
9
|
+
opSnippet: n + "\n return x < 0.0 ? NAN : log(x);\n",
|
|
10
10
|
packedOpSnippet: "\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? NAN : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? NAN : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? NAN : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? NAN : result.a);\n return result;\n",
|
|
11
|
-
cpuKernelImpl:
|
|
11
|
+
cpuKernelImpl: r
|
|
12
12
|
})
|
|
13
13
|
});
|
|
14
14
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "../../matMulGelu-
|
|
1
|
+
import { n as e, r as t, t as n } from "../../matMulGelu-CBoqTZM7.js";
|
|
2
2
|
export { n as MATMUL_SHARED_DIM_THRESHOLD, e as batchMatMulGeluImpl, t as batchMatMulKernel };
|