10 lines
326 B
TypeScript
10 lines
326 B
TypeScript
import { pipeline } from "@xenova/transformers";
|
|
const pipePromise = pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
|
|
async function getEmbeddingFromText(text) {
|
|
const pipe = await pipePromise;
|
|
const output = await pipe(text, {
|
|
pooling: "mean",
|
|
normalize: true,
|
|
});
|
|
return Array.from(output.data);
|
|
}
|