@genai-fi/nanogpt 0.23.0 → 1.0.0
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/README.md +78 -281
- package/dist/{DatasetBuilder-C0iJT29K.js → DatasetBuilder-DU1G1OKX.js} +20 -23
- package/dist/{RealDiv-CNsvC4AU.js → RealDiv-CSnvtN2E.js} +20 -20
- package/dist/{Reshape-dnm9bO3B.js → Reshape-BlylqwWy.js} +12 -12
- package/dist/TeachableLLM.d.ts +10 -15
- package/dist/TeachableLLM.js +201 -2
- package/dist/api/responses.d.ts +81 -0
- package/dist/api/responses.js +169 -0
- package/dist/api/training.d.ts +70 -0
- package/dist/api/training.js +205 -0
- package/dist/data/docx.js +9 -3036
- package/dist/data/stream.d.ts +8 -8
- package/dist/data/stream.js +1 -1
- package/dist/data/textLoader.d.ts +1 -1
- package/dist/data/textLoader.js +2 -2
- package/dist/data.d.ts +3 -0
- package/dist/data.js +12 -0
- package/dist/{dist-BqAU9-yi.js → dist-CwK5S7Ls.js} +2168 -2168
- package/dist/{gpgpu_math-DBYEAAdI.js → gpgpu_math-20tPK8LM.js} +458 -458
- package/dist/{Generator.d.ts → inference/Generator.d.ts} +16 -44
- package/dist/inference/Generator.js +271 -0
- package/dist/inference/tokenisePrompt.d.ts +4 -0
- package/dist/inference/tokenisePrompt.js +13 -0
- package/dist/inference/types.d.ts +44 -8
- package/dist/inference/utilities.d.ts +9 -0
- package/dist/inference/utilities.js +20 -0
- package/dist/jszip.min-DKa1Rjyn.js +3033 -0
- package/dist/{kernel_funcs_utils-D-mATnGR.js → kernel_funcs_utils-ql8Y8qPn.js} +96 -93
- package/dist/layers/MLP.d.ts +1 -1
- package/dist/layers/PositionEmbedding.d.ts +2 -1
- package/dist/layers/PositionEmbedding.js +1 -1
- package/dist/layers/RMSNorm.d.ts +1 -1
- package/dist/layers/TiedEmbedding.js +1 -1
- package/dist/layers.d.ts +4 -0
- package/dist/layers.js +14 -0
- package/dist/loader/load.js +58 -2
- package/dist/loader/loadHF.d.ts +1 -1
- package/dist/loader/loadHF.js +17 -2
- package/dist/loader/loadTransformers.js +46 -2
- package/dist/loader/newZipLoad.js +25 -2
- package/dist/loader/oldZipLoad.d.ts +1 -1
- package/dist/loader/oldZipLoad.js +37 -2
- package/dist/loader/save.js +75 -2
- package/dist/loader/types.d.ts +3 -3
- package/dist/main.d.ts +34 -43
- package/dist/main.js +12327 -20
- package/dist/{matMulGelu-BAIgQaRx.js → matMulGelu-CBoqTZM7.js} +2 -2
- package/dist/models/NanoGPTV1.js +95 -2
- package/dist/models/NanoGPTV2.js +86 -2
- package/dist/models/factory.js +13 -2
- package/dist/models/model.js +76 -2
- package/dist/models.d.ts +4 -0
- package/dist/models.js +14 -0
- package/dist/ops/dot16.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/webgl/adamAdjust.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +2 -2
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +5 -5
- package/dist/ops/webgl/matMulGelu.js +1 -1
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/{stream-BjdpSNqB.js → stream-BpAwcvHz.js} +565 -561
- package/dist/{tfjs_backend-CydPRQTc.js → tfjs_backend-h5weiy1O.js} +36 -36
- package/dist/tokenise.d.ts +4 -0
- package/dist/tokenise.js +15 -0
- package/dist/tokeniser/CharTokeniser.js +18 -20
- package/dist/tokeniser/bpe.js +18 -22
- package/dist/training/BasicTrainer.d.ts +5 -10
- package/dist/training/BasicTrainer.js +80 -88
- package/dist/training/DatasetBuilder.d.ts +4 -4
- package/dist/training/DatasetBuilder.js +1 -1
- package/dist/training/PreTrainer.js +1 -1
- package/dist/training/SFTTrainer.js +1 -1
- package/dist/training/configure.d.ts +3 -0
- package/dist/training/configure.js +32 -0
- package/dist/training/factory.d.ts +6 -0
- package/dist/training/factory.js +8 -0
- package/dist/training/prepareData.d.ts +22 -0
- package/dist/training/prepareData.js +49 -0
- package/dist/training/tasks/TokenStore.d.ts +2 -1
- package/dist/training/tasks/TokenStore.js +8 -5
- package/dist/training/tasks/tokenStream.d.ts +17 -0
- package/dist/training/tasks/tokenStream.js +46 -0
- package/dist/training/types.d.ts +14 -1
- package/dist/training/validateOptions.d.ts +2 -0
- package/dist/training/validateOptions.js +19 -0
- package/dist/training/validation.js +4 -2
- package/dist/utilities/arrayShape.d.ts +1 -0
- package/dist/utilities/arrayShape.js +8 -0
- package/dist/utilities/random.d.ts +1 -0
- package/dist/utilities/random.js +19 -0
- package/dist/utilities/waitForModel.d.ts +1 -1
- package/dist/v4-BK7K-jy_.js +30 -0
- package/package.json +8 -2
- package/dist/Generator.js +0 -2
- package/dist/Trainer-DBsyWJ4s.js +0 -228
- package/dist/Trainer.d.ts +0 -45
- package/dist/Trainer.js +0 -2
- package/dist/main-BSaDGH7I.js +0 -13274
- package/dist/training/tasks/ConversationTask.d.ts +0 -17
- package/dist/training/tasks/ConversationTask.js +0 -29
- package/dist/training/tasks/PretrainingTask.d.ts +0 -17
- package/dist/training/tasks/PretrainingTask.js +0 -42
- package/dist/training/tasks/StartSentenceTask.d.ts +0 -18
- package/dist/training/tasks/StartSentenceTask.js +0 -45
- package/dist/training/tasks/Task.d.ts +0 -29
- package/dist/training/tasks/Task.js +0 -50
- package/dist/training/tasks/splitter.d.ts +0 -5
- package/dist/training/tasks/splitter.js +0 -18
package/dist/Trainer-DBsyWJ4s.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { packingSupported as e } from "./utilities/packed.js";
|
|
2
|
-
import { t } from "./eventemitter3-D_qV3Lof.js";
|
|
3
|
-
import n from "./training/PreTrainer.js";
|
|
4
|
-
import { TokenStore as r } from "./training/tasks/TokenStore.js";
|
|
5
|
-
import { tokensFromTasks as i } from "./training/tasks/Task.js";
|
|
6
|
-
import { createTrainValidationDatasets as a, storeFromArray as o } from "./training/validation.js";
|
|
7
|
-
import s from "./training/SFTTrainer.js";
|
|
8
|
-
//#region node_modules/uuid/dist/stringify.js
|
|
9
|
-
var c = [];
|
|
10
|
-
for (let e = 0; e < 256; ++e) c.push((e + 256).toString(16).slice(1));
|
|
11
|
-
function l(e, t = 0) {
|
|
12
|
-
return (c[e[t + 0]] + c[e[t + 1]] + c[e[t + 2]] + c[e[t + 3]] + "-" + c[e[t + 4]] + c[e[t + 5]] + "-" + c[e[t + 6]] + c[e[t + 7]] + "-" + c[e[t + 8]] + c[e[t + 9]] + "-" + c[e[t + 10]] + c[e[t + 11]] + c[e[t + 12]] + c[e[t + 13]] + c[e[t + 14]] + c[e[t + 15]]).toLowerCase();
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region node_modules/uuid/dist/rng.js
|
|
16
|
-
var u = new Uint8Array(16);
|
|
17
|
-
function d() {
|
|
18
|
-
return crypto.getRandomValues(u);
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region node_modules/uuid/dist/v4.js
|
|
22
|
-
function f(e, t, n) {
|
|
23
|
-
return !t && !e && crypto.randomUUID ? crypto.randomUUID() : p(e, t, n);
|
|
24
|
-
}
|
|
25
|
-
function p(e, t, n) {
|
|
26
|
-
e ||= {};
|
|
27
|
-
let r = e.random ?? e.rng?.() ?? d();
|
|
28
|
-
if (r.length < 16) throw Error("Random bytes length must be >= 16");
|
|
29
|
-
if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, t) {
|
|
30
|
-
if (n ||= 0, n < 0 || n + 16 > t.length) throw RangeError(`UUID byte range ${n}:${n + 15} is out of buffer bounds`);
|
|
31
|
-
for (let e = 0; e < 16; ++e) t[n + e] = r[e];
|
|
32
|
-
return t;
|
|
33
|
-
}
|
|
34
|
-
return l(r);
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region lib/Trainer.ts
|
|
38
|
-
var m = class c extends t {
|
|
39
|
-
trainer;
|
|
40
|
-
trainingType = "pretraining";
|
|
41
|
-
hasTrained = !1;
|
|
42
|
-
trainDataset;
|
|
43
|
-
validationDataset;
|
|
44
|
-
totalTokens = 0;
|
|
45
|
-
tokensProcessed = 0;
|
|
46
|
-
log = [];
|
|
47
|
-
progress = null;
|
|
48
|
-
options = {
|
|
49
|
-
batchSize: 32,
|
|
50
|
-
sftMode: "full",
|
|
51
|
-
logInterval: 10
|
|
52
|
-
};
|
|
53
|
-
tokenizer;
|
|
54
|
-
constructor(t, r, i, a, o) {
|
|
55
|
-
if (super(), t instanceof c) {
|
|
56
|
-
let e = r || t.options, a = t.options, o = !1;
|
|
57
|
-
if (t.trainingType === "sft" && e.sftMode !== a.sftMode && (o = !0), t.trainer instanceof s && t.trainer.loraName && e.loraName !== t.trainer.loraName && (o = !0), i !== void 0 && i !== t.trainingType && (o = !0), o) {
|
|
58
|
-
if (t.trainingType === "sft") {
|
|
59
|
-
let n = new s(t.model, t.tokenizer, e);
|
|
60
|
-
this.trainer = n, n.loraName = e.loraName;
|
|
61
|
-
} else this.trainer = new n(t.model, t.tokenizer, e);
|
|
62
|
-
this.trainingType = i || t.trainingType, this.options = e, this.tokenizer = t.tokenizer;
|
|
63
|
-
} else this.trainer = t.trainer, this.trainingType = i || t.trainingType, this.options = e, this.trainer.updateOptimizer(this.options), this.log = t.log, this.progress = t.progress, this.totalTokens = t.totalTokens, this.tokenizer = t.tokenizer, e.batchSize === a.batchSize && (this.trainDataset = t.trainDataset, this.validationDataset = t.validationDataset);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (!r) throw Error("Tokeniser must be provided when initializing Trainer with a model");
|
|
67
|
-
if (!t) throw Error("Model must be provided when initializing Trainer");
|
|
68
|
-
this.options = a || {
|
|
69
|
-
batchSize: 32,
|
|
70
|
-
sftMode: "full"
|
|
71
|
-
};
|
|
72
|
-
let l = this.options.mixedPrecision && e();
|
|
73
|
-
if (this.options.lossScaling = l ? t.lossScaling : 1, i === "sft") {
|
|
74
|
-
let e = new s(t, r, this.options, o);
|
|
75
|
-
this.trainer = e, e.loraName = a?.loraName;
|
|
76
|
-
} else this.trainer = new n(t, r, this.options, o);
|
|
77
|
-
this.trainingType = i || "pretraining", this.tokenizer = r;
|
|
78
|
-
}
|
|
79
|
-
get model() {
|
|
80
|
-
return this.trainer.model;
|
|
81
|
-
}
|
|
82
|
-
get optimizer() {
|
|
83
|
-
return this.trainer.optimizer;
|
|
84
|
-
}
|
|
85
|
-
get isTraining() {
|
|
86
|
-
return this.trainer.isRunning;
|
|
87
|
-
}
|
|
88
|
-
stop() {
|
|
89
|
-
this.trainer.stop();
|
|
90
|
-
}
|
|
91
|
-
reset() {
|
|
92
|
-
this.hasTrained = !1, this.log = [], this.trainer.reset();
|
|
93
|
-
}
|
|
94
|
-
dispose() {
|
|
95
|
-
this.trainer.dispose(), this.removeAllListeners();
|
|
96
|
-
}
|
|
97
|
-
getTotalTokens() {
|
|
98
|
-
return this.totalTokens;
|
|
99
|
-
}
|
|
100
|
-
setOptions(e) {
|
|
101
|
-
let t = new Set(Object.keys(e).filter((t) => e[t] !== this.options[t]));
|
|
102
|
-
if (this.trainer.isRunning) {
|
|
103
|
-
if (t.has("batchSize")) throw Error("Cannot change batch size during training");
|
|
104
|
-
if (t.has("sftMode")) throw Error("Cannot change SFT mode during training");
|
|
105
|
-
if (t.has("loraConfig")) throw Error("Cannot change LoRA configuration during training");
|
|
106
|
-
if (t.has("validationSplit")) throw Error("Cannot change validation split during training");
|
|
107
|
-
if (t.has("trainableWeights")) throw Error("Cannot change trainable weights during training");
|
|
108
|
-
if (t.has("mixedPrecision")) throw Error("Cannot change mixed precision setting during training");
|
|
109
|
-
if (t.has("gradientCheckpointing")) throw Error("Cannot change gradient checkpointing setting during training");
|
|
110
|
-
}
|
|
111
|
-
this.options = {
|
|
112
|
-
...this.options,
|
|
113
|
-
...e
|
|
114
|
-
}, this.trainer.updateOptimizer(this.options), t.has("metrics") && this.trainer.setMetrics(e.metrics || []);
|
|
115
|
-
}
|
|
116
|
-
async prepare(e = [], t, n) {
|
|
117
|
-
let c = this.options, l = c.loraName || c.loraConfig;
|
|
118
|
-
if (n && l) throw Error("Cannot specify datasets when using LoRA fine-tuning");
|
|
119
|
-
if (!n && !l) throw Error("Must specify datasets for non-LoRA training");
|
|
120
|
-
if (n) {
|
|
121
|
-
let e = this.model.metaData.pretrainingData || [], t = [...e], r = !1;
|
|
122
|
-
for (let i of n) e.some((e) => e.id === i.id) || t.push({
|
|
123
|
-
id: i.id,
|
|
124
|
-
name: i.name,
|
|
125
|
-
conversational: i.conversational
|
|
126
|
-
}), i.conversational && (r = !0);
|
|
127
|
-
this.model.metaData.pretrainingData = t, r ? this.model.metaData.mode = "conversational" : this.model.metaData.mode !== "conversational" && (this.model.metaData.mode = "completion");
|
|
128
|
-
} else this.model.metaData.mode !== "conversational" && (this.model.metaData.mode = "completion");
|
|
129
|
-
let u = c.maskedLoss ?? this.trainingType === "sft";
|
|
130
|
-
if (this.trainingType === "sft" && this.trainer instanceof s && e instanceof Uint16Array) throw Error("SFT training requires Task[] input");
|
|
131
|
-
let d, f = t;
|
|
132
|
-
if (Array.isArray(e)) if (e[0] instanceof Uint16Array) d = e;
|
|
133
|
-
else {
|
|
134
|
-
let n = await i(e, this.trainer.tokenizer, {
|
|
135
|
-
masking: u,
|
|
136
|
-
validationSplit: c.validationSplit
|
|
137
|
-
});
|
|
138
|
-
d = n.trainingTokens, t || (f = n.validationTokens);
|
|
139
|
-
}
|
|
140
|
-
else d = e;
|
|
141
|
-
let p = d instanceof r ? d.getTokenCount() : d.reduce((e, t) => e + t.length, 0);
|
|
142
|
-
if (f) {
|
|
143
|
-
let { trainDataset: e, validationDataset: t } = await a(d, f, this.trainer.tokenizer, this.trainer.datasetBuilder, c?.batchSize || 32);
|
|
144
|
-
this.trainDataset = e, this.validationDataset = t;
|
|
145
|
-
} else {
|
|
146
|
-
let e = d instanceof r ? d : await o(d, this.trainer.tokenizer);
|
|
147
|
-
this.trainDataset = (await this.trainer.datasetBuilder.createTextDataset(e, c)).dataset;
|
|
148
|
-
}
|
|
149
|
-
this.totalTokens = p, this.options.epochSteps = Math.ceil(this.totalTokens / ((c?.batchSize || 32) * this.model.config.blockSize)), this.trainer.updateOptimizer(this.options);
|
|
150
|
-
}
|
|
151
|
-
configureModel(e) {
|
|
152
|
-
let t = e?.sftMode || "full";
|
|
153
|
-
if (this.trainingType === "pretraining" && (this.trainer.model.hasLoRA() && this.trainer.model.detachLoRA(), this.trainer.model.weightStore.setTrainable(["*"])), this.trainingType === "sft") {
|
|
154
|
-
if (t === "lora") {
|
|
155
|
-
let t = this.trainer.model;
|
|
156
|
-
if (e?.loraName) {
|
|
157
|
-
if (!t.hasLoRA(e.loraName)) if (e.loraConfig) t.createLoRA(e.loraName, e.loraConfig), t.attachLoRA(e.loraName);
|
|
158
|
-
else throw Error(`LoRA configuration must be provided to create LoRA with name ${e.loraName}`);
|
|
159
|
-
else if (t.attachLoRA(e.loraName), e.loraConfig) {
|
|
160
|
-
let n = t.lora;
|
|
161
|
-
(n.alpha !== e.loraConfig.alpha || n.rank !== e.loraConfig.rank) && (t.detachLoRA(), t.deleteLoRA(e.loraName), t.createLoRA(e.loraName, e.loraConfig), t.attachLoRA(e.loraName), console.warn("Resetting LoRA with new configuration."));
|
|
162
|
-
}
|
|
163
|
-
} else if (e?.loraConfig) if (t.hasLoRA()) {
|
|
164
|
-
let n = t.lora;
|
|
165
|
-
if (n.alpha !== e.loraConfig.alpha || n.rank !== e.loraConfig.rank) {
|
|
166
|
-
t.detachLoRA();
|
|
167
|
-
let n = e.loraName || f();
|
|
168
|
-
t.createLoRA(n, e.loraConfig), t.attachLoRA(n);
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
171
|
-
let n = e.loraName || f();
|
|
172
|
-
t.createLoRA(n, e.loraConfig), t.attachLoRA(n);
|
|
173
|
-
}
|
|
174
|
-
else if (!t.hasLoRA()) throw Error("LoRA configuration must be provided for lora SFT mode");
|
|
175
|
-
} else this.trainer.model.hasLoRA() && this.trainer.model.detachLoRA();
|
|
176
|
-
t === "last-layer" ? this.trainer.model.weightStore.setTrainable([`block_${this.trainer.model.config.nLayer - 1}_*`, "token_embedding"]) : t === "full" && this.trainer.model.weightStore.setTrainable(["*"]);
|
|
177
|
-
}
|
|
178
|
-
e?.trainableWeights && this.trainer.model.weightStore.setTrainable(e.trainableWeights);
|
|
179
|
-
}
|
|
180
|
-
async train() {
|
|
181
|
-
let e = this.options;
|
|
182
|
-
if (!this.trainDataset) throw Error("Dataset not prepared");
|
|
183
|
-
this.hasTrained || this.trainer.setLearningRate(e?.learningRate || .001), this.hasTrained = !0, this.emit("start"), this.model.metaData.pretrainingSettings = e;
|
|
184
|
-
let t = Date.now();
|
|
185
|
-
this.log.length > 0 && this.trainer.resumeFromLog(this.log[this.log.length - 1]), this.trainer.setGradientCheckpointing(e?.gradientCheckpointing || !1), this.trainer.setMixedPrecision(e?.mixedPrecision || !1), this.trainer.setLabelSmoothing(e?.labelSmoothing || 0), this.trainer.setDropout(e?.dropout || 0), this.trainer.setLayerDrop(e?.layerDrop || 0), this.configureModel(e), await this.trainer.trainOnDataset(this.trainDataset, {
|
|
186
|
-
...e,
|
|
187
|
-
onStep: async (e) => {
|
|
188
|
-
this.log.push(e), this.progress = {
|
|
189
|
-
lastLog: e,
|
|
190
|
-
progress: e.totalTokens / this.totalTokens,
|
|
191
|
-
remaining: Math.max(0, (this.totalTokens - e.totalTokens) / e.totalTokens * e.duration)
|
|
192
|
-
}, this.tokensProcessed = e.totalTokens;
|
|
193
|
-
let t = this.listeners("log");
|
|
194
|
-
for (let n of t) await n(e, this.progress);
|
|
195
|
-
}
|
|
196
|
-
}, this.validationDataset), this.model.metaData.actionLog = this.model.metaData.actionLog || [];
|
|
197
|
-
let n = Date.now();
|
|
198
|
-
this.model.metaData.actionLog.push({
|
|
199
|
-
action: "pretrain",
|
|
200
|
-
timestamp: n,
|
|
201
|
-
duration: n - t,
|
|
202
|
-
tokensProcessed: this.tokensProcessed,
|
|
203
|
-
options: e
|
|
204
|
-
}), this.emit("stop");
|
|
205
|
-
}
|
|
206
|
-
async step(e) {
|
|
207
|
-
if (!this.trainDataset) throw Error("Dataset not prepared");
|
|
208
|
-
this.hasTrained || this.trainer.setLearningRate(e?.learningRate || .001), this.hasTrained = !0, this.emit("start");
|
|
209
|
-
let { log: t } = await this.trainer.stepDataset(this.trainDataset, e || {}, this.validationDataset), n = this.listeners("log");
|
|
210
|
-
for (let e of n) await e(t, {
|
|
211
|
-
lastLog: t,
|
|
212
|
-
progress: t.totalTokens / this.totalTokens,
|
|
213
|
-
remaining: Math.max(0, (this.totalTokens - t.totalTokens) / t.totalTokens * t.duration)
|
|
214
|
-
});
|
|
215
|
-
this.emit("stop");
|
|
216
|
-
}
|
|
217
|
-
getLog() {
|
|
218
|
-
return this.log;
|
|
219
|
-
}
|
|
220
|
-
getProgress() {
|
|
221
|
-
return this.progress;
|
|
222
|
-
}
|
|
223
|
-
isPrepared() {
|
|
224
|
-
return this.trainDataset !== void 0 && this.validationDataset !== void 0;
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
//#endregion
|
|
228
|
-
export { m as t };
|
package/dist/Trainer.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ITokeniser } from './tokeniser/type';
|
|
2
|
-
import { default as EE } from 'eventemitter3';
|
|
3
|
-
import { default as Model, ModelForwardAttributes } from './models/model';
|
|
4
|
-
import { Task } from './training/tasks/Task';
|
|
5
|
-
import { TrainingOptions, TrainingLogEntry } from './training/types';
|
|
6
|
-
import { AdamWOptimizer } from './training/AdamW';
|
|
7
|
-
import { DatasetMetadata } from './loader/types';
|
|
8
|
-
import { TokenStore } from './training/tasks/TokenStore';
|
|
9
|
-
interface TrainingProgress {
|
|
10
|
-
lastLog: TrainingLogEntry;
|
|
11
|
-
progress: number;
|
|
12
|
-
remaining: number;
|
|
13
|
-
}
|
|
14
|
-
export type TrainingType = 'pretraining' | 'sft';
|
|
15
|
-
export default class Trainer extends EE<'start' | 'stop' | 'log'> {
|
|
16
|
-
private trainer;
|
|
17
|
-
readonly trainingType: TrainingType;
|
|
18
|
-
private hasTrained;
|
|
19
|
-
private trainDataset?;
|
|
20
|
-
private validationDataset?;
|
|
21
|
-
private totalTokens;
|
|
22
|
-
private tokensProcessed;
|
|
23
|
-
log: TrainingLogEntry[];
|
|
24
|
-
private progress;
|
|
25
|
-
options: TrainingOptions;
|
|
26
|
-
protected tokenizer: ITokeniser;
|
|
27
|
-
constructor(model: Model<ModelForwardAttributes>, tokeniser: ITokeniser, trainingType?: TrainingType, options?: TrainingOptions, optimizer?: AdamWOptimizer);
|
|
28
|
-
constructor(trainer: Trainer, options?: TrainingOptions);
|
|
29
|
-
get model(): Model<ModelForwardAttributes>;
|
|
30
|
-
get optimizer(): AdamWOptimizer;
|
|
31
|
-
get isTraining(): boolean;
|
|
32
|
-
stop(): void;
|
|
33
|
-
reset(): void;
|
|
34
|
-
dispose(): void;
|
|
35
|
-
getTotalTokens(): number;
|
|
36
|
-
setOptions(options: TrainingOptions): void;
|
|
37
|
-
prepare(tasks?: Task[] | Uint16Array[] | TokenStore, validation?: Uint16Array[] | TokenStore, datasets?: DatasetMetadata[]): Promise<void>;
|
|
38
|
-
private configureModel;
|
|
39
|
-
train(): Promise<void>;
|
|
40
|
-
step(options?: TrainingOptions): Promise<void>;
|
|
41
|
-
getLog(): TrainingLogEntry[];
|
|
42
|
-
getProgress(): TrainingProgress | null;
|
|
43
|
-
isPrepared(): boolean;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
package/dist/Trainer.js
DELETED