New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fastembed

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastembed

NodeJS implementation of @Qdrant/fastembed

latest
Source
npmnpm
Version
2.1.0
Version published
Weekly downloads
51K
1.27%
Maintainers
1
Weekly downloads
 
Created
Source

FastEmbed-js ⚡️

Typescript/NodeJS implementation of @Qdrant/fastembed

Crates.io MIT Licensed Semantic release

🍕 Features

  • Supports CommonJS and ESM.
  • Uses @anush008/tokenizers multi-arch native bindings for @huggingface/tokenizers.
  • Supports batch embedddings with generators.

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";
// For CommonJS
// const { EmbeddingModel, FlagEmbedding } = require("fastembed)

const embeddingModel = await FlagEmbedding.init({
    model: EmbeddingModel.BGEBaseEN
});

let documents = [
    "passage: Hello, World!",
    "query: Hello, World!",
    "passage: This is an example passage.",
    // You can leave out the prefix but it's recommended
    "fastembed-js is licensed under MIT" 
];

const embeddings = embeddingModel.embed(documents, 2); //Optional batch size. Defaults to 256

for await (const batch of embeddings) {
    // batch is list of Float32 embeddings(number[][]) with length 2
    console.log(batch);
}

Supports passage and query embeddings for more accurate results

const embeddings = embeddingModel.passageEmbed(listOfLongTexts, 10); //Optional batch size. Defaults to 256

for await (const batch of embeddings) {
    // batch is list of Float32 passage embeddings(number[][]) with length 10
    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

Keywords

embeddings

FAQs

Package last updated on 15 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts