File size: 396 Bytes
fbe0334
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
import { env, pipeline } from "@xenova/transformers";

let pipe: Function | null = null;
const piping = pipeline("feature-extraction", "sentence-transformers/paraphrase-multilingual-mpnet-base-v2", { local_files_only: true, quantized: true }).then(p => { pipe = p; })

export async function embedding_calc(text: string) {
    await piping;
    if (pipe) {
        return await pipe(text);
    }
}