@genai-fi/nanogpt 0.2.2 → 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 +31 -11
- 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,19 +1,39 @@
|
|
|
1
1
|
import { p as s } from "../papaparse.min-C8l2Kvo1.js";
|
|
2
|
-
import { loadParquet as
|
|
3
|
-
|
|
2
|
+
import { loadParquet as d } from "./parquet.js";
|
|
3
|
+
import { loadPDF as m } from "./pdf.js";
|
|
4
|
+
function x(e, t) {
|
|
4
5
|
const a = e.findIndex((n) => n.toLowerCase() === t.toLowerCase());
|
|
5
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
|
-
|
|
11
|
-
|
|
11
|
+
function l(e) {
|
|
12
|
+
return e.split(".").pop() || "";
|
|
13
|
+
}
|
|
14
|
+
function w(e) {
|
|
15
|
+
switch (l(e)) {
|
|
16
|
+
case "parquet":
|
|
17
|
+
return "application/parquet";
|
|
18
|
+
case "csv":
|
|
19
|
+
return "text/csv";
|
|
20
|
+
case "txt":
|
|
21
|
+
return "text/plain";
|
|
22
|
+
case "pdf":
|
|
23
|
+
return "application/pdf";
|
|
24
|
+
default:
|
|
25
|
+
return "unknown";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function q(e, t) {
|
|
29
|
+
const a = e.type !== "" ? e.type : w(e.name);
|
|
12
30
|
if (a === "application/parquet")
|
|
13
|
-
return
|
|
31
|
+
return d(e, t?.maxSize, t?.column);
|
|
32
|
+
if (a === "application/pdf")
|
|
33
|
+
return m(e, t?.maxSize);
|
|
14
34
|
if (a === "text/csv") {
|
|
15
|
-
const n =
|
|
16
|
-
return new Promise((
|
|
35
|
+
const n = await e.text();
|
|
36
|
+
return new Promise((p, o) => {
|
|
17
37
|
s.parse(n, {
|
|
18
38
|
header: !1,
|
|
19
39
|
skipEmptyLines: !0,
|
|
@@ -21,8 +41,8 @@ async function w(e, t) {
|
|
|
21
41
|
if (r.errors.length > 0)
|
|
22
42
|
o(new Error("Error parsing file"));
|
|
23
43
|
else {
|
|
24
|
-
const
|
|
25
|
-
|
|
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]));
|
|
26
46
|
}
|
|
27
47
|
},
|
|
28
48
|
error: (r) => {
|
|
@@ -35,5 +55,5 @@ async function w(e, t) {
|
|
|
35
55
|
throw new Error(`Unsupported file type: ${a}`);
|
|
36
56
|
}
|
|
37
57
|
export {
|
|
38
|
-
|
|
58
|
+
q as default
|
|
39
59
|
};
|