@genai-fi/nanogpt 0.15.11 → 0.15.13
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.d.ts +2 -2
- package/dist/Generator.js +6 -4
- package/package.json +1 -1
package/dist/Generator.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface IGenerateOptions extends GenerateOptions {
|
|
|
19
19
|
nonConversational?: boolean;
|
|
20
20
|
continuation?: boolean;
|
|
21
21
|
}
|
|
22
|
-
export interface IGenerator extends EE<'start' | 'stop' | 'tokens'> {
|
|
22
|
+
export interface IGenerator extends EE<'start' | 'stop' | 'tokens' | 'reset'> {
|
|
23
23
|
generate(prompt: Conversation[], options?: IGenerateOptions): Promise<Conversation[]>;
|
|
24
24
|
generate(options?: IGenerateOptions): Promise<Conversation[]>;
|
|
25
25
|
step(prompt: Conversation[], options?: IGenerateOptions): Promise<Conversation[]>;
|
|
@@ -42,7 +42,7 @@ export interface IGenerator extends EE<'start' | 'stop' | 'tokens'> {
|
|
|
42
42
|
* Text generator using a NanoGPT model and a tokeniser.
|
|
43
43
|
* This uses the forward method of the model to generate text token by token, including options for temperature, top-k, and top-p sampling.
|
|
44
44
|
*/
|
|
45
|
-
export default class Generator extends EE<'start' | 'stop' | 'tokens'> implements IGenerator {
|
|
45
|
+
export default class Generator extends EE<'start' | 'stop' | 'tokens' | 'reset'> implements IGenerator {
|
|
46
46
|
private readonly model;
|
|
47
47
|
private readonly tokeniser;
|
|
48
48
|
private active;
|
package/dist/Generator.js
CHANGED
|
@@ -11757,9 +11757,11 @@ class AS extends Ui {
|
|
|
11757
11757
|
const C = Vd(g, r);
|
|
11758
11758
|
n?.includeProbabilities && (d = g), p = Wd(C, h);
|
|
11759
11759
|
} else if (o) {
|
|
11760
|
-
const { values: x, indices: g } = Bc(l, o)
|
|
11760
|
+
const { values: x, indices: g } = Bc(l, o);
|
|
11761
|
+
console.warn("Using broken multinomial");
|
|
11762
|
+
const C = Fn(x, 1);
|
|
11761
11763
|
p = Bd(g, C, 1), x.dispose(), g.dispose(), C.dispose();
|
|
11762
|
-
} else if (p = Fn(l, 1), n?.includeProbabilities) {
|
|
11764
|
+
} else if (console.warn("Using broken multinomial"), p = Fn(l, 1), n?.includeProbabilities) {
|
|
11763
11765
|
const x = gs(l);
|
|
11764
11766
|
d = await x.array(), x.dispose();
|
|
11765
11767
|
}
|
|
@@ -11837,11 +11839,11 @@ class AS extends Ui {
|
|
|
11837
11839
|
}
|
|
11838
11840
|
resetCache(t) {
|
|
11839
11841
|
this.cache && (this.cache.forEach((e) => {
|
|
11840
|
-
e && (e.k && e.k.dispose(), e.v && e.v.dispose(), e.k = void 0, e.v = void 0);
|
|
11842
|
+
e && (e.k && e.k.dispose(), e.v && e.v.dispose(), e.k = void 0, e.v = void 0, e.cumulativeLength = 0, e.length = 0);
|
|
11841
11843
|
}), t || (this.cache = null)), this.lastToken = -1;
|
|
11842
11844
|
}
|
|
11843
11845
|
reset() {
|
|
11844
|
-
this.resetCache(), this.outputConversation = [], this.initialPrompt = null, this.attentionData = [], this.probabilitiesData = [], this.tokens = [], this.lastLoss = null;
|
|
11846
|
+
this.resetCache(), this.outputConversation = [], this.initialPrompt = null, this.attentionData = [], this.probabilitiesData = [], this.tokens = [], this.lastLoss = null, this.emit("reset");
|
|
11845
11847
|
}
|
|
11846
11848
|
dispose() {
|
|
11847
11849
|
this.reset();
|