Added save directory for embedder
This commit is contained in:
@@ -3,8 +3,11 @@ import { parentPort } from 'worker_threads';
|
||||
|
||||
let embedder: any;
|
||||
|
||||
parentPort?.on('message', async ({ id, text, model }) => {
|
||||
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model, {quantized: true});
|
||||
parentPort?.on('message', async ({ id, text, model, path }) => {
|
||||
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model, {
|
||||
quantized: true,
|
||||
cache_dir: path,
|
||||
});
|
||||
const output = await embedder(text, { pooling: 'mean', normalize: true });
|
||||
const embedding = Array.from(output.data);
|
||||
parentPort?.postMessage({ id, embedding });
|
||||
|
||||
Reference in New Issue
Block a user