Skip to content

Commit 15e6860

Browse files
committed
LanguageModel: Rename the "steps" option to "maxTokens"
1 parent 8040dc4 commit 15e6860

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/LanguageModel/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class LanguageModel extends EventEmitter {
1818
this.options = {
1919
modelUrl: '', // if set, model.bin will be preloaded from provided URL (assumed to be embedded in llama2.data if not)
2020
tokenizerUrl: '', // if set, tokenizer.bin will be preloaded from provided URL (assumed to be embedded in llama2.data if not)
21-
steps: 0, // how many tokens to generate (defaults to model's maximum)
21+
maxTokens: 0, // how many tokens to generate (defaults to model's maximum)
2222
temperature: 1.0, // 0.0 = (deterministic) argmax sampling, 1.0 = baseline, don't set higher
2323
topp: 0.9, // p value in top-p (nucleus) sampling, 0 = off
2424
stopOnBosOrEos: true, // stop when encountering beginning-of-sequence or end-of-sequence token
@@ -163,7 +163,7 @@ class LanguageModel extends EventEmitter {
163163
this.callback = optionsOrCb;
164164
} else {
165165
if (typeof optionsOrCb === 'object') {
166-
this.options.steps = (typeof optionsOrCb.steps === 'number') ? optionsOrCb.steps : this.options.steps;
166+
this.options.maxTokens = (typeof optionsOrCb.maxTokens === 'number') ? optionsOrCb.maxTokens : this.options.maxTokens;
167167
this.options.temperature = (typeof optionsOrCb.temperature === 'number') ? optionsOrCb.temperature : this.options.temperature;
168168
this.options.topp = (typeof optionsOrCb.topp === 'number') ? optionsOrCb.topp : this.options.topp;
169169
this.options.stopOnBosOrEos = (typeof optionsOrCb.stopOnBosOrEos == 'boolean') ? optionsOrCb.stopPropagation : this.options.stopOnBosOrEos;
@@ -181,7 +181,7 @@ class LanguageModel extends EventEmitter {
181181
this.promiseResolve(this.text);
182182
}
183183

184-
await this.llama2.ccall('set_parameters', null, [ 'number', 'number', 'number' ], [ this.options.temperature, this.options.topp, this.options.steps ]);
184+
await this.llama2.ccall('set_parameters', null, [ 'number', 'number', 'number' ], [ this.options.temperature, this.options.topp, this.options.maxTokens ]);
185185

186186
this.prompt = prompt;
187187
this.text = '';
@@ -220,7 +220,7 @@ class LanguageModel extends EventEmitter {
220220
this.callback = optionsOrCb;
221221
} else {
222222
if (typeof optionsOrCb === 'object') {
223-
this.options.steps = (typeof optionsOrCb.steps === 'number') ? optionsOrCb.steps : this.options.steps;
223+
this.options.maxTokens = (typeof optionsOrCb.maxTokens === 'number') ? optionsOrCb.maxTokens : this.options.maxTokens;
224224
this.options.temperature = (typeof optionsOrCb.temperature === 'number') ? optionsOrCb.temperature : this.options.temperature;
225225
this.options.topp = (typeof optionsOrCb.topp === 'number') ? optionsOrCb.topp : this.options.topp;
226226
this.options.stopOnBosOrEos = (typeof optionsOrCb.stopOnBosOrEos == 'boolean') ? optionsOrCb.stopPropagation : this.options.stopOnBosOrEos;
@@ -238,7 +238,7 @@ class LanguageModel extends EventEmitter {
238238
this.promiseResolve(this.text);
239239
}
240240

241-
await this.llama2.ccall('set_parameters', null, [ 'number', 'number', 'number' ], [ this.options.temperature, this.options.topp, this.options.steps ]);
241+
await this.llama2.ccall('set_parameters', null, [ 'number', 'number', 'number' ], [ this.options.temperature, this.options.topp, this.options.maxTokens ]);
242242

243243
this.prompt = prompt;
244244
this.text = '';

0 commit comments

Comments
 (0)