nvidia/Nemotron-3-Embed-1B-BF16
摘要
NVIDIA发布了Nemotron-3-Embed-1B-BF16,一款针对检索和语义相似度优化的多语言文本嵌入模型,在34种语言上实现了RAG系统的最优性能。
查看缓存全文
缓存时间: 2026/07/20 09:32
nvidia/Nemotron-3-Embed-1B-BF16 · Hugging Face
来源:https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#model-overview模型概述
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#description描述:
Nemotron-3-Embed-1B-BF16 是一款由 NVIDIA 训练的多功能文本嵌入模型,专为检索和语义相似度任务优化。它提供强大的多语言和跨语言检索能力,旨在成为基于文本的检索增强生成(RAG)系统中的基础组件。该模型在以下 34 种语言上进行了评估:英语、阿拉伯语、阿萨姆语、孟加拉语、保加利亚语、中文、丹麦语、荷兰语、芬兰语、法语、德语、印地语、混合印地语(Hinglish)、印度尼西亚语、意大利语、日语、韩语、马来语、马拉地语、尼泊尔语、挪威语、波斯语、葡萄牙语、罗马尼亚语、俄语、西班牙语、斯瓦希里语、瑞典语、泰米尔语、泰卢固语、泰语、乌克兰语、乌尔都语、越南语。
该模型能够从多语言文本输入中生成稠密向量嵌入,支持检索、语义搜索以及(代理式)RAG工作流。作为文本检索系统的核心组件,嵌入模型将文本(如问题或段落)转换为稠密向量表示。这些模型通常是Transformer编码器,对输入令牌(tokens)进行处理,生成适合高效相似度匹配的嵌入向量。
在规模相近的模型中,Nemotron-3-Embed-1B-BF16 在多个多语言检索基准测试中实现了最先进的性能。更多详细信息,请参见我们的博客文章 (https://huggingface.co/blog/nvidia/nemotron-3-embed-wins-rteb)。
该模型已准备好用于商业用途。
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#licenseterms-of-use许可证/使用条款:
本模型及其相关配置文件根据 OpenMDW 许可证协议 1.1 版 (OpenMDW-1.1) (https://openmdw.ai/license/1-1/) 进行许可。附加信息:基于 Ministral-3-3B-Instruct-2512 (https://huggingface.co/mistralai/Ministral-3-3B-Instruct-2512) 构建,该模型根据 Apache 2.0 许可证发布。
该项目将下载并安装额外的第三方开源软件项目。使用前请查看这些开源项目的许可条款。
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#deployment-geography部署地域:
全球
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#use-case-使用场景:
Nemotron-3-Embed-1B-BF16 最适用于希望利用最新稠密检索技术,在大型文本语料库上构建多语言问答应用的用户。
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#release-date-发布日期:
2026年7月16日,通过 https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#model-architecture模型架构:
**架构类型:**Transformer
**网络架构:**基于 Ministral-3-3B-Instruct-2512 (https://huggingface.co/mistralai/Ministral-3-3B-Instruct-2512) 的剪枝模型
**模型参数数量:**该模型约有 11.4 亿个参数
**隐藏层维度:**2048
Nemotron-3-Embed-1B-BF16 模型是一种基于 Transformer 的文本嵌入模型,采用双向注意力掩码,通过平均池化 Transformer 的令牌级表示来获取最终嵌入向量。它将每个输入文本编码为维度为 2048 的稠密嵌入向量。
Nemotron-3-Embed-1B-BF16 是通过对 Ministral-3-3B-Instruct-2512 (https://huggingface.co/mistralai/Ministral-3-3B-Instruct-2512) 进行两轮迭代的结构化剪枝和蒸馏得到的。首先,将 3B 参数的父模型训练为文本嵌入模型。然后,使用 NVIDIA ModelOpt mcore_minitron 神经架构搜索 (NAS) [NVIDIA/Model-Optimizer (https://github.com/NVIDIA/Model-Optimizer),论文 (https://arxiv.org/pdf/2407.14679)] 将其剪枝至 2B 参数。该过程在隐藏宽度、FFN 大小、注意力头数和深度上进行搜索,并从 Top-10 帕累托前沿中选择最佳候选。候选模型使用 5 万条领域内校准语料库与父模型的表示进行对比评估,同时该语料库也用于估计重要性分数。
然后,将得到的 2B 模型用微调后的 Nemotron-3-Embed-8B-BF16 (https://huggingface.co/nvidia/Nemotron-3-Embed-8B-BF16) 嵌入教师模型进行蒸馏,以恢复精度。蒸馏使用余弦距离损失 (COS) 和均方误差 (MSE) 损失的组合,在混合多语言领域内检索数据上训练。之后,使用相同的数据集混合重复上述剪枝和蒸馏过程,得到最终的 14 亿参数嵌入模型。
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#inputs-输入:
**输入类型:**文本
输入格式:
- 文本:字符串列表
输入参数:
- 文本:一维 (1D)
**与输入相关的其他属性:**文本输入需使用模型分词器进行分词。模型的最大序列长度为 32768。较长的输入应进行分块或截断。
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#outputs输出
**输出类型:**浮点数
输出格式:
- 浮点数组列表
**输出参数:**每个输入文本字符串对应一维 (1D) 嵌入向量
**与输出相关的其他属性:**模型为每个输入文本字符串输出一个 2048 维的嵌入向量。此外,支持通过从向量开头切片(例如,只保留前 1024 或 512 维)来动态调整嵌入大小。只要切片后的子向量重新进行 L2 归一化,这些切片嵌入仍保持高度可用。
我们的 AI 模型旨在或优化在 NVIDIA GPU 加速系统上运行。通过利用 NVIDIA 的硬件(如 GPU 核心)和软件框架(如 CUDA 库),该模型相比仅使用 CPU 的方案可实现更快的训练和推理时间。
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#usage用法
对于本地 Python 示例,默认使用 Hugging Face 模型 ID。如果从本地仓库工作,请将 MODEL_ID 替换为该路径。对于从本地检查点进行 vLLM 在线服务,请使用本地检查点示例。
MODEL_ID = "nvidia/Nemotron-3-Embed-1B-BF16"
该模型用于检索式嵌入。查询文本前添加 query: 前缀,文档文本前添加 passage: 前缀。嵌入已进行 L2 归一化,因此点积和余弦相似度等价。输出表格使用 q[i] 表示查询,d[i] 表示文档。分数四舍五入到四位小数。具体数值可能因运行时和软件包版本而异。
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#local-python-dependencies本地 Python 依赖
BF16 检查点支持 Transformers 5.2.0 及以上版本。示例还需要支持 CUDA 的 PyTorch 安装,且需与驱动和 CUDA 环境匹配。
如果未使用 NVIDIA PyTorch 容器,请先安装 PyTorch。使用 PyTorch 本地安装选择器 (https://pytorch.org/get-started/locally/) 选择与操作系统、包管理器和 CUDA 环境匹配的命令。如果默认的 PyPI wheel 与 CUDA 环境匹配,请运行:
pip install --upgrade torch
对于非默认 CUDA 环境,选择器可能包含额外的 --index-url 参数。当默认 PyPI wheel 与 CUDA 环境不匹配时,请使用该特定 CUDA 索引 URL。
然后安装 Transformers 和 Sentence Transformers:
pip install --upgrade "transformers>=5.2.0" "sentence-transformers>=5.4.1"
NVIDIA 在 nvcr.io/nvidia/pytorch:26.06-py3 容器中测试了这些示例,使用了容器自带的 Torch 和 CUDA 栈。在 NVIDIA PyTorch 容器内,请勿升级 Torch。只安装缺失的包:
pip install --upgrade "transformers>=5.2.0" "sentence-transformers>=5.4.1"
测试的 nvcr.io/nvidia/pytorch:26.06-py3 容器包含 flash-attn,因此代码段默认使用 FlashAttention-2。如果您的环境没有 FlashAttention-2,请将 attn_implementation 或 ATTN_IMPLEMENTATION 设置为 sdpa。
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#sentence-transformersSentence Transformers
使用 Sentence Transformers 可提供最简单的本地 Python 接口。它会读取保存的查询和文档提示词及归一化元数据。
import torch
from sentence_transformers import SentenceTransformer
MODEL_ID = "nvidia/Nemotron-3-Embed-1B-BF16"
model = SentenceTransformer(
MODEL_ID,
device="cuda",
model_kwargs={
"dtype": torch.bfloat16,
"attn_implementation": "flash_attention_2",
},
)
model.max_seq_length = 32768
QUERIES = [
"Write a Python function that counts the frequency of each element in a list of lists.",
"Write a function that orders a dictionary with tuple keys by the product of each key's tuple values.",
"What symptoms and common triggers help distinguish eczema from other inflammatory skin conditions?",
"How can someone reduce exposure to pollen during allergy season?",
]
DOCUMENTS = [
"def frequency_lists(list1):\n flattened = [item for sublist in list1 for item in sublist]\n counts = {}\n for item in flattened:\n if item in counts:\n counts[item] += 1\n else:\n counts[item] = 1\n return counts",
"def sort_dict_item(test_dict):\n return {key: test_dict[key] for key in sorted(test_dict.keys(), key=lambda ele: ele[0] * ele[1])}",
"Eczema commonly causes itchy, dry, inflamed patches of skin. The affected areas may look red, scaly, cracked, or darker than the surrounding skin depending on skin tone. Symptoms can flare after exposure to irritants, allergens, stress, or changes in weather.",
"People with pollen allergy can reduce exposure by staying indoors on dry, windy days, avoiding early-morning outdoor activity, and going outside after rain when pollen levels are lower. They should check pollen forecasts, close windows and doors when counts are high, and consider starting allergy medication before symptoms begin if high pollen is expected. After being outside, showering, changing clothes, avoiding outdoor laundry drying, and wearing a face mask for yard work can help limit pollen contact.",
]
query_embeddings = model.encode_query(QUERIES, batch_size=8, convert_to_tensor=True)
document_embeddings = model.encode_document(DOCUMENTS, batch_size=8, convert_to_tensor=True)
scores = model.similarity(query_embeddings, document_embeddings)
print("Similarity scores:")
print(f"{'':>4}" + "".join(f"d[{i}]".rjust(10) for i in range(scores.shape[1])))
for query_index, row in enumerate(scores):
print(f"q[{query_index}]" + "".join(f"{score.item():>10.4f}" for score in row))
Sentence Transformers 期望输出
Similarity scores:
d[0] d[1] d[2] d[3]
q[0] 0.8125 0.0255 0.0005 -0.0312
q[1] 0.0447 0.6484 -0.0520 0.0386
q[2] -0.0095 -0.0410 0.6484 0.1006
q[3] -0.0216 0.0214 0.1211 0.7734
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#transformersTransformers
当需要手动控制分词、池化或批处理时,可使用 Transformers。
import torch
import torch.nn.functional as F
from transformers import AutoModel, AutoTokenizer
MODEL_ID = "nvidia/Nemotron-3-Embed-1B-BF16"
MAX_LENGTH = 32768
BATCH_SIZE = 8
DTYPE = torch.bfloat16
ATTN_IMPLEMENTATION = "flash_attention_2"
QUERIES = [
"Write a Python function that counts the frequency of each element in a list of lists.",
"Write a function that orders a dictionary with tuple keys by the product of each key's tuple values.",
"What symptoms and common triggers help distinguish eczema from other inflammatory skin conditions?",
"How can someone reduce exposure to pollen during allergy season?",
]
DOCUMENTS = [
"def frequency_lists(list1):\n flattened = [item for sublist in list1 for item in sublist]\n counts = {}\n for item in flattened:\n if item in counts:\n counts[item] += 1\n else:\n counts[item] = 1\n return counts",
"def sort_dict_item(test_dict):\n return {key: test_dict[key] for key in sorted(test_dict.keys(), key=lambda ele: ele[0] * ele[1])}",
"Eczema commonly causes itchy, dry, inflamed patches of skin. The affected areas may look red, scaly, cracked, or darker than the surrounding skin depending on skin tone. Symptoms can flare after exposure to irritants, allergens, stress, or changes in weather.",
"People with pollen allergy can reduce exposure by staying indoors on dry, windy days, avoiding early-morning outdoor activity, and going outside after rain when pollen levels are lower. They should check pollen forecasts, close windows and doors when counts are high, and consider starting allergy medication before symptoms begin if high pollen is expected. After being outside, showering, changing clothes, avoiding outdoor laundry drying, and wearing a face mask for yard work can help limit pollen contact.",
]
def average_pool(last_hidden_state: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
last_hidden = last_hidden_state.masked_fill(~attention_mask[..., None].bool(), 0.0)
return last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]
if not torch.cuda.is_available():
raise RuntimeError("CUDA is required for practical BF16 inference.")
device = torch.device("cuda")
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, padding_side="left")
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
model = AutoModel.from_pretrained(
MODEL_ID,
dtype=DTYPE,
attn_implementation=ATTN_IMPLEMENTATION,
).to(device)
model.eval()
def encode_texts(texts: list[str]) -> torch.Tensor:
embedding_batches = []
for start in range(0, len(texts), BATCH_SIZE):
encoded = tokenizer(
texts[start : start + BATCH_SIZE],
max_length=MAX_LENGTH,
truncation=True,
padding=True,
return_tensors="pt",
)
encoded = {name: tensor.to(device) for name, tensor in encoded.items()}
with torch.inference_mode():
output = model(**encoded)
pooled = average_pool(output.last_hidden_state, encoded["attention_mask"])
embeddings = F.normalize(pooled, p=2, dim=-1)
embedding_batches.append(embeddings.detach().cpu().to(torch.float32))
return torch.cat(embedding_batches, dim=0)
embeddings = encode_texts(
["query: " + query for query in QUERIES]
+ ["passage: " + doc for doc in DOCUMENTS]
)
query_embeddings = embeddings[: len(QUERIES)]
document_embeddings = embeddings[len(QUERIES) :]
scores = query_embeddings @ document_embeddings.T
print("Similarity scores:")
print(f"{'':>4}" + "".join(f"d[{i}]".rjust(10) for i in range(scores.shape[1])))
for query_index, row in enumerate(scores):
print(f"q[{query_index}]" + "".join(f"{score.item():>10.4f}" for score in row))
Transformers 期望输出
Similarity scores:
d[0] d[1] d[2] d[3]
q[0] 0.8069 0.0252 0.0001 -0.0312
q[1] 0.0446 0.6466 -0.0514 0.0385
q[2] -0.0098 -0.0410 0.6450 0.0998
q[3] -0.0215 0.0212 0.1197 0.7679
https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16#vllm-dependenciesvLLM 依赖
对于 BF16,使用 vllm==0.25.0 进行 /v2/embed 服务。NVIDIA 还验证了在 vllm/vllm-openai:v0.20.0 到 v0.24.0 版本中,使用 vllm serve "$MODEL_ID" 处理该检查点。
pip install --upgrade "vllm==0.25.0" openai requests numpy
相似文章
Nemotron-3-Embed 1B/8B
NVIDIA 发布了 Nemotron-3-Embed 1B 和 8B 模型,这是最先进的多语言文本嵌入模型,用于检索和语义相似度,针对 RAG 系统进行了优化。
NVIDIA Nemotron 3 Embed 在RTEB整体排名第一,推动智能检索发展
NVIDIA发布Nemotron 3 Embed,这是一组开源嵌入模型,在RTEB排行榜上名列前茅,包括一个80亿参数的旗舰模型以及适用于生产规模检索的高效10亿参数变体。
NVIDIA 发布了 Nemotron-TwoTower-30B-A3B-Base-BF16,这是一种基于 Nemotron 3 Nano 30B-A3B 主干构建的异常扩散型语言模型。
NVIDIA 发布了 Nemotron-TwoTower-30B-A3B-Base-BF16,这是一种基于扩散的语言模型,采用逐块自回归扩散方法,通过对令牌块进行迭代去噪来生成文本,实现了自回归基线 2.42 倍的生成吞吐量,同时保留了基准测试质量 98.7% 的水平。
nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16 · Hugging Face
NVIDIA发布Nemotron-3-Ultra-550B-A55B,这是一个5500亿参数(550亿活跃参数)的前沿大语言模型,采用混合LatentMoE架构,结合Mamba-2、MoE和注意力层,支持高达100万令牌的上下文长度和可配置的推理模式。它支持11种语言,并针对复杂的智能体工作流、长上下文分析和高精度推理进行了优化。
nvidia/nemotron-3.5-asr-streaming-0.6b
NVIDIA 发布 Nemotron 3.5 ASR,这是一个6亿参数的多语言流式语音识别模型,支持40种语言区域,采用缓存感知的FastConformer-RNNT架构实现低延迟转录。该模型支持可配置的块大小,并已在OpenMDW-1.1许可证下准备商业化使用。