1.14.1 • Published 3 months ago

fastembed v1.14.1

Weekly downloads
-
License
-
Repository
github
Last release
3 months ago

🍕 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";
// 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:

  1. Quantized model weights
  2. ONNX Runtime which allows for inference on CPU, GPU, and other dedicated runtimes

Why light?

  1. No hidden dependencies via Huggingface Transformers

Why accurate?

  1. Better than OpenAI Ada-002
  2. Top of the Embedding leaderboards e.g. MTEB

© LICENSE

MIT © 2023

1.14.1

3 months ago

1.14.0

7 months ago

1.13.0

7 months ago

1.12.2-beta.2

7 months ago

1.12.2-beta.1

7 months ago

1.12.1

7 months ago

1.12.0

7 months ago

1.11.0

7 months ago

1.10.0

7 months ago

1.9.0

7 months ago

1.7.0

7 months ago

1.6.1

8 months ago

1.6.0

8 months ago

1.5.1

8 months ago

1.5.0

8 months ago

1.4.3

8 months ago

1.4.2

8 months ago

1.4.1

8 months ago

1.4.0

8 months ago

1.3.0

8 months ago

1.2.0

8 months ago

1.1.0

8 months ago

1.0.0

8 months ago

0.0.0-rc.1

8 months ago