@genai-fi/nanogpt 0.2.3 → 0.2.5
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 +6 -4
- package/dist/data/docx.d.ts +1 -0
- package/dist/data/docx.js +15 -0
- package/dist/data/parquet.js +7 -5
- package/dist/data/pdf.d.ts +1 -0
- package/dist/data/pdf.js +14 -0
- package/dist/data/textLoader.js +24 -14
- 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-CjP2V1VV.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 +5 -5
- 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,8 @@ 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";
|
|
12
|
+
import "./jszip.min-CjP2V1VV.js";
|
|
11
13
|
class a extends c {
|
|
12
14
|
_config;
|
|
13
15
|
_model;
|
|
@@ -44,7 +46,7 @@ class a extends c {
|
|
|
44
46
|
saveModel(t) {
|
|
45
47
|
if (!this._model || !this._tokeniser)
|
|
46
48
|
throw new Error("Model or tokeniser is not initialized.");
|
|
47
|
-
return
|
|
49
|
+
return u(this._model, this._tokeniser, t);
|
|
48
50
|
}
|
|
49
51
|
static loadModel(t, r) {
|
|
50
52
|
const e = new a(t);
|
|
@@ -59,7 +61,7 @@ class a extends c {
|
|
|
59
61
|
}), e;
|
|
60
62
|
}
|
|
61
63
|
static create(t, r = {}) {
|
|
62
|
-
const e = { ...d, ...r }, s = new g(e.vocabSize), o = new
|
|
64
|
+
const e = { ...d, ...r }, s = new g(e.vocabSize), o = new m(t, e), i = new a(t, s, o);
|
|
63
65
|
return i.setStatus("warmup"), h(o).then(() => {
|
|
64
66
|
i.tokeniser.trained ? i.setStatus("ready") : (i.setStatus("awaitingTokens"), i.tokeniser.once("trainStatus", (n) => {
|
|
65
67
|
n === "trained" && i.setStatus("ready");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadDOCX(file: Blob | Uint8Array): Promise<string[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { j as a } from "../jszip.min-CjP2V1VV.js";
|
|
2
|
+
async function c(n) {
|
|
3
|
+
const t = await (await a.loadAsync(n)).file("word/document.xml")?.async("string");
|
|
4
|
+
if (!t) throw new Error("Failed to load document.xml");
|
|
5
|
+
return s(t).split(`
|
|
6
|
+
`).filter((r) => r.trim().length > 10);
|
|
7
|
+
}
|
|
8
|
+
function s(n) {
|
|
9
|
+
const t = new DOMParser().parseFromString(n, "application/xml");
|
|
10
|
+
return Array.from(t.getElementsByTagName("w:t")).map((r) => r.textContent).join(`
|
|
11
|
+
`);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
c as loadDOCX
|
|
15
|
+
};
|
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: Blob | Uint8Array, maxSize?: number): Promise<string[]>;
|