Model reference · open weights
Dmeta-embedding-zh is an open-weight embedding model from DMetaSoul. Dmeta-embedding-zh (BF16) weighs 411 MB; 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 DMetaSoul/Dmeta-embedding-zh model card, 2026-10-01
What it is
| Released by | DMetaSoul |
|---|---|
| Released | 2024-01-25 |
| VRAM | 411 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
Update News
2024.04.01, The Dmeta-embedding small version is released. Just with 8 layers, inference is more efficient, about 30% improved.
2024.02.07, The Embedding API service based on the Dmeta-embedding model now open for internal beta testing. Click the link to apply, and you will receive 400M tokens for free, which can encode approximately GB-level Chinese text.
Dmeta-embedding is a cross-domain, cross-task, out-of-the-box Chinese embedding model. It is suitable for various scenarios such as search engine, Q&A, intelligent customer service, LLM+RAG, etc. It supports inference using tools like Transformers/Sentence-Transformers/Langchain.
Features:
The model supports inference through frameworks such as Sentence-Transformers, Langchain, Huggingface Transformers, etc. For specific usage, please refer to the following examples.
Load and inference Dmeta-embedding via sentence-transformers as following:
pip install -U sentence-transformers
from sentence_transformers import SentenceTransformer
texts1 = ["胡子长得太快怎么办?", "在香港哪里买手表好"]
texts2 = ["胡子长得快怎么办?", "怎样使胡子不浓密!", "香港买手表哪里好", "在杭州手机到哪里买"]
model = SentenceTransformer('DMetaSoul/Dmeta-embedding')
embs1 = model.encode(texts1, normalize_embeddings=True)
embs2 = model.encode(texts2, normalize_embeddings=True)
similarity = embs1 @ embs2.T
print(similarity)
for i in range(len(texts1)):
scores = []
for j in range(len(texts2)):
scores.append([texts2[j], similarity[i][j]])
scores = sorted(scores, key=lambda x:x[1], reverse=True)
print(f"查询文本:{texts1[i]}")
for text2, score in scores:
print(f"相似文本:{text2},打分:{score}")
print()
Output:
查询文本:胡子长得太快怎么办?
相似文本:胡子长得快怎么办?,打分:0.9535336494445801
相似文本:怎样使胡子不浓密!,打分:0.6776421070098877
相似文本:香港买手表哪里好,打分:0.2297907918691635
相似文本:在杭州手机到哪里买,打分:0.11386542022228241
查询文本:在香港哪里买手表好
相似文本:香港买手表哪里好,打分:0.9843372106552124
相似文本:在杭州手机到哪里买,打分:0.45211508870124817
相似文本:胡子长得快怎么办?,打分:0.19985519349575043
相似文本:怎样使胡子不浓密!,打分:0.18558596074581146
Load and inference Dmeta-embedding via langchain as following:
pip install -U langchain
import torch
import numpy as np
from langchain.embeddings import HuggingFaceEmbeddings
model_name = "DMetaSoul/Dmeta-embedding"
model_kwargs = {'device': 'cuda' if torch.cuda.is_available() else 'cpu'}
encode_kwargs = {'normalize_embeddings': True} # set True to compute cosine similarity
model = HuggingFaceEmbeddings(
model_name=model_name,
model_kwargs=model_kwargs,
encode_kwargs=encode_kwargs,
)
texts1 = ["胡子长得太快怎么办?", "在香港哪里买手表好"]
texts2 = ["胡子长得快怎么办?", "怎样使胡子不浓密!", "香港买手表哪里好", "在杭州手机到哪里买"]
embs1 = model.embed_documents(texts1)
embs2 = model.embed_documents(texts2)
embs1, embs2 = np.array(embs1), np.array(embs2)
similarity = embs1 @ embs2.T
print(similarity)
for i in range(len(texts1)):
scores = []
for j in range(len(texts2)):
scores.append([texts2[j], similarity[i][j]])
scores = sorted(scores, key=lambda x:x[1], reverse=True)
print(f"查询文本:{texts1[i]}")
for text2, score in scores:
print(f"相似文本:{text2},打分:{score}")
print()
Load and inference Dmeta-embedding via HuggingFace Transformers as following:
pip install -U transformers
import torch
from transformers import AutoTokenizer, AutoModel
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
def cls_pooling(model_output):
return model_output[0][:, 0]
texts1 = ["胡子长得太快怎么办?", "在香港哪里买手表好"]
texts2 = ["胡子长得快怎么办?", "怎样使胡子不浓密!", "香港买手表哪里好", "在杭州手机到哪里买"]
tokenizer = AutoTokenizer.from_pretrained('DMetaSoul/Dmeta-embedding')
model = AutoModel.from_pretrained('DMetaSoul/Dmeta-embedding')
model.eval()
with torch.no_grad():
inputs1 = tokenizer(texts1, padding=True, truncation=True, return_tensors='pt')
inputs2 = tokenizer(texts2, padding=True, truncation=True, return_tensors='pt')
model_output1 = model(**inputs1)
model_output2 = model(**inputs2)
embs1Quoted 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 |
|---|---|---|---|
| STS | MTEB AFQMC | cos_sim_pearson | 65.608 |
| STS | MTEB AFQMC | cos_sim_spearman | 71.129 |
| STS | MTEB AFQMC | euclidean_pearson | 70.181 |
| STS | MTEB AFQMC | euclidean_spearman | 71.129 |
| STS | MTEB AFQMC | manhattan_pearson | 70.145 |
| STS | MTEB AFQMC | manhattan_spearman | 71.052 |
| STS | MTEB ATEC | cos_sim_pearson | 65.524 |
| STS | MTEB ATEC | cos_sim_spearman | 64.642 |
| STS | MTEB ATEC | euclidean_pearson | 73.202 |
| STS | MTEB ATEC | euclidean_spearman | 64.642 |
| STS | MTEB ATEC | manhattan_pearson | 73.228 |
| STS | MTEB ATEC | manhattan_spearman | 64.626 |
| Classification | MTEB AmazonReviewsClassification (zh) | accuracy | 44.926 |
| Classification | MTEB AmazonReviewsClassification (zh) | f1 | 42.826 |
| STS | MTEB BQ | cos_sim_pearson | 71.352 |
| STS | MTEB BQ | cos_sim_spearman | 72.296 |
| STS | MTEB BQ | euclidean_pearson | 70.946 |
| STS | MTEB BQ | euclidean_spearman | 72.296 |
| STS | MTEB BQ | manhattan_pearson | 70.845 |
| STS | MTEB BQ | manhattan_spearman | 72.245 |
| Clustering | MTEB CLSClusteringP2P | v_measure | 40.242 |
| Clustering | MTEB CLSClusteringS2S | v_measure | 39.168 |
| Reranking | MTEB CMedQAv1 | map | 88.488 |
| Reranking | MTEB CMedQAv1 | mrr | 90.369 |