Skip to content

Commit 772360e

Browse files
committed
Merge branch 'refactor' into release/v1.1.0-alpha.3
2 parents 6a6b0b5 + 1f70046 commit 772360e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"prebuild": "rimraf dist",
2323
"build": "tsc",
2424
"watch": "tsc -w",
25-
"start": "npm run build && fastify start -T 60000 -l info dist/app.js",
25+
"start": "npm run build && fastify start -T 60000 -l info dist/app.js -- --workerTaskTimeout 10000",
2626
"download-default-model": "node ./dist/loadDefaultModel.js",
2727
"dev": "npm run build && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"npm:watch\" \"npm:dev:start\"",
2828
"dev:start": "fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js",

src/libs/EmbeddingEncoder.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class EmbeddingEncoder {
209209

210210
// Run tokenization
211211
const model_inputs = this.tokenizer(texts, {
212-
padding: true,
212+
padding: typeof texts !== "string",
213213
truncation: true,
214214
max_length:
215215
typeof max_length !== "undefined" && max_length > 0
@@ -334,6 +334,8 @@ class EmbeddingEncoder {
334334
`Model \`${model}\` is not supported. Supported models: ${this.supportModels.join(", ")}`
335335
);
336336
}
337+
const modelOpts = this.getModelByName(model);
338+
const { max_length } = modelOpts;
337339
opts = {
338340
...opts,
339341
...(typeof opts.padding !== "boolean" ? { padding: true } : {}),
@@ -343,8 +345,12 @@ class EmbeddingEncoder {
343345
};
344346

345347
return this.tokenizer(texts, {
346-
padding: true,
347-
truncation: true
348+
padding: typeof texts !== "string",
349+
truncation: true,
350+
max_length:
351+
typeof max_length !== "undefined" && max_length > 0
352+
? max_length
353+
: DEFAULT_MAX_LENGTH
348354
});
349355
}
350356
}

0 commit comments

Comments
 (0)