Model reference · open weights

MiniCPM-Embedding

Embeddings openbmb Embeddings 1 build Licence not stated 12k dl/mo

MiniCPM-Embedding is an open-weight embedding model from openbmb. MiniCPM-Embedding (BF16) weighs 5.4 GB; the smallest configuration that runs it is RTX 3060 12 GB.

  • MiniCPM-Embedding is a 2.7B parameter bilingual text embedding model developed by openbmb for feature extraction and retrieval tasks.
  • It supports Chinese and English with a maximum context length of 512 tokens and utilizes bidirectional attention with weighted mean pooling.
  • The model code is released under the Apache-2.0 license, while the weights are free for academic research and available for commercial use after registration.

Summary of the openbmb/MiniCPM-Embedding model card, 2026-10-01

What it is

Released byopenbmb
Released2024-09-04
Parameters2.7B
VRAM5.4 GB for the weights

What it runs on

Memory and cards for MiniCPM-Embedding (BF16)

5.4 GBweights, file size
1.1 GBruntime overhead
CardRunsMemory
RTX 3060 12 GBfits11.6 GB
RTX 4060 Ti 16 GBfits15.4 GB
RTX 3090 24 GBfits23.4 GB
RTX 4090 24 GBfits23.4 GB
RTX 5090 32 GBfits31.0 GB
L40S 48 GBfits44.0 GB
A100 80 GBfits78.2 GB
H100 80 GBfits78.1 GB
RTX PRO 6000 Blackwell 96 GBfits93.8 GB
DGX Spark (GB10) 128 GB unifiedfits107 GB
H200 141 GBfits138 GB
B200 180 GBfits176 GB

From the model card

What openbmb says about MiniCPM-Embedding

Read the model card

MiniCPM-Embedding

MiniCPM-Embedding 是面壁智能与清华大学自然语言处理实验室(THUNLP)、东北大学信息检索小组(NEUIR)共同开发的中英双语言文本嵌入模型,有如下特点:

  • 出色的中文、英文检索能力。
  • 出色的中英跨语言检索能力。

MiniCPM-Embedding 基于 MiniCPM-2B-sft-bf16 训练,结构上采取双向注意力和 Weighted Mean Pooling [1]。采取多阶段训练方式,共使用包括开源数据、机造数据、闭源数据在内的约 600 万条训练数据。

欢迎关注 RAG 套件系列:

MiniCPM-Embedding is a bilingual & cross-lingual text embedding model developed by ModelBest Inc. , THUNLP and NEUIR , featuring:

  • Exceptional Chinese and English retrieval capabilities.
  • Outstanding cross-lingual retrieval capabilities between Chinese and English.

MiniCPM-Embedding is trained based on MiniCPM-2B-sft-bf16 and incorporates bidirectional attention and Weighted Mean Pooling [1] in its architecture. The model underwent multi-stage training using approximately 6 million training examples, including open-source, synthetic, and proprietary data.

We also invite you to explore the RAG toolkit series:

[1] Muennighoff, N. (2022). Sgpt: Gpt sentence embeddings for semantic search. arXiv preprint arXiv:2202.08904.

模型信息 Model Information

  • 模型大小:2.4B

  • 嵌入维度:2304

  • 最大输入token数:512

  • Model Size: 2.4B

  • Embedding Dimension: 2304

  • Max Input Tokens: 512

使用方法 Usage

输入格式 Input Format

本模型支持 query 侧指令,格式如下:

MiniCPM-Embedding supports query-side instructions in the following format:

Instruction: {{ instruction }} Query: {{ query }}

例如:

For example:

Instruction: 为这个医学问题检索相关回答。Query: 咽喉癌的成因是什么?
Instruction: Given a claim about climate change, retrieve documents that support or refute the claim. Query: However the warming trend is slower than most climate models have forecast.

也可以不提供指令,即采取如下格式:

MiniCPM-Embedding also works in instruction-free mode in the following format:

Query: {{ query }}

我们在 BEIR 与 C-MTEB/Retrieval 上测试时使用的指令见 instructions.json,其他测试不使用指令。文档侧直接输入文档原文。

When running evaluation on BEIR and C-MTEB/Retrieval, we use instructions in instructions.json. For other evaluations, we do not use instructions. On the document side, we directly use the bare document as the input.

环境要求 Requirements

transformers==4.37.2

示例脚本 Demo

Huggingface Transformers

from transformers import AutoModel, AutoTokenizer
import torch
import torch.nn.functional as F

model_name = "openbmb/MiniCPM-Embedding"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name, trust_remote_code=True, torch_dtype=torch.float16).to("cuda")
# You can also use the following line to enable the Flash Attention 2 implementation
# model = AutoModel.from_pretrained(model_name, trust_remote_code=True, attn_implementation="flash_attention_2", torch_dtype=torch.float16).to("cuda")
model.eval()

# 由于在 `model.forward` 中缩放了最终隐层表示,此处的 mean pooling 实际上起到了 weighted mean pooling 的作用
# As we scale hidden states in `model.forward`, mean pooling here actually works as weighted mean pooling
def mean_pooling(hidden, attention_mask):
    s = torch.sum(hidden * attention_mask.unsqueeze(-1).float(), dim=1)
    d = attention_mask.sum(dim=1, keepdim=True).float()
    reps = s / d
    return reps

@torch.no_grad()
def encode(input_texts):
    batch_dict = tokenizer(input_texts, max_length=512, padding=True, truncation=True, return_tensors='pt', return_attention_mask=True).to("cuda")

    outputs = model(**batch_dict)
    attention_mask = batch_dict["attention_mask"]
    hidden = outputs.last_hidden_state

    reps = mean_pooling(hidden, attention_mask)
    embeddings = F.normalize(reps, p=2, dim=1).detach().cpu().numpy()
    return embeddings

queries = ["中国的首都是哪里?"]
passages = ["beijing", "shanghai"]

INSTRUCTION = "Query: "
queries = [INSTRUCTION + query for query in queries]

embeddings_query = encode(queries)
embeddings_doc = encode(passages)

scores = (embeddings_query @ embeddings_doc.T)
print(scores.tolist())  # [[0.3535913825035095, 0.18596848845481873]]
Sentence Transformers
import torch
from sentence_transformers import SentenceTransformer

model_name = "openbmb/MiniCPM-Embedding"
model = SentenceTransformer(model_name, trust_remote_code=True, model_kwargs={ "torch_dtype": torch.float16})
# You can also use the following line to enable the Flash Attention 2 implementation
# model = SentenceTransformer(model_name, trust_remote_code=True, attn_implementation="flash_attention_2", model_kwargs={ "torch_dtype": torch.float16})

queries = ["中国的首都是哪里?"]
passages = ["beijing", "shanghai"]

INSTRUCTION = "Query: "

embeddings_query = model.encode(queries, prompt=INSTRUCTION)
embeddings_doc = model.encode(passages)

scores = (embeddings_query @ embeddings_doc.T)
print(scores.tolist())  # [[0.35365450382232666, 0.18592746555805206]]

实验结果 Evaluation Results

中文与英文检索结果 CN/EN Retrieval Results

模型 ModelC-MTEB/Retrieval (NDCG@10)BEIR (NDCG@10)
bge-large-zh-v1.570.46-
gte-large-zh72.49-
Zhihui_LLM_Embedding76.74
bge-large-en-v1.5-54.29
gte-en-large-v1.5-57.91
NV-Retriever-v1-60.9
bge-en-icl

Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.

Benchmarks

Reported results

As published on the model card: the maker's own numbers, not measured by AxForge.

TaskDatasetMetricScore
RetrievalMTEB ArguAnandcg_at_1064.650
RetrievalMTEB CQADupstackRetrievalndcg_at_1046.530
RetrievalMTEB ClimateFEVERndcg_at_1035.550
RetrievalMTEB DBPediandcg_at_1047.820
RetrievalMTEB FEVERndcg_at_1090.760
RetrievalMTEB FiQA2018ndcg_at_1056.640
RetrievalMTEB HotpotQAndcg_at_1078.110
RetrievalMTEB MSMARCOndcg_at_1043.930
RetrievalMTEB NFCorpusndcg_at_1039.770
RetrievalMTEB NQndcg_at_1069.290
RetrievalMTEB QuoraRetrievalndcg_at_1089.970
RetrievalMTEB SCIDOCSndcg_at_1022.380
RetrievalMTEB SciFactndcg_at_1086.600
RetrievalMTEB TRECCOVIDndcg_at_1081.320
RetrievalMTEB Touche2020ndcg_at_1025.080
RetrievalMTEB CmedqaRetrievalndcg_at_1046.050
RetrievalMTEB CovidRetrievalndcg_at_1092.010
RetrievalMTEB DuRetrievalndcg_at_1090.980
RetrievalMTEB EcomRetrievalndcg_at_1070.210
RetrievalMTEB MMarcoRetrievalndcg_at_1085.550
RetrievalMTEB MedicalRetrievalndcg_at_1063.910
RetrievalMTEB T2Retrievalndcg_at_1087.330
RetrievalMTEB VideoRetrievalndcg_at_1078.050
© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms