NVIDIA Llama-Nemotron-Colembed-VL-3B-V2 API完全指南查询、文档与图像嵌入的最佳实践【免费下载链接】llama-nemotron-colembed-vl-3b-v2项目地址: https://ai.gitcode.com/hf_mirrors/nvidia/llama-nemotron-colembed-vl-3b-v2NVIDIA Llama-Nemotron-Colembed-VL-3B-V2是一款强大的多模态嵌入模型专为查询-文档检索优化支持文本查询与图像文档的嵌入生成通过ColBERT风格的多向量数值表示实现高效的跨模态检索。本指南将帮助您快速掌握其API使用方法、核心功能与最佳实践。 模型核心优势与应用场景✨ v2版本关键改进高级模型融合通过训练后模型合并技术结合多个微调检查点的优势在不增加推理延迟的情况下实现集成模型的精度稳定性增强合成数据显著丰富了训练数据中的多语言合成数据提升跨语言和复杂文档类型的语义对齐能力 典型应用场景多模态RAG系统处理文本查询与图像文档如页面、图表、表格、信息图的检索多媒体搜索引擎构建跨文本和图像的内容检索系统对话式AI增强对富媒体输入的理解能力 模型基础架构与技术规格 架构组成Llama-Nemotron-Colembed-VL-3B-V2基于Transformer架构由以下组件构成视觉编码器google/siglip2-giant-opt-patch16-384语言模型meta-llama/Llama-3.2-3B总参数量约4.4B 输入输出规格输入类型与格式文本字符串列表一维图像RGB格式的PIL图像列表二维图像处理特性每张图像切片消耗256 tokens默认配置max_input_tiles 8use_thumbnails True图像会被分割为最多8个切片1个缩略图低分辨率完整图像输出规格输出类型浮点数数组输出形状[batchsize x seq length x embedding_dim]嵌入维度3072维️ 快速开始安装与基础使用 环境准备首先安装必要的依赖包pip install transformers4.45.0 pip install flash-attn2.6.3 --no-build-isolation根据环境可能需要升级额外依赖pip install -U datasets polars pip install -U pydantic 模型加载使用transformers库加载模型import torch from transformers import AutoModel model AutoModel.from_pretrained( nvidia/llama-nemotron-colembed-vl-3b-v2, device_mapcuda, trust_remote_codeTrue, torch_dtypetorch.bfloat16, attn_implementationflash_attention_2 ).eval() 文本查询嵌入生成文本查询的嵌入向量queries [ How is AI improving the intelligence and capabilities of robots?, Canary, a multilingual model that transcribes speech in English, Spanish, German, and French with punctuation and capitalization., Generative AI can generate DNA sequences that can be translated into proteins for bioengineering. ] query_embeddings model.forward_queries(queries, batch_size8)️ 图像文档嵌入处理图像并生成嵌入向量from transformers.image_utils import load_image image_urls [ https://developer.download.nvidia.com/images/isaac/nvidia-isaac-lab-1920x1080.jpg, https://developer-blogs.nvidia.com/wp-content/uploads/2024/03/asr-nemo-canary-featured.jpg, https://blogs.nvidia.com/wp-content/uploads/2023/02/genome-sequencing-helix.jpg ] images [load_image(img_path) for img_path in image_urls] image_embeddings model.forward_images(images, batch_size8) 计算相似度分数获取查询与图像文档之间的相似度分数scores model.get_scores( query_embeddings, image_embeddings ) print(scores) # tensor([[10.9662, 10.6623, 10.0281], # [17.7323, 18.6031, 17.7613], # [13.2915, 13.6993, 13.7968]], devicecuda:0) API详细解析 文本处理方法forward_queries(queries, batch_size8)功能处理文本查询并生成嵌入向量参数queries字符串列表或DataLoaderbatch_size批处理大小默认为8返回形状为(num_queries, max_seq_len, hidden_dim)的张量️ 图像处理方法forward_images(images, batch_size8)功能处理图像文档并生成嵌入向量参数imagesPIL图像列表batch_size批处理大小默认为8返回形状为(num_images, max_seq_len, hidden_dim)的张量forward_documents(corpus, batch_size8)功能处理包含图像和文本的文档参数corpus字典列表每个字典包含image和text键batch_size批处理大小默认为8返回文档嵌入张量 检索评分方法get_scores(query_embeddings, passage_embeddings, batch_size128)功能计算查询与文档嵌入之间的ColBERT MaxSim分数参数query_embeddings查询嵌入张量或张量列表passage_embeddings文档嵌入张量或张量列表batch_size计算批次大小默认为128返回形状为(num_queries, num_passages)的分数矩阵⚙️ 配置参数详解模型配置可通过configuration_llama_nemotron_vl.py文件查看和调整关键参数包括 文本处理配置q_max_length查询最大长度默认为512p_max_length文档最大长度默认为10240query_prefix查询前缀默认为query:passage_prefix文档前缀默认为passage:️ 图像处理配置max_input_tiles最大图像切片数默认为2use_thumbnail是否使用缩略图默认为Falsedynamic_image_size是否使用动态图像大小默认为Falsemin_dynamic_patch/max_dynamic_patch动态补丁大小范围 模型架构配置select_layer选择提取特征的层默认为-1最后一层pooling池化方式默认为lastbidirectional_attention是否使用双向注意力默认为False 评估与性能 基准测试结果Llama-Nemotron-Colembed-VL-3B-V2在ViDoReVisual Document Retrieval基准测试中表现优异Benchmarkllama-nemoretriever-colembed-3b-v1llama-nemotron-colembed-vl-3b-v2ViDoRe V10.91000.9174ViDoRe V20.63320.6338ViDoRe V30.57070.5970注ViDoRe V1和V2的精度以NDCG5报告ViDoRe V3以NDCG10报告 运行评估脚本使用MTEB 2库评估模型性能pip install mteb2.6.0, 3.0.0 # 评估ViDoRe V1和V2 CUDA_VISIBLE_DEVICES0; python3 mteb2_eval.py --model_name nvidia/llama-nemotron-colembed-vl-3b-v2 --batch_size 16 --benchmark VisualDocumentRetrieval # 评估ViDoRe V3 CUDA_VISIBLE_DEVICES0; python3 mteb2_eval.py --model_name nvidia/llama-nemotron-colembed-vl-3b-v2 --batch_size 16 --benchmark ViDoRe(v3) # 评估ViDoRe V3特定任务 CUDA_VISIBLE_DEVICES0; python3 mteb2_eval.py --model_name nvidia/llama-nemotron-colembed-vl-3b-v2 --batch_size 16 --benchmark ViDoRe(v3) --task-list Vidore3ComputerScienceRetrieval 最佳实践与优化建议 性能优化硬件加速推荐使用NVIDIA Ampere (A100)或Hopper (H100) GPU启用Flash Attention 2加速注意力计算批处理策略根据GPU内存调整批处理大小A100 40GB建议批大小为16-32对长文档使用动态批处理以提高吞吐量内存管理使用torch.bfloat16dtype减少内存占用对大型图像集采用渐进式加载策略 使用技巧文本查询优化保持查询简洁关键信息放在句首使用领域特定术语提高检索精度图像处理建议确保图像分辨率至少为512x512对复杂文档如多图表PDF先分割为单页图像检索系统构建结合FAISS或Annoy等向量数据库实现高效检索对嵌入向量进行归一化以提高相似度计算稳定性 许可证与引用 许可证信息本模型的使用受NVIDIA Non-Commercial License Agreement约束适用于非商业/研究用途。模型基于Meta Llama 3.2构建Llama 3.2受Llama 3.2 Community License约束。 引用格式misc{moreira2026_nemotron_colembed_v2, title{Nemotron ColEmbed V2: Top-Performing Late Interaction embedding models for Visual Document Retrieval}, author{Gabriel de Souza P. Moreira, Ronay Ak, Mengyao Xu, Oliver Holworthy, Benedikt Schifferer, Zhiding Yu, Yauhen Babakhin, Radek Osmulski, Jiarui Cai, Ryan Chesler, Bo Liu, Even Oldridge}, year{2026}, eprint{2602.03992}, archivePrefix{arXiv}, primaryClass{cs.IR}, url{https://arxiv.org/abs/2602.03992}, } 相关资源模型文件modeling_llama_nemotron_vl.py - 模型架构实现config.json - 模型配置参数processor_config.json - 处理器配置评估脚本mteb2_eval.py - MTEB基准测试脚本vidore_eval.py - ViDoRe基准测试专用脚本** tokenizer文件**tokenizer.jsontokenizer_config.jsonspecial_tokens_map.json【免费下载链接】llama-nemotron-colembed-vl-3b-v2项目地址: https://ai.gitcode.com/hf_mirrors/nvidia/llama-nemotron-colembed-vl-3b-v2创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
NVIDIA Llama-Nemotron-Colembed-VL-3B-V2 API完全指南:查询、文档与图像嵌入的最佳实践
NVIDIA Llama-Nemotron-Colembed-VL-3B-V2 API完全指南查询、文档与图像嵌入的最佳实践【免费下载链接】llama-nemotron-colembed-vl-3b-v2项目地址: https://ai.gitcode.com/hf_mirrors/nvidia/llama-nemotron-colembed-vl-3b-v2NVIDIA Llama-Nemotron-Colembed-VL-3B-V2是一款强大的多模态嵌入模型专为查询-文档检索优化支持文本查询与图像文档的嵌入生成通过ColBERT风格的多向量数值表示实现高效的跨模态检索。本指南将帮助您快速掌握其API使用方法、核心功能与最佳实践。 模型核心优势与应用场景✨ v2版本关键改进高级模型融合通过训练后模型合并技术结合多个微调检查点的优势在不增加推理延迟的情况下实现集成模型的精度稳定性增强合成数据显著丰富了训练数据中的多语言合成数据提升跨语言和复杂文档类型的语义对齐能力 典型应用场景多模态RAG系统处理文本查询与图像文档如页面、图表、表格、信息图的检索多媒体搜索引擎构建跨文本和图像的内容检索系统对话式AI增强对富媒体输入的理解能力 模型基础架构与技术规格 架构组成Llama-Nemotron-Colembed-VL-3B-V2基于Transformer架构由以下组件构成视觉编码器google/siglip2-giant-opt-patch16-384语言模型meta-llama/Llama-3.2-3B总参数量约4.4B 输入输出规格输入类型与格式文本字符串列表一维图像RGB格式的PIL图像列表二维图像处理特性每张图像切片消耗256 tokens默认配置max_input_tiles 8use_thumbnails True图像会被分割为最多8个切片1个缩略图低分辨率完整图像输出规格输出类型浮点数数组输出形状[batchsize x seq length x embedding_dim]嵌入维度3072维️ 快速开始安装与基础使用 环境准备首先安装必要的依赖包pip install transformers4.45.0 pip install flash-attn2.6.3 --no-build-isolation根据环境可能需要升级额外依赖pip install -U datasets polars pip install -U pydantic 模型加载使用transformers库加载模型import torch from transformers import AutoModel model AutoModel.from_pretrained( nvidia/llama-nemotron-colembed-vl-3b-v2, device_mapcuda, trust_remote_codeTrue, torch_dtypetorch.bfloat16, attn_implementationflash_attention_2 ).eval() 文本查询嵌入生成文本查询的嵌入向量queries [ How is AI improving the intelligence and capabilities of robots?, Canary, a multilingual model that transcribes speech in English, Spanish, German, and French with punctuation and capitalization., Generative AI can generate DNA sequences that can be translated into proteins for bioengineering. ] query_embeddings model.forward_queries(queries, batch_size8)️ 图像文档嵌入处理图像并生成嵌入向量from transformers.image_utils import load_image image_urls [ https://developer.download.nvidia.com/images/isaac/nvidia-isaac-lab-1920x1080.jpg, https://developer-blogs.nvidia.com/wp-content/uploads/2024/03/asr-nemo-canary-featured.jpg, https://blogs.nvidia.com/wp-content/uploads/2023/02/genome-sequencing-helix.jpg ] images [load_image(img_path) for img_path in image_urls] image_embeddings model.forward_images(images, batch_size8) 计算相似度分数获取查询与图像文档之间的相似度分数scores model.get_scores( query_embeddings, image_embeddings ) print(scores) # tensor([[10.9662, 10.6623, 10.0281], # [17.7323, 18.6031, 17.7613], # [13.2915, 13.6993, 13.7968]], devicecuda:0) API详细解析 文本处理方法forward_queries(queries, batch_size8)功能处理文本查询并生成嵌入向量参数queries字符串列表或DataLoaderbatch_size批处理大小默认为8返回形状为(num_queries, max_seq_len, hidden_dim)的张量️ 图像处理方法forward_images(images, batch_size8)功能处理图像文档并生成嵌入向量参数imagesPIL图像列表batch_size批处理大小默认为8返回形状为(num_images, max_seq_len, hidden_dim)的张量forward_documents(corpus, batch_size8)功能处理包含图像和文本的文档参数corpus字典列表每个字典包含image和text键batch_size批处理大小默认为8返回文档嵌入张量 检索评分方法get_scores(query_embeddings, passage_embeddings, batch_size128)功能计算查询与文档嵌入之间的ColBERT MaxSim分数参数query_embeddings查询嵌入张量或张量列表passage_embeddings文档嵌入张量或张量列表batch_size计算批次大小默认为128返回形状为(num_queries, num_passages)的分数矩阵⚙️ 配置参数详解模型配置可通过configuration_llama_nemotron_vl.py文件查看和调整关键参数包括 文本处理配置q_max_length查询最大长度默认为512p_max_length文档最大长度默认为10240query_prefix查询前缀默认为query:passage_prefix文档前缀默认为passage:️ 图像处理配置max_input_tiles最大图像切片数默认为2use_thumbnail是否使用缩略图默认为Falsedynamic_image_size是否使用动态图像大小默认为Falsemin_dynamic_patch/max_dynamic_patch动态补丁大小范围 模型架构配置select_layer选择提取特征的层默认为-1最后一层pooling池化方式默认为lastbidirectional_attention是否使用双向注意力默认为False 评估与性能 基准测试结果Llama-Nemotron-Colembed-VL-3B-V2在ViDoReVisual Document Retrieval基准测试中表现优异Benchmarkllama-nemoretriever-colembed-3b-v1llama-nemotron-colembed-vl-3b-v2ViDoRe V10.91000.9174ViDoRe V20.63320.6338ViDoRe V30.57070.5970注ViDoRe V1和V2的精度以NDCG5报告ViDoRe V3以NDCG10报告 运行评估脚本使用MTEB 2库评估模型性能pip install mteb2.6.0, 3.0.0 # 评估ViDoRe V1和V2 CUDA_VISIBLE_DEVICES0; python3 mteb2_eval.py --model_name nvidia/llama-nemotron-colembed-vl-3b-v2 --batch_size 16 --benchmark VisualDocumentRetrieval # 评估ViDoRe V3 CUDA_VISIBLE_DEVICES0; python3 mteb2_eval.py --model_name nvidia/llama-nemotron-colembed-vl-3b-v2 --batch_size 16 --benchmark ViDoRe(v3) # 评估ViDoRe V3特定任务 CUDA_VISIBLE_DEVICES0; python3 mteb2_eval.py --model_name nvidia/llama-nemotron-colembed-vl-3b-v2 --batch_size 16 --benchmark ViDoRe(v3) --task-list Vidore3ComputerScienceRetrieval 最佳实践与优化建议 性能优化硬件加速推荐使用NVIDIA Ampere (A100)或Hopper (H100) GPU启用Flash Attention 2加速注意力计算批处理策略根据GPU内存调整批处理大小A100 40GB建议批大小为16-32对长文档使用动态批处理以提高吞吐量内存管理使用torch.bfloat16dtype减少内存占用对大型图像集采用渐进式加载策略 使用技巧文本查询优化保持查询简洁关键信息放在句首使用领域特定术语提高检索精度图像处理建议确保图像分辨率至少为512x512对复杂文档如多图表PDF先分割为单页图像检索系统构建结合FAISS或Annoy等向量数据库实现高效检索对嵌入向量进行归一化以提高相似度计算稳定性 许可证与引用 许可证信息本模型的使用受NVIDIA Non-Commercial License Agreement约束适用于非商业/研究用途。模型基于Meta Llama 3.2构建Llama 3.2受Llama 3.2 Community License约束。 引用格式misc{moreira2026_nemotron_colembed_v2, title{Nemotron ColEmbed V2: Top-Performing Late Interaction embedding models for Visual Document Retrieval}, author{Gabriel de Souza P. Moreira, Ronay Ak, Mengyao Xu, Oliver Holworthy, Benedikt Schifferer, Zhiding Yu, Yauhen Babakhin, Radek Osmulski, Jiarui Cai, Ryan Chesler, Bo Liu, Even Oldridge}, year{2026}, eprint{2602.03992}, archivePrefix{arXiv}, primaryClass{cs.IR}, url{https://arxiv.org/abs/2602.03992}, } 相关资源模型文件modeling_llama_nemotron_vl.py - 模型架构实现config.json - 模型配置参数processor_config.json - 处理器配置评估脚本mteb2_eval.py - MTEB基准测试脚本vidore_eval.py - ViDoRe基准测试专用脚本** tokenizer文件**tokenizer.jsontokenizer_config.jsonspecial_tokens_map.json【免费下载链接】llama-nemotron-colembed-vl-3b-v2项目地址: https://ai.gitcode.com/hf_mirrors/nvidia/llama-nemotron-colembed-vl-3b-v2创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考