Enable quantized embedder for speed boost
This commit is contained in:
@@ -4,7 +4,7 @@ import { parentPort } from 'worker_threads';
|
||||
let embedder: any;
|
||||
|
||||
parentPort?.on('message', async ({ id, text, model }) => {
|
||||
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model);
|
||||
if(!embedder) embedder = await pipeline('feature-extraction', 'Xenova/' + model, {quantized: true});
|
||||
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