Model reference · open weights
ML-Embed is an open-weight embedding model from codefuse-ai. ML-Embed-0.6B (BF16) weighs 1.3 GB; the smallest configuration that runs it is RTX 3060 12 GB.
For self-hosting, compare this build's requirements below with the GPU you plan to rent.
Summary of the codefuse-ai/ML-Embed-0.6B model card, 2026-10-01
What it is
| Released by | codefuse-ai |
|---|---|
| Released | 2026-05-15 |
| Parameters | 596M |
| VRAM | 1.3 GB 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
ML-Embed-0.6B is a multilingual text embedding model developed by CodeFuse AI and trained from Qwen3-0.6B. It is part of the ML-Embed family introduced in the ICML 2026 paper ML-Embed: Inclusive and Efficient Embeddings for a Multilingual World.
This model is designed to be:
The default released checkpoint is in compatibility mode, meaning it behaves like a standard Transformer embedding model and can be used directly with sentence-transformers or transformers.
U.pth, V.pth)To encode text with the Sentence Transformers library:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer(
"codefuse-ai/ML-Embed-0.6B",
device="cuda:0",
model_kwargs={"torch_dtype": "bfloat16"}
)
# Some sample query and documents
query = "What is ML-Embed used for?"
documents = [
"ML-Embed is a family of multilingual embedding models for retrieval, semantic search, and other NLP tasks.",
"ML-Embed is trained to produce text embeddings that work well across many languages.",
"ML-Embed 是 CodeFuse AI 开源的多语言嵌入模型。",
"ML-Embed — это многоязычная модель эмбеддингов для поиска и семантического сопоставления."
]
# Encode the query and documents separately. The encode_query method uses the query prompt
query_embedding = model.encode_query(query)
document_embeddings = model.encode_document(documents)
print(query_embedding.shape, document_embeddings.shape)
# (1024,) (4, 1024)
# Compute cosine similarity between the query and documents
similarity = model.similarity(query_embedding, document_embeddings)
print(similarity)
Or directly with the Transformers library:
from transformers import AutoModel, AutoTokenizer
import torch
import torch.nn.functional as F
model_path = "codefuse-ai/ML-Embed-0.6B"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModel.from_pretrained(
model_path,
torch_dtype=torch.bfloat16,
device_map={"": 0}
)
query = "What is ML-Embed used for?"
query_prompt = "Instruct: Given a question, retrieve passages that can help answer the question.\nQuery: "
documents = [
"ML-Embed is a family of multilingual embedding models for retrieval, semantic search, and other NLP tasks.",
"ML-Embed is trained to produce text embeddings that work well across many languages.",
"ML-Embed 是 CodeFuse AI 开源的多语言嵌入模型。",
"ML-Embed — это многоязычная модель эмбеддингов для поиска и семантического сопоставления."
]
def encode(sentences):
batch_size = len(sentences)
tokenized_inputs = tokenizer(sentences, padding=True, return_tensors="pt").to(model.device)
last_hidden_state = model(**tokenized_inputs).last_hidden_state
eos_positions = tokenized_inputs.attention_mask.sum(dim=1) - 1
embeddings = last_hidden_state[torch.arange(batch_size, device=model.device), eos_positions]
embeddings = F.normalize(embeddings, p=2, dim=1)
return embeddings
# Encode the query and documents
query_embedding = encode([query_prompt + query])
document_embeddings = encode(documents)
print(query_embedding.shape, document_embeddings.shape)
# torch.Size([1, 1024]) torch.Size([4, 1024])
# Compute cosine similarity between the query and documents
similarity = query_embedding @ document_embeddings.T
print(similarity)
The model supports custom instructions in the following format:
Instruct: your_instruction
Query:
In general, for retrieval and reranking tasks:
For symmetric tasks such as STS, clustering, and bitext mining, you can encode the documents either with or without prompts. The model is trained to support both scenarios.
ML-Embed-0.6B was trained with 3D Matryoshka Learning, including:
This enables multiple deployment modes.
The default released checkpoint is a standard Qwen3-compatible model. You can load it normally with AutoModel or SentenceTransformer without any code changes (refer to the examples above).
This is the recommended option if you want the simplest integration.
This model was trained so that shallower versions remain useful. If you want to save memory or compute, you can deploy a smaller model by editing:
num_hidden_layersmax_window_layersin config.json to a value smaller than the current one.
For example, changing both values from 28 to 16 will make transformers load only the first 16 layers and ignore the remaining weights.
This works automatically with the Hugging Face transformers library.
Note: make sure
num_hidden_layersandmax_window_layersstay consistent. If you are using transformers v5, you will also need to trucatelayer_typesin the config file according to the new
Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.