@genai-fi/nanogpt 0.2.3 → 0.2.4
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/TeachableLLM.js +5 -4
- package/dist/data/parquet.js +7 -5
- package/dist/data/pdf.d.ts +1 -0
- package/dist/data/pdf.js +12 -0
- package/dist/data/textLoader.js +27 -22
- package/dist/index-D5v913EJ.js +4 -0
- package/dist/{index-B8nyc6IR.js → index-DcaSvB38.js} +462 -506
- package/dist/index-Tf7vU29b.js +1023 -0
- package/dist/index-xuotMAFm.js +118 -0
- package/dist/{jszip.min-pMIn3RZH.js → jszip.min-CAxN99oA.js} +42 -52
- package/dist/layers/TiedEmbedding.js +1 -1
- package/dist/parquet-BRl5lE_I.js +44956 -0
- package/dist/pdf-kJD-f258.js +19481 -0
- package/dist/training/AdamExt.js +1 -1
- package/dist/utilities/load.js +1 -1
- package/dist/utilities/save.js +1 -1
- package/package.json +4 -2
- package/dist/parquet-DpcqBLb0.js +0 -39727
package/dist/TeachableLLM.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defaultConfig as d } from "./config.js";
|
|
2
|
-
import
|
|
3
|
-
import { saveModel as
|
|
2
|
+
import m from "./NanoGPTModel.js";
|
|
3
|
+
import { saveModel as u } from "./utilities/save.js";
|
|
4
4
|
import { loadModel as l } from "./utilities/load.js";
|
|
5
5
|
import f from "./Generator.js";
|
|
6
6
|
import _ from "./Trainer.js";
|
|
@@ -8,6 +8,7 @@ import { E as c } from "./index-Dwqa6Zy2.js";
|
|
|
8
8
|
import { dummyPassAsync as h } from "./utilities/dummy.js";
|
|
9
9
|
import g from "./tokeniser/CharTokeniser.js";
|
|
10
10
|
import "./papaparse.min-C8l2Kvo1.js";
|
|
11
|
+
import "./index-Tf7vU29b.js";
|
|
11
12
|
class a extends c {
|
|
12
13
|
_config;
|
|
13
14
|
_model;
|
|
@@ -44,7 +45,7 @@ class a extends c {
|
|
|
44
45
|
saveModel(t) {
|
|
45
46
|
if (!this._model || !this._tokeniser)
|
|
46
47
|
throw new Error("Model or tokeniser is not initialized.");
|
|
47
|
-
return
|
|
48
|
+
return u(this._model, this._tokeniser, t);
|
|
48
49
|
}
|
|
49
50
|
static loadModel(t, r) {
|
|
50
51
|
const e = new a(t);
|
|
@@ -59,7 +60,7 @@ class a extends c {
|
|
|
59
60
|
}), e;
|
|
60
61
|
}
|
|
61
62
|
static create(t, r = {}) {
|
|
62
|
-
const e = { ...d, ...r }, s = new g(e.vocabSize), o = new
|
|
63
|
+
const e = { ...d, ...r }, s = new g(e.vocabSize), o = new m(t, e), i = new a(t, s, o);
|
|
63
64
|
return i.setStatus("warmup"), h(o).then(() => {
|
|
64
65
|
i.tokeniser.trained ? i.setStatus("ready") : (i.setStatus("awaitingTokens"), i.tokeniser.once("trainStatus", (n) => {
|
|
65
66
|
n === "trained" && i.setStatus("ready");
|
package/dist/data/parquet.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { B as n } from "../index-Tf7vU29b.js";
|
|
2
|
+
const p = 100 * 1024 * 1024;
|
|
3
|
+
async function w(s, f = p, r = "text") {
|
|
4
|
+
const e = await (await import("../parquet-BRl5lE_I.js").then((t) => t.p)).ParquetReader.openBuffer(n.from(await s.arrayBuffer())), a = [], i = e.getCursor([[r]]);
|
|
3
5
|
let o = 0;
|
|
4
6
|
for (; ; ) {
|
|
5
7
|
const t = await i.next();
|
|
6
|
-
if (!t || !t[
|
|
8
|
+
if (!t || !t[r] || typeof t[r] != "string" || (a.push(t[r]), o += t[r].length, o > f)) break;
|
|
7
9
|
}
|
|
8
|
-
return
|
|
10
|
+
return e.close(), a;
|
|
9
11
|
}
|
|
10
12
|
export {
|
|
11
|
-
|
|
13
|
+
w as loadParquet
|
|
12
14
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadPDF(file: File, maxSize?: number): Promise<string[]>;
|
package/dist/data/pdf.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
async function u(s, i = 104857600) {
|
|
2
|
+
const e = await (await import("../pdf-kJD-f258.js")).getDocument({ data: await s.arrayBuffer() }).promise, c = e.numPages, a = [];
|
|
3
|
+
let n = 0;
|
|
4
|
+
for (let t = 1; t <= c; t++) {
|
|
5
|
+
const o = (await (await e.getPage(t)).getTextContent()).items.map((g) => g.str).join(" ");
|
|
6
|
+
if (a.push(o), n += o.length, n > i) break;
|
|
7
|
+
}
|
|
8
|
+
return a;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
u as loadPDF
|
|
12
|
+
};
|
package/dist/data/textLoader.js
CHANGED
|
@@ -1,54 +1,59 @@
|
|
|
1
|
-
import { p as
|
|
1
|
+
import { p as s } from "../papaparse.min-C8l2Kvo1.js";
|
|
2
2
|
import { loadParquet as d } from "./parquet.js";
|
|
3
|
+
import { loadPDF as m } from "./pdf.js";
|
|
3
4
|
function x(e, t) {
|
|
4
|
-
const
|
|
5
|
-
return
|
|
5
|
+
const a = e.findIndex((n) => n.toLowerCase() === t.toLowerCase());
|
|
6
|
+
return a === -1 ? 0 : a;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
+
function f(e) {
|
|
8
9
|
return e.every((t) => t.length < 64);
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
+
function l(e) {
|
|
11
12
|
return e.split(".").pop() || "";
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
switch (
|
|
14
|
+
function w(e) {
|
|
15
|
+
switch (l(e)) {
|
|
15
16
|
case "parquet":
|
|
16
17
|
return "application/parquet";
|
|
17
18
|
case "csv":
|
|
18
19
|
return "text/csv";
|
|
19
20
|
case "txt":
|
|
20
21
|
return "text/plain";
|
|
22
|
+
case "pdf":
|
|
23
|
+
return "application/pdf";
|
|
21
24
|
default:
|
|
22
25
|
return "unknown";
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
|
-
async function
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
+
async function q(e, t) {
|
|
29
|
+
const a = e.type !== "" ? e.type : w(e.name);
|
|
30
|
+
if (a === "application/parquet")
|
|
28
31
|
return d(e, t?.maxSize, t?.column);
|
|
29
|
-
if (
|
|
32
|
+
if (a === "application/pdf")
|
|
33
|
+
return m(e, t?.maxSize);
|
|
34
|
+
if (a === "text/csv") {
|
|
30
35
|
const n = await e.text();
|
|
31
|
-
return new Promise((
|
|
32
|
-
|
|
36
|
+
return new Promise((p, o) => {
|
|
37
|
+
s.parse(n, {
|
|
33
38
|
header: !1,
|
|
34
39
|
skipEmptyLines: !0,
|
|
35
|
-
complete: (
|
|
36
|
-
if (
|
|
40
|
+
complete: (r) => {
|
|
41
|
+
if (r.errors.length > 0)
|
|
37
42
|
o(new Error("Error parsing file"));
|
|
38
43
|
else {
|
|
39
|
-
const
|
|
40
|
-
|
|
44
|
+
const c = x(r.data[0], t?.column || "text"), i = t?.hasHeader ?? f(r.data[0]) ? r.data.slice(1) : r.data;
|
|
45
|
+
p(i.map((u) => u[c]));
|
|
41
46
|
}
|
|
42
47
|
},
|
|
43
|
-
error: (
|
|
44
|
-
o(
|
|
48
|
+
error: (r) => {
|
|
49
|
+
o(r);
|
|
45
50
|
}
|
|
46
51
|
});
|
|
47
52
|
});
|
|
48
|
-
} else if (
|
|
53
|
+
} else if (a === "text/plain")
|
|
49
54
|
return [await e.text()];
|
|
50
|
-
throw new Error(`Unsupported file type: ${
|
|
55
|
+
throw new Error(`Unsupported file type: ${a}`);
|
|
51
56
|
}
|
|
52
57
|
export {
|
|
53
|
-
|
|
58
|
+
q as default
|
|
54
59
|
};
|