• Stars
    star
    738
  • Rank 59,146 (Top 2 %)
  • Language
    Jupyter Notebook
  • License
    Apache License 2.0
  • Created 10 months ago
  • Updated 29 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fast, Accurate, Lightweight Python library to make State of the Art Embedding

⚡️ What is FastEmbed?

FastEmbed is a lightweight, fast, Python library built for embedding generation. We support popular text models. Please open a Github issue if you want us to add a new model.

The default embedding supports "query" and "passage" prefixes for the input text. The default model is Flag Embedding, which is top of the MTEB leaderboard. Here is an example for Retrieval Embedding Generation and how to use FastEmbed with Qdrant.

  1. Light & Fast

    • Quantized model weights
    • ONNX Runtime, no PyTorch dependency
    • CPU-first design
    • Data-parallelism for encoding of large datasets
  2. Accuracy/Recall

    • Better than OpenAI Ada-002
    • Default is Flag Embedding, which is top of the MTEB leaderboard
    • List of supported models - including multilingual models

🚀 Installation

To install the FastEmbed library, pip works:

pip install fastembed

📖 Usage

from fastembed import TextEmbedding
from typing import List
import numpy as np

documents: List[str] = [
    "passage: Hello, World!",
    "query: Hello, World!", # these are two different embedding
    "passage: This is an example passage.",
    "fastembed is supported by and maintained by Qdrant." # You can leave out the prefix but it's recommended
]
embedding_model = TextEmbedding(model_name="BAAI/bge-base-en")
embeddings: List[np.ndarray] = list(embedding_model.embed(documents)) # Note the list() call - this is a generator

Usage with Qdrant

Installation with Qdrant Client in Python:

pip install qdrant-client[fastembed]

Might have to use pip install 'qdrant-client[fastembed]' on zsh.

from qdrant_client import QdrantClient

# Initialize the client
client = QdrantClient(":memory:")  # or QdrantClient(path="path/to/db")

# Prepare your documents, metadata, and IDs
docs = ["Qdrant has Langchain integrations", "Qdrant also has Llama Index integrations"]
metadata = [
    {"source": "Langchain-docs"},
    {"source": "Linkedin-docs"},
]
ids = [42, 2]

# Use the new add method
client.add(
    collection_name="demo_collection",
    documents=docs,
    metadata=metadata,
    ids=ids
)

search_result = client.query(
    collection_name="demo_collection",
    query_text="This is a query document"
)
print(search_result)

Similar Work

Ilyas M. wrote about using FlagEmbeddings with Optimum over CUDA.

More Repositories

1

qdrant

Qdrant - High-performance, massive-scale Vector Database for the next generation of AI. Also available in the cloud https://cloud.qdrant.io/
Rust
16,757
star
2

quaterion

Blazing fast framework for fine-tuning similarity learning models
Python
604
star
3

qdrant-client

Python client for Qdrant vector search engine
Python
537
star
4

awesome-metric-learning

😎 A curated list of awesome practical Metric Learning and its applications
426
star
5

vector-db-benchmark

Framework for benchmarking vector search engines
Python
218
star
6

qdrant-js

JavaScript/Typescript SDK for Qdrant Vector Database
TypeScript
192
star
7

rust-client

Rust client for Qdrant vector search engine
Rust
167
star
8

qdrant-web-ui

Self-hosted web UI for Qdrant
JavaScript
164
star
9

page-search

Neural search for web-sites, docs, articles - online!
Rust
117
star
10

qdrant_demo

Demo of the neural semantic search built with Qdrant
TypeScript
104
star
11

go-client

Go client for Qdrant vector search engine
Shell
99
star
12

qdrant-helm

Go
75
star
13

qdrant-dotnet

Qdrant .Net SDK
C#
67
star
14

examples

A collection of examples and tutorials for Qdrant vector search engine
Jupyter Notebook
61
star
15

qdrant-haystack

An integration of Qdrant ANN vector database backend with Haystack
Python
39
star
16

qdrant-spark

Qdrant Apache Spark connector
Java
38
star
17

quaterion-models

The collection of bulding blocks building fine-tunable metric learning models
Python
30
star
18

ann-filtering-benchmark-datasets

Collection of datasets for benchmarking filtered vector similarity retrieval
Python
24
star
19

demo-food-discovery

Source code of the food discovery demo built on top of Qdrant
TypeScript
23
star
20

qdrant-txtai

An integration of Qdrant ANN vector database backend with txtai
Python
22
star
21

workshop-rag-optimization

Notebooks for RAG optimization workshop, using HackerNews data
Jupyter Notebook
19
star
22

goods_categorization_demo

Demo example of consumer goods categorization
Jupyter Notebook
18
star
23

wal

Write Ahead Logging for Rust
Rust
16
star
24

java-client

Official Java client for Qdrant
Java
13
star
25

landing_page

Landing page for qdrant.tech
CSS
12
star
26

bfb

*high-load* benchmarking tool
Rust
11
star
27

demo-cloud-faq

Demo of fine-tuning QA models for answering FAQ of cloud providers documentation
Python
9
star
28

benchmark

Collection of Qdrant benchmarks
Python
7
star
29

demo-hnm

Jupyter Notebook
5
star
30

qdrant-markdown-indexer

Simple pipeline to index markdown files into Qdrant using OpenAI embeddings
Python
5
star
31

quantization

Rust
5
star
32

autocomplete-openapi

Autocomplete queries using OpenAPI spec
JavaScript
4
star
33

demo-distributed-deployment-docker

An example of setting up the distributed deployment of Qdrant with docker-compose
Shell
4
star
34

contexto

A simple script to solve contexto.me using word embeddings
JavaScript
4
star
35

page-search-js

Web interface for integrated web-site search powered by Qdrant
JavaScript
4
star
36

demo-code-search

Python
3
star
37

haloperidol

Antipsychotic therapy for qdrant cluster
Shell
3
star
38

qdrant_python_client

Qdrant Python client, generated from OpenAPI specification (with minor fixes)
Python
3
star
39

dataset-cloud-platform-faq

HTML
3
star
40

qdrant-qa-workshop

Jupyter Notebook
3
star
41

sparse-vectors-experiments

Rust
3
star
42

qdrant-langchain-qa

HTML
2
star
43

coach

Coach running drills to train qdrant deployments
Rust
2
star
44

rust-parser

Extracts semantics from rust code
Rust
2
star
45

tutorials

This repo contains tutorials, demos, and how-to guides on how to use Qdrant and adjacent technologies.
Jupyter Notebook
1
star
46

demo-qdrant-fiftyone

An example of integrating Qdrant with FiftyOne
Python
1
star
47

sparse-vectors-benchmark

This is a benchmarking tool for Qdrant's sparse vector implementation
Python
1
star
48

crasher

Crashing the party
Rust
1
star