Model reference · open weights
mxbai-embed-large is an open-weight embedding model from mixedbread-ai. mxbai-embed-large-v1 (FP16) weighs 670 MB; the smallest configuration that runs it is RTX 3060 12 GB.
Summary of the mixedbread-ai/mxbai-embed-large-v1 model card, 2026-10-01
What it is
| Released by | mixedbread-ai |
|---|---|
| Released | 2024-03-07 |
| Parameters | 335M |
| VRAM | 670 MB for the weights |
What it runs on
| Card | Runs | Memory |
|---|---|---|
| RTX 3060 12 GB | fits | 11.6 GB |
| RTX 4060 Ti 16 GB | fits | 15.4 GB |
| RTX 3090 24 GB | fits | 23.4 GB |
| RTX 4090 24 GB | fits | 23.4 GB |
| RTX 5090 32 GB | fits | 31.0 GB |
| L40S 48 GB | fits | 44.0 GB |
| A100 80 GB | fits | 78.2 GB |
| H100 80 GB | fits | 78.1 GB |
| RTX PRO 6000 Blackwell 96 GB | fits | 93.8 GB |
| DGX Spark (GB10) 128 GB unified | fits | 107 GB |
| H200 141 GB | fits | 138 GB |
| B200 180 GB | fits | 176 GB |
From the model card
Here, we provide several ways to produce sentence embeddings. Please note that you have to provide the prompt Represent this sentence for searching relevant passages: for query if you want to use it for retrieval. Besides that you don't need any prompt. Our model also supports Matryoshka Representation Learning and binary quantization.
Here, we provide several ways to produce sentence embeddings. Please note that you have to provide the prompt Represent this sentence for searching relevant passages: for query if you want to use it for retrieval. Besides that you don't need any prompt.
python -m pip install -U sentence-transformers
from sentence_transformers import SentenceTransformer
from sentence_transformers.util import cos_sim
from sentence_transformers.quantization import quantize_embeddings
# 1. Specify preffered dimensions
dimensions = 512
# 2. load model
model = SentenceTransformer("mixedbread-ai/mxbai-embed-large-v1", truncate_dim=dimensions)
# The prompt used for query retrieval tasks:
# query_prompt = 'Represent this sentence for searching relevant passages: '
query = "A man is eating a piece of bread"
docs = [
"A man is eating food.",
"A man is eating pasta.",
"The girl is carrying a baby.",
"A man is riding a horse.",
]
# 2. Encode
query_embedding = model.encode(query, prompt_name="query")
# Equivalent Alternatives:
# query_embedding = model.encode(query_prompt + query)
# query_embedding = model.encode(query, prompt=query_prompt)
docs_embeddings = model.encode(docs)
# Optional: Quantize the embeddings
binary_query_embedding = quantize_embeddings(query_embedding, precision="ubinary")
binary_docs_embeddings = quantize_embeddings(docs_embeddings, precision="ubinary")
similarities = cos_sim(query_embedding, docs_embeddings)
print('similarities:', similarities)
from typing import Dict
import torch
import numpy as np
from transformers import AutoModel, AutoTokenizer
from sentence_transformers.util import cos_sim
# For retrieval you need to pass this prompt. Please find our more in our blog post.
def transform_query(query: str) -> str:
""" For retrieval, add the prompt for query (not for documents).
"""
return f'Represent this sentence for searching relevant passages: {query}'
# The model works really well with cls pooling (default) but also with mean pooling.
def pooling(outputs: torch.Tensor, inputs: Dict, strategy: str = 'cls') -> np.ndarray:
if strategy == 'cls':
outputs = outputs[:, 0]
elif strategy == 'mean':
outputs = torch.sum(
outputs * inputs["attention_mask"][:, :, None], dim=1) / torch.sum(inputs["attention_mask"], dim=1, keepdim=True)
else:
raise NotImplementedError
return outputs.detach().cpu().numpy()
# 1. load model
model_id = 'mixedbread-ai/mxbai-embed-large-v1'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModel.from_pretrained(model_id).cuda()
docs = [
transform_query('A man is eating a piece of bread'),
"A man is eating food.",
"A man is eating pasta.",
"The girl is carrying a baby.",
"A man is riding a horse.",
]
# 2. encode
inputs = tokenizer(docs, padding=True, return_tensors='pt')
for k, v in inputs.items():
inputs[k] = v.cuda()
outputs = model(**inputs).last_hidden_state
embeddings = pooling(outputs, inputs, 'cls')
similarities = cos_sim(embeddings[0], embeddings[1:])
print('similarities:', similarities)
If you haven't already, you can install the Transformers.js JavaScript library from NPM using:
npm i @huggingface/transformers
You can then use the model to compute embeddings like this:
import { pipeline, cos_sim } from "@huggingface/transformers";
// Create a feature extraction pipeline
const extractor = await pipeline("feature-extraction", "mixedbread-ai/mxbai-embed-large-v1", {
dtype: "fp32", // Options: "fp32", "fp16", "q8"
});
// Generate sentence embeddings
const docs = [
"Represent this sentence for searching relevant passages: A man is eating a piece of bread",
"A man is eating food.",
"A man is eating pasta.",
"The girl is carrying a baby.",
"A man is riding a horse.",
]
const output = await extractor(docs, { pooling: "cls" });
// Compute similarity scores
const [source_embeddings, ...document_embeddings ] = output.tolist();
const similarities = document_embeddings.map(x => cos_sim(source_embeddings, x));
console.log(similarities); // [0.7919578577247139, 0.6369278664248345, 0.16512018371357193, 0.3620778366720027]
You can use the model via our API as follows:
from mixedbread_ai.client import MixedbreadAI, EncodingFormat
from sklearn.metrics.pairwise import cosine_similarity
import os
mxbai = MixedbreadAI(api_key="{MIXEDBREAD_API_KEY}")
english_sentences = [
'What is the capital of Australia?',
'Canberra is the capital of Australia.'
]
res = mxbai.embeddings(
input=english_sentences,
model="mixedbread-ai/mxbai-embed-large-v1",
normalized=True,
encoding_format=[EncodingFormat.FLOAT, EncodingFormat.UBINARY, EncodingFormat.INT_8],
dimensions=512
)
encoded_embeddings = res.data[0].embedding
print(res.dimensions, encoded_embeddings.ubinary, encoded_embeddings.float_, encoded_embeddings.int_8)
The API comes with native int8 and binary quantization support! Check out the docs for more information.
docker run --gpus all -v $PWD/data:/app/.cache -p "7997":"7997" \
michaelf34/infinity:0.0.68 \
v2 --model-id mixedbread-ai/mxbai-embed-large-v1 --revision "main" --dtype float16 --engine torch --port 7997
As of March 2024, our model archives SOTA performance f
Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.
Benchmarks
As published on the model card: the maker's own numbers, not measured by AxForge.
| Task | Dataset | Metric | Score |
|---|---|---|---|
| Classification | MTEB AmazonCounterfactualClassification (en) | accuracy | 75.045 |
| Classification | MTEB AmazonCounterfactualClassification (en) | ap | 37.736 |
| Classification | MTEB AmazonCounterfactualClassification (en) | f1 | 68.927 |
| Classification | MTEB AmazonPolarityClassification | accuracy | 93.840 |
| Classification | MTEB AmazonPolarityClassification | ap | 90.932 |
| Classification | MTEB AmazonPolarityClassification | f1 | 93.830 |
| Classification | MTEB AmazonReviewsClassification (en) | accuracy | 49.184 |
| Classification | MTEB AmazonReviewsClassification (en) | f1 | 48.742 |
| Retrieval | MTEB ArguAna | map_at_1 | 41.252 |
| Retrieval | MTEB ArguAna | map_at_10 | 57.778 |
| Retrieval | MTEB ArguAna | map_at_100 | 58.233 |
| Retrieval | MTEB ArguAna | map_at_1000 | 58.237 |
| Retrieval | MTEB ArguAna | map_at_3 | 53.450 |
| Retrieval | MTEB ArguAna | map_at_5 | 56.376 |
| Retrieval | MTEB ArguAna | mrr_at_1 | 41.679 |
| Retrieval | MTEB ArguAna | mrr_at_10 | 57.927 |
| Retrieval | MTEB ArguAna | mrr_at_100 | 58.389 |
| Retrieval | MTEB ArguAna | mrr_at_1000 | 58.392 |
| Retrieval | MTEB ArguAna | mrr_at_3 | 53.651 |
| Retrieval | MTEB ArguAna | mrr_at_5 | 56.521 |
| Retrieval | MTEB ArguAna | ndcg_at_1 | 41.252 |
| Retrieval | MTEB ArguAna | ndcg_at_10 | 66.018 |
| Retrieval | MTEB ArguAna | ndcg_at_100 | 67.774 |
| Retrieval | MTEB ArguAna | ndcg_at_1000 | 67.844 |