Model reference · open weights
MiniCPM-Embedding-Light is an open-weight embedding model from openbmb. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Maker | openbmb |
|---|---|
| Type | Embedding models |
| Task | Embeddings |
| Parameters (lead) | 434M |
| Context | 4k tokens |
| Runs with | transformers |
| Released | 2025-01-17 |
| Popularity | 12k downloads / month |
| Licence | Unknown |
About
MiniCPM-Embedding-Light 是面壁智能与清华大学自然语言处理实验室(THUNLP)、东北大学信息检索小组(NEUIR)共同开发的中英双语言文本嵌入模型,有如下特点:
MiniCPM-Embedding-Light结构上采取双向注意力和 Weighted Mean Pooling [1]。采取多阶段训练方式,共使用包括开源数据、机造数据、闭源数据在内的约 260M 条训练数据。
欢迎关注 UltraRAG 系列:
MiniCPM-Embedding-Light is a bilingual & cross-lingual text embedding model developed by ModelBest Inc. , THUNLP and NEUIR , featuring:
MiniCPM-Embedding-Light incorporates bidirectional attention and Weighted Mean Pooling [1] in its architecture. The model underwent multi-stage training using approximately 260 million training examples, including open-source, synthetic, and proprietary data.
We also invite you to explore the UltraRAG series:
[1] Muennighoff, N. (2022). Sgpt: Gpt sentence embeddings for semantic search. arXiv preprint arXiv:2202.08904. [2] Kusupati, Aditya, et al. "Matryoshka representation learning." Advances in Neural Information Processing Systems 35 (2022): 30233-30249.
模型大小:440M
嵌入维度:1024
最大输入token数:8192
Model Size: 440M
Embedding Dimension: 1024
Max Input Tokens: 8192
本模型支持 query 侧指令,格式如下:
MiniCPM-Embedding-Light 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-Light also works in instruction-free mode in the following format:
Query: {{ query }}
transformers==4.37.2
from transformers import AutoModel
import torch
model_name = "openbmb/MiniCPM-Embedding-Light"
model = AutoModel.from_pretrained(model_name, trust_remote_code=True, torch_dtype=torch.float16).to("cuda")
# you can use flash_attention_2 for faster inference
# model = AutoModel.from_pretrained(model_name, trust_remote_code=True, attn_implementation="flash_attention_2", torch_dtype=torch.float16).to("cuda")
model.eval()
queries = ["MiniCPM-o 2.6 A GPT-4o Level MLLM for Vision, Speech and Multimodal Live Streaming on Your Phone"]
passages = ["MiniCPM-o 2.6 is the latest and most capable model in the MiniCPM-o series. The model is built in an end-to-end fashion based on SigLip-400M, Whisper-medium-300M, ChatTTS-200M, and Qwen2.5-7B with a total of 8B parameters. It exhibits a significant performance improvement over MiniCPM-V 2.6, and introduces new features for real-time speech conversation and multimodal live streaming."]
embeddings_query_dense, embeddings_query_sparse = model.encode_query(queries, return_sparse_vectors=True)
embeddings_doc_dense, embeddings_doc_sparse = model.encode_corpus(passages, return_sparse_vectors=True)
dense_scores = (embeddings_query_dense @ embeddings_doc_dense.T)
print(dense_scores.tolist()) # [[0.6512398719787598]]
print(model.compute_sparse_score_dicts(embeddings_query_sparse, embeddings_doc_sparse)) # [[0.27202296]]
dense_scores, sparse_scores, mixed_scores = model.compute_score(queries, passages)
print(dense_scores) # [[0.65123993]]
print(sparse_scores) # [[0.27202296]]
print(mixed_scores) # [[0.73284686]]
import torch
from sentence_transformers import SentenceTransformer
model_name = "openbmb/MiniCPM-Embedding-Light"
model = SentenceTransformer(model_name, trust_remote_code=True, model_kwargs={"torch_dtype": torch.float16})
# you can use flash_attention_2 for faster inference
# model = SentenceTransformer(model_name, trust_remote_code=True, model_kwargs={"attn_implementation": "flash_attention_2", "torch_dtype": torch.float16})
queries = ["中国的首都是哪里?"] # "What is the capital of China?"
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.40356746315956116, 0.36183440685272217]]
import asyncio
from infinity_emb import AsyncEngineArray, EngineArgs, AsyncEmbeddingEngine
import numpy as np
array = AsyncEngineArray.from_args([
EngineArgs(model_name_or_path = "openbmb/MiniCPM-Embedding-Light", engine="torch", dtype="float16", bettertransformer=False, pooling_method="mean", trust_remote_code=True),
])
queries = ["中国的首都是哪里?"] # "What is the capital of China?"
passages = ["beijing", "shanghai"] # "北京", "上海"
INSTRUCTION = "Query:"
queries = [f"{INSTRUCTION} {query}" for query in queries]
async def embed_text(engine: AsyncEmbeddingEngine,sentences):
async with engine:
embeddings, usage = await engine.embed(sentences=sentences)
return embeddings
queries_embedding = asyncio.run(embed_text(array[0],queries))
passages_embedding = asyncio.run(embed_text(array[0],passages))
scores = (np.array(querie
From the published model card. Full card on the HuggingFace links in the sidebar.
Benchmarks
As published on the model card — the maker's own numbers, not measured by AxForge.
| Task | Dataset | Metric | Score |
|---|---|---|---|
| STS | MTEB AFQMC (default) | cosine_pearson | 31.602 |
| STS | MTEB AFQMC (default) | cosine_spearman | 32.266 |
| STS | MTEB AFQMC (default) | euclidean_pearson | 31.387 |
| STS | MTEB AFQMC (default) | euclidean_spearman | 32.266 |
| STS | MTEB AFQMC (default) | main_score | 32.266 |
| STS | MTEB AFQMC (default) | manhattan_pearson | 31.012 |
| STS | MTEB AFQMC (default) | manhattan_spearman | 31.881 |
| STS | MTEB AFQMC (default) | pearson | 31.602 |
| STS | MTEB AFQMC (default) | spearman | 32.266 |
| STS | MTEB ATEC (default) | cosine_pearson | 40.900 |
| STS | MTEB ATEC (default) | cosine_spearman | 40.342 |
| STS | MTEB ATEC (default) | euclidean_pearson | 43.266 |
| STS | MTEB ATEC (default) | euclidean_spearman | 40.342 |
| STS | MTEB ATEC (default) | main_score | 40.342 |
| STS | MTEB ATEC (default) | manhattan_pearson | 43.094 |
| STS | MTEB ATEC (default) | manhattan_spearman | 40.133 |
| STS | MTEB ATEC (default) | pearson | 40.900 |
| STS | MTEB ATEC (default) | spearman | 40.342 |
| STS | MTEB ATEC (default) | cosine_pearson | 40.977 |
| STS | MTEB ATEC (default) | cosine_spearman | 41.151 |
| STS | MTEB ATEC (default) | euclidean_pearson | 43.127 |
| STS | MTEB ATEC (default) | euclidean_spearman | 41.151 |
| STS | MTEB ATEC (default) | main_score | 41.151 |
| STS | MTEB ATEC (default) | manhattan_pearson | 43.016 |
Using it via the API
Once AxForge deploys minicpm-embedding-light for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (minicpm-embedding-light below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/embeddings \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"minicpm-embedding-light","input":"text to embed"}'
Create an account — your API key is available in the console. 5M tokens/month currently included with every new account at launch.