Updataes?
All checks were successful
Publish Library / Build NPM Project (push) Successful in 26s
Publish Library / Tag Version (push) Successful in 5s

This commit is contained in:
2026-02-12 20:14:00 -05:00
parent ad1ee48763
commit e4399e1b7b
4 changed files with 12 additions and 15 deletions

View File

@@ -3,11 +3,8 @@ import { parentPort } from 'worker_threads';
let embedder: any;
parentPort?.on('message', async ({ id, text, model, path }) => {
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model, {
quantized: true,
cache_dir: path,
});
parentPort?.on('message', async ({ id, text, model, modelDir }) => {
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model, {quantized: true, cache_dir: modelDir});
const output = await embedder(text, { pooling: 'mean', normalize: true });
const embedding = Array.from(output.data);
parentPort?.postMessage({ id, embedding });