const model = new HuggingFaceTransformersEmbeddings({
model: "Xenova/all-MiniLM-L6-v2",
});

// Embed a single query
const res = await model.embedQuery(
"What would be a good company name for a company that makes colorful socks?"
);
console.log({ res });

// Embed multiple documents
const documentRes = await model.embedDocuments(["Hello world", "Bye bye"]);
console.log({ documentRes });

Hierarchy (view full)

  • Toolkit
    • HuggingFaceTransformersEmbeddings

Implements

Constructors

Properties

batchSize: number = 512

The maximum number of documents to embed in a single request.

model: string = "Xenova/all-MiniLM-L6-v2"

Model name to use

modelName: string = "Xenova/all-MiniLM-L6-v2"

Model name to use Alias for model

stripNewLines: boolean = true

Whether to strip new lines from the input text. This is recommended by OpenAI, but may not be suitable for all use cases.

timeout?: number

Timeout to use when making requests to OpenAI.

Methods