🍕 Features
The default model is Flag Embedding, which is top of the MTEB leaderboard.
🔍 Not looking for Javascript?
🤖 Models
🚀 Installation
To install the FastEmbed library, npm works:
npm install fastembed
📖 Usage
import { EmbeddingModel, FlagEmbedding } from "fastembed";
const embeddingModel = await FlagEmbedding.init({
model: EmbeddingModel.BGEBaseEN
});
let documents = [
"passage: Hello, World!",
"query: Hello, World!",
"passage: This is an example passage.",
"fastembed-js is licensed under MIT"
];
const embeddings = embeddingModel.embed(documents, 2);
for await (const batch of embeddings) {
console.log(batch);
}
Supports passage and query embeddings for more accurate results
const embeddings = embeddingModel.passageEmbed(listOfLongTexts, 10);
for await (const batch of embeddings) {
console.log(batch);
}
const queryEmbeddings: number[] = await embeddingModel.queryEmbed(userQuery);
console.log(queryEmbeddings)
🚒 Under the hood
Why fast?
It's important we justify the "fast" in FastEmbed. FastEmbed is fast because:
- Quantized model weights
- ONNX Runtime which allows for inference on CPU, GPU, and other dedicated runtimes
Why light?
- No hidden dependencies via Huggingface Transformers
Why accurate?
- Better than OpenAI Ada-002
- Top of the Embedding leaderboards e.g. MTEB
© LICENSE
MIT © 2023