@genai-fi/nanogpt 0.2.12 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Generator.js +30 -25
- package/dist/NanoGPTModel.d.ts +13 -14
- package/dist/NanoGPTModel.js +142 -70
- package/dist/TeachableLLM.d.ts +16 -7
- package/dist/TeachableLLM.js +81 -44
- package/dist/Trainer.js +8 -8
- package/dist/concat-BIZS_td9.js +33 -0
- package/dist/data/parquet.js +1 -1
- package/dist/exports_layers-tbTBcwMM.js +25 -0
- package/dist/{sum-D7fu15XL.js → gather-BPGW8RsB.js} +6 -8
- package/dist/index-C4L8Cm77.js +349 -0
- package/dist/{index-YPKosni4.js → index-pWA4_lUh.js} +1020 -782
- package/dist/layers/CausalSelfAttention.d.ts +11 -11
- package/dist/layers/CausalSelfAttention.js +71 -63
- package/dist/layers/MLP.d.ts +6 -7
- package/dist/layers/MLP.js +18 -16
- package/dist/layers/RMSNorm.d.ts +6 -7
- package/dist/layers/RMSNorm.js +15 -13
- package/dist/layers/RoPECache.d.ts +4 -5
- package/dist/layers/RoPECache.js +36 -12
- package/dist/layers/TiedEmbedding.d.ts +7 -8
- package/dist/layers/TiedEmbedding.js +16 -418
- package/dist/layers/TransformerBlock.d.ts +8 -9
- package/dist/layers/TransformerBlock.js +12 -12
- package/dist/main.d.ts +2 -0
- package/dist/main.js +35 -21
- package/dist/{mat_mul-Bu7bhLms.js → mat_mul-D7_a4KJn.js} +5 -5
- package/dist/moments-DfcpfwKi.js +132 -0
- package/dist/ones-Cog-G2ag.js +29 -0
- package/dist/ops/appendCache.d.ts +2 -0
- package/dist/ops/appendCache.js +9 -0
- package/dist/ops/attentionMask.d.ts +1 -1
- package/dist/ops/attentionMask.js +7 -85
- package/dist/ops/cpu/appendCache.d.ts +2 -0
- package/dist/ops/cpu/appendCache.js +28 -0
- package/dist/ops/cpu/attentionMask.js +18 -0
- package/dist/ops/cpu/gatherSub.d.ts +1 -0
- package/dist/ops/cpu/gatherSub.js +34 -0
- package/dist/ops/cpu/qkv.d.ts +5 -0
- package/dist/ops/cpu/qkv.js +38 -0
- package/dist/ops/cpu/rope.d.ts +6 -0
- package/dist/ops/cpu/rope.js +38 -0
- package/dist/ops/cpu/scatterSub.d.ts +1 -0
- package/dist/ops/cpu/scatterSub.js +70 -0
- package/dist/ops/gatherSub.d.ts +1 -1
- package/dist/ops/gatherSub.js +6 -63
- package/dist/ops/grads/attentionMask.d.ts +1 -0
- package/dist/ops/grads/attentionMask.js +21 -0
- package/dist/ops/grads/qkv.d.ts +1 -0
- package/dist/ops/grads/qkv.js +20 -0
- package/dist/ops/grads/rope.d.ts +1 -0
- package/dist/ops/grads/rope.js +14 -0
- package/dist/ops/node/sparseCrossEntropy.js +1 -1
- package/dist/ops/qkv.d.ts +1 -6
- package/dist/ops/qkv.js +7 -124
- package/dist/ops/rope.d.ts +0 -5
- package/dist/ops/rope.js +7 -151
- package/dist/ops/scatterSub.d.ts +1 -1
- package/dist/ops/scatterSub.js +6 -147
- package/dist/ops/webgl/appendCache.d.ts +1 -0
- package/dist/ops/webgl/appendCache.js +43 -0
- package/dist/ops/webgl/attentionMask.d.ts +1 -0
- package/dist/ops/webgl/attentionMask.js +43 -0
- package/dist/ops/webgl/gatherSub.d.ts +1 -0
- package/dist/ops/webgl/gatherSub.js +27 -0
- package/dist/ops/webgl/qkv.d.ts +1 -0
- package/dist/ops/webgl/qkv.js +46 -0
- package/dist/ops/webgl/rope.d.ts +1 -0
- package/dist/ops/webgl/rope.js +56 -0
- package/dist/ops/webgl/scatterSub.d.ts +1 -0
- package/dist/ops/webgl/scatterSub.js +27 -0
- package/dist/{parquet-BRl5lE_I.js → parquet-C0Tlmv9c.js} +3045 -3048
- package/dist/random_width-oeUIlUZj.js +15487 -0
- package/dist/range-CcDl05lo.js +26 -0
- package/dist/{reshape-DmnmKT6r.js → reshape-C8CR_Bad.js} +3 -3
- package/dist/sin-BJIrfnj7.js +47 -0
- package/dist/softmax-Be_lsqUc.js +105 -0
- package/dist/{complex-CJ-qCcLB.js → split-DZbvruEP.js} +6 -8
- package/dist/stack-BMm-efee.js +27 -0
- package/dist/sum-C7Mgy9Bw.js +104 -0
- package/dist/tensor-DJVbYhh1.js +24 -0
- package/dist/tensor2d-ZuQSh2D-.js +30 -0
- package/dist/tokeniser/bpe.d.ts +17 -6
- package/dist/tokeniser/bpe.js +89 -61
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.d.ts +6 -6
- package/dist/training/DatasetBuilder.js +1262 -17
- package/dist/training/Evaluator.d.ts +3 -2
- package/dist/training/FullTrainer.d.ts +9 -8
- package/dist/training/FullTrainer.js +26 -25
- package/dist/training/LayerTrainer.d.ts +9 -8
- package/dist/training/LayerTrainer.js +34 -33
- package/dist/training/Trainer.d.ts +22 -21
- package/dist/training/Trainer.js +21 -18
- package/dist/training/sparseCrossEntropy.js +22 -166
- package/dist/utilities/dummy.js +10 -8
- package/dist/utilities/generate.js +14 -11
- package/dist/utilities/load.d.ts +1 -2
- package/dist/utilities/load.js +37 -35
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/save.js +14 -9
- package/dist/utilities/tokenParse.d.ts +1 -1
- package/dist/utilities/tokenParse.js +7 -61
- package/dist/utilities/weights.d.ts +3 -3
- package/dist/utilities/weights.js +21 -19
- package/dist/variable-Dl_ub3pk.js +23 -0
- package/dist/{stack-BtKpB0Ry.js → zeros-CCy9C3uU.js} +18 -16
- package/package.json +2 -1
- package/dist/assets/worker-BYeSPNkq.js +0 -1
- package/dist/tokeniser/NodeTokeniser.d.ts +0 -20
- package/dist/tokeniser/NodeTokeniser.js +0 -46
- package/dist/tokeniser/WebTokeniser.d.ts +0 -18
- package/dist/tokeniser/WebTokeniser.js +0 -96
- package/dist/tokeniser/worker.js +0 -53
- /package/dist/{tokeniser/worker.d.ts → ops/cpu/attentionMask.d.ts} +0 -0
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { E as d } from "../index-Dwqa6Zy2.js";
|
|
2
|
-
const t = new Worker(new URL(
|
|
3
|
-
/* @vite-ignore */
|
|
4
|
-
"/assets/worker-BYeSPNkq.js",
|
|
5
|
-
import.meta.url
|
|
6
|
-
), {
|
|
7
|
-
type: "module"
|
|
8
|
-
});
|
|
9
|
-
let r = 0;
|
|
10
|
-
class m extends d {
|
|
11
|
-
id;
|
|
12
|
-
vocabSize = 0;
|
|
13
|
-
handler;
|
|
14
|
-
constructor() {
|
|
15
|
-
super(), this.id = r++, this.handler = (e) => {
|
|
16
|
-
e.data.type === "trainStatus" && e.data.id === this.id && (this.vocabSize = e.data.vocabSize, this.emit("trainStatus", e.data.progress, e.data.vocabSize));
|
|
17
|
-
}, t.addEventListener("message", this.handler);
|
|
18
|
-
}
|
|
19
|
-
destroy() {
|
|
20
|
-
this.handler && (t.removeEventListener("message", this.handler), this.handler = void 0);
|
|
21
|
-
}
|
|
22
|
-
post(e) {
|
|
23
|
-
t.postMessage(e);
|
|
24
|
-
}
|
|
25
|
-
async train(e, n) {
|
|
26
|
-
return new Promise((s) => {
|
|
27
|
-
const i = (a) => {
|
|
28
|
-
a.data.type === "trainResponse" && a.data.id === this.id && (t.removeEventListener("message", i), this.vocabSize = a.data.vocabSize, s(this.vocabSize));
|
|
29
|
-
};
|
|
30
|
-
t.addEventListener("message", i), this.post({
|
|
31
|
-
type: "train",
|
|
32
|
-
id: this.id,
|
|
33
|
-
text: e,
|
|
34
|
-
vocabSize: n
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async tokenise(e, n) {
|
|
39
|
-
return new Promise((s) => {
|
|
40
|
-
const i = (a) => {
|
|
41
|
-
a.data.type === "tokeniseResponse" && a.data.id === this.id && (t.removeEventListener("message", i), s(a.data.tokens));
|
|
42
|
-
};
|
|
43
|
-
t.addEventListener("message", i), this.post({
|
|
44
|
-
type: "tokenise",
|
|
45
|
-
id: this.id,
|
|
46
|
-
text: e,
|
|
47
|
-
numeric: n
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
async detokenise(e) {
|
|
52
|
-
return new Promise((n) => {
|
|
53
|
-
const s = (i) => {
|
|
54
|
-
i.data.type === "detokeniseResponse" && i.data.id === this.id && (t.removeEventListener("message", s), n(i.data.text));
|
|
55
|
-
};
|
|
56
|
-
t.addEventListener("message", s), this.post({
|
|
57
|
-
type: "detokenise",
|
|
58
|
-
id: this.id,
|
|
59
|
-
tokens: e
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
async encode(e) {
|
|
64
|
-
return (await this.tokenise([e], !0))[0];
|
|
65
|
-
}
|
|
66
|
-
async decode(e) {
|
|
67
|
-
return (await this.detokenise([e]))[0];
|
|
68
|
-
}
|
|
69
|
-
async getVocab() {
|
|
70
|
-
return new Promise((e) => {
|
|
71
|
-
const n = (s) => {
|
|
72
|
-
s.data.type === "tokensResponse" && s.data.id === this.id && (t.removeEventListener("message", n), e(s.data.tokens));
|
|
73
|
-
};
|
|
74
|
-
t.addEventListener("message", n), this.post({
|
|
75
|
-
type: "tokens",
|
|
76
|
-
id: this.id
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
async createTrainingData(e, n = 5) {
|
|
81
|
-
return new Promise((s) => {
|
|
82
|
-
const i = (a) => {
|
|
83
|
-
a.data.type === "buildTrainingDataResponse" && a.data.id === this.id && (t.removeEventListener("message", i), s(a.data.trainingData));
|
|
84
|
-
};
|
|
85
|
-
t.addEventListener("message", i), this.post({
|
|
86
|
-
type: "buildTrainingData",
|
|
87
|
-
id: this.id,
|
|
88
|
-
text: e,
|
|
89
|
-
windowSize: n
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
export {
|
|
95
|
-
m as default
|
|
96
|
-
};
|
package/dist/tokeniser/worker.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import d from "./bpe.js";
|
|
2
|
-
let e = new d();
|
|
3
|
-
onmessage = async (s) => {
|
|
4
|
-
if (s.data.type === "tokenise")
|
|
5
|
-
if (s.data.numeric) {
|
|
6
|
-
const t = e.tokenise(s.data.text, !0), a = {
|
|
7
|
-
type: "tokeniseResponse",
|
|
8
|
-
id: s.data.id,
|
|
9
|
-
tokens: t,
|
|
10
|
-
numeric: !0
|
|
11
|
-
};
|
|
12
|
-
postMessage(a);
|
|
13
|
-
} else {
|
|
14
|
-
const t = e.tokenise(s.data.text), a = {
|
|
15
|
-
type: "tokeniseResponse",
|
|
16
|
-
id: s.data.id,
|
|
17
|
-
tokens: t,
|
|
18
|
-
numeric: !1
|
|
19
|
-
};
|
|
20
|
-
postMessage(a);
|
|
21
|
-
}
|
|
22
|
-
else if (s.data.type === "detokenise") {
|
|
23
|
-
const t = e.getVocab(), a = s.data.tokens.map((i) => i.map((n) => t[n]).join("")), o = {
|
|
24
|
-
type: "detokeniseResponse",
|
|
25
|
-
id: s.data.id,
|
|
26
|
-
text: a
|
|
27
|
-
};
|
|
28
|
-
postMessage(o);
|
|
29
|
-
} else if (s.data.type === "train") {
|
|
30
|
-
e = new d(), e.train(s.data.text, s.data.vocabSize ?? 100, (a, o) => {
|
|
31
|
-
const i = {
|
|
32
|
-
type: "trainStatus",
|
|
33
|
-
id: s.data.id,
|
|
34
|
-
progress: a,
|
|
35
|
-
vocabSize: o
|
|
36
|
-
};
|
|
37
|
-
postMessage(i);
|
|
38
|
-
});
|
|
39
|
-
const t = {
|
|
40
|
-
type: "trainResponse",
|
|
41
|
-
id: s.data.id,
|
|
42
|
-
vocabSize: e.getVocab().length
|
|
43
|
-
};
|
|
44
|
-
postMessage(t);
|
|
45
|
-
} else if (s.data.type === "tokens") {
|
|
46
|
-
const t = e.getVocab(), a = {
|
|
47
|
-
type: "tokensResponse",
|
|
48
|
-
id: s.data.id,
|
|
49
|
-
tokens: t
|
|
50
|
-
};
|
|
51
|
-
postMessage(a);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
File without changes
|