@genai-fi/nanogpt 0.20.4 → 0.20.6
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 +1 -1
- package/dist/TeachableLLM.js +1 -1
- package/dist/Trainer.d.ts +1 -0
- package/dist/Trainer.js +1 -1
- package/dist/loader/load.js +1 -1
- package/dist/loader/loadHF.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/newZipLoad.js +1 -1
- package/dist/loader/oldZipLoad.js +1 -1
- package/dist/loader/save.js +1 -1
- package/dist/{main-BqRjvJ8B.js → main-C0YUnw98.js} +20 -17
- package/dist/main.js +1 -1
- package/dist/models/NanoGPTV1.js +1 -1
- package/dist/models/NanoGPTV2.js +1 -1
- package/dist/models/factory.js +1 -1
- package/dist/models/model.js +1 -1
- package/dist/training/validation.js +1 -1
- package/package.json +1 -1
package/dist/Generator.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as e, s as t } from "./main-
|
|
1
|
+
import { c as e, s as t } from "./main-C0YUnw98.js";
|
|
2
2
|
export { t as default, e as isConversation };
|
package/dist/TeachableLLM.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as e } from "./main-
|
|
1
|
+
import { i as e } from "./main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
package/dist/Trainer.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export default class Trainer extends EE<'start' | 'stop' | 'log'> {
|
|
|
27
27
|
constructor(trainer: Trainer, options?: TrainingOptions);
|
|
28
28
|
get model(): Model<ModelForwardAttributes>;
|
|
29
29
|
get optimizer(): AdamWOptimizer;
|
|
30
|
+
get isTraining(): boolean;
|
|
30
31
|
stop(): void;
|
|
31
32
|
reset(): void;
|
|
32
33
|
dispose(): void;
|
package/dist/Trainer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e } from "./main-
|
|
1
|
+
import { a as e } from "./main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
package/dist/loader/load.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as e, u as t } from "../main-
|
|
1
|
+
import { d as e, u as t } from "../main-C0YUnw98.js";
|
|
2
2
|
export { t as VERSION, e as loadModel };
|
package/dist/loader/loadHF.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { f as e } from "../main-
|
|
1
|
+
import { f as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { h as e, m as t } from "../main-
|
|
1
|
+
import { h as e, m as t } from "../main-C0YUnw98.js";
|
|
2
2
|
export { t as default, e as mapTransformersConfigToGPTConfig };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { p as e } from "../main-
|
|
1
|
+
import { p as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { g as e } from "../main-
|
|
1
|
+
import { g as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
package/dist/loader/save.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { l as e } from "../main-
|
|
1
|
+
import { l as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as saveModel };
|
|
@@ -12829,7 +12829,7 @@ var bS = class extends hc {
|
|
|
12829
12829
|
}
|
|
12830
12830
|
async tokenisePrompt(e, t, n) {
|
|
12831
12831
|
if (t) {
|
|
12832
|
-
let r = t.length > 0 && t[t.length - 1].role === "
|
|
12832
|
+
let r = t.length > 0 && t[t.length - 1].role === "text", i = [];
|
|
12833
12833
|
return i = n?.nonConversational ? r && n?.continuation ? [e.bosToken, ...e.encode(t[t.length - 1].content)] : e.encodeAsSequence(t, !0) : e.encodeConversation(t, !0), i.length > this.model.config.blockSize && (i = i.slice(-this.model.config.blockSize)), ce([i], [1, i.length], "int32");
|
|
12834
12834
|
} else {
|
|
12835
12835
|
let t = n?.nonConversational ? void 0 : e.getSpecialTokenIndex("<|assistant_start|>"), r = t === void 0 ? [e.bosToken] : [e.bosToken, t];
|
|
@@ -12947,32 +12947,32 @@ var bS = class extends hc {
|
|
|
12947
12947
|
multinomialRand: p
|
|
12948
12948
|
};
|
|
12949
12949
|
}
|
|
12950
|
-
async _generate(e) {
|
|
12951
|
-
let
|
|
12952
|
-
this.outputConversation.length === 0 || this.outputConversation[this.outputConversation.length - 1]._completed || this.outputConversation[this.outputConversation.length - 1].role !== "assistant" ? (this.outputConversation.push({
|
|
12953
|
-
role: "assistant",
|
|
12950
|
+
async _generate(e, t) {
|
|
12951
|
+
let n = !1;
|
|
12952
|
+
this.outputConversation.length === 0 || this.outputConversation[this.outputConversation.length - 1]._completed || this.outputConversation[this.outputConversation.length - 1].role !== "assistant" && e?.nonConversational !== !0 || this.outputConversation[this.outputConversation.length - 1].role !== "text" && e?.nonConversational === !0 ? (this.outputConversation.push({
|
|
12953
|
+
role: e?.nonConversational === !0 ? "text" : "assistant",
|
|
12954
12954
|
content: "",
|
|
12955
12955
|
_timestamp: Date.now()
|
|
12956
|
-
}),
|
|
12957
|
-
let
|
|
12958
|
-
for (let t = 0; t <
|
|
12959
|
-
let { output:
|
|
12956
|
+
}), n = !0, this.resetCache(!e?.noCache)) : (this.lastToken < 0 || t) && this.resetCache(!e?.noCache);
|
|
12957
|
+
let r = this.lastToken >= 0 && this.cache ? ce([this.lastToken], [1, 1], "int32") : await this.tokenisePrompt(this.actualTokeniser, t ? n ? this.outputConversation.slice(0, -1) : this.outputConversation : void 0, e), i = e?.maxLength ?? 1e3;
|
|
12958
|
+
for (let t = 0; t < i && this.active; t++) {
|
|
12959
|
+
let { output: n, probabilities: a, attention: o, loss: s, multinomialRand: c } = await this._generateToken(r, this.cache ? this.cache : void 0, {
|
|
12960
12960
|
...e,
|
|
12961
12961
|
usePadding: !this.cache
|
|
12962
12962
|
});
|
|
12963
|
-
if (this.lastMultinomialRand = c, s !== void 0 && (this.lastLoss = s), this.cache)
|
|
12963
|
+
if (this.lastMultinomialRand = c, s !== void 0 && (this.lastLoss = s), this.cache) r.dispose(), r = n;
|
|
12964
12964
|
else {
|
|
12965
|
-
let e =
|
|
12966
|
-
|
|
12965
|
+
let e = r;
|
|
12966
|
+
r = kt([r, n], 1), e.dispose();
|
|
12967
12967
|
}
|
|
12968
|
-
let l = await this.processResponse(this.actualTokeniser,
|
|
12969
|
-
if (this.cache ||
|
|
12968
|
+
let l = await this.processResponse(this.actualTokeniser, n, e?.allowSpecial ?? !1, o, a);
|
|
12969
|
+
if (this.cache || n.dispose(), l === null) {
|
|
12970
12970
|
this.outputConversation[this.outputConversation.length - 1]._completed = !0;
|
|
12971
12971
|
break;
|
|
12972
12972
|
}
|
|
12973
|
-
t ===
|
|
12973
|
+
t === i - 1 && i > 1 && (this.outputConversation[this.outputConversation.length - 1]._completed = !0), this.outputConversation[this.outputConversation.length - 1].content += l;
|
|
12974
12974
|
}
|
|
12975
|
-
return
|
|
12975
|
+
return r.dispose(), this.outputConversation;
|
|
12976
12976
|
}
|
|
12977
12977
|
resetCache(e) {
|
|
12978
12978
|
this.cache && (this.cache.forEach((e) => {
|
|
@@ -13036,7 +13036,7 @@ var bS = class extends hc {
|
|
|
13036
13036
|
}
|
|
13037
13037
|
async startJob(e, t) {
|
|
13038
13038
|
this.initialise(e, t), this.active = !0, this.model.metaData.generationSettings = t, t?.maxLength !== 1 && this.emit("start");
|
|
13039
|
-
let n = await this._generate(t);
|
|
13039
|
+
let n = await this._generate(t, !!e);
|
|
13040
13040
|
if (this.active = !1, this.startTime !== null) {
|
|
13041
13041
|
let e = Date.now(), n = e - this.startTime;
|
|
13042
13042
|
this.startTime = null, this.model.metaData.actionLog = this.model.metaData.actionLog || [], this.model.metaData.actionLog.push({
|
|
@@ -13178,6 +13178,9 @@ var DS = class e extends hc {
|
|
|
13178
13178
|
get optimizer() {
|
|
13179
13179
|
return this.trainer.optimizer;
|
|
13180
13180
|
}
|
|
13181
|
+
get isTraining() {
|
|
13182
|
+
return this.trainer.isRunning;
|
|
13183
|
+
}
|
|
13181
13184
|
stop() {
|
|
13182
13185
|
this.trainer.stop();
|
|
13183
13186
|
}
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, b as t, i as n, n as r, r as i, s as a, t as o, y as s } from "./main-
|
|
1
|
+
import { a as e, b as t, i as n, n as r, r as i, s as a, t as o, y as s } from "./main-C0YUnw98.js";
|
|
2
2
|
import c from "./tokeniser/CharTokeniser.js";
|
|
3
3
|
import l from "./tokeniser/bpe.js";
|
|
4
4
|
import { AdamWOptimizer as u } from "./training/AdamW.js";
|
package/dist/models/NanoGPTV1.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { y as e } from "../main-
|
|
1
|
+
import { y as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
package/dist/models/NanoGPTV2.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { v as e } from "../main-
|
|
1
|
+
import { v as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
package/dist/models/factory.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as e } from "../main-
|
|
1
|
+
import { _ as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
package/dist/models/model.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { b as e } from "../main-
|
|
1
|
+
import { b as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { o as e } from "../main-
|
|
1
|
+
import { o as e } from "../main-C0YUnw98.js";
|
|
2
2
|
export { e as createTrainValidationSplit };
|