🚀 奈莫特朗超长8B模型
奈莫特朗超长8B(Nemotron-UltraLong-8B) 是一系列超长上下文语言模型,旨在处理大量文本序列(最多可达100万、200万和400万个标记),同时在标准基准测试中保持有竞争力的性能。该模型基于Llama-3.1构建,采用了系统的训练方法,将高效的持续预训练与指令微调相结合,以增强长上下文理解和指令遵循能力。这种方法使模型能够在不牺牲整体性能的情况下,有效扩展其上下文窗口。
🚀 快速开始
从 transformers >= 4.43.0
版本开始,你可以使用Transformers的 pipeline
抽象或借助 generate()
函数的自动类来进行对话推理。
请确保通过 pip install --upgrade transformers
更新你的transformers库。
import transformers
import torch
model_id = "nvidia/Llama-3.1-Nemotron-8B-UltraLong-2M-Instruct"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
messages = [
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
{"role": "user", "content": "Who are you?"},
]
outputs = pipeline(
messages,
max_new_tokens=256,
)
print(outputs[0]["generated_text"][-1])
✨ 主要特性
- 超长上下文处理能力:能够处理多达400万个标记的文本序列,适用于需要处理长文本的任务。
- 高性能表现:在超长上下文任务和标准基准测试中均表现出色。
- 基于Llama-3.1架构:继承了Llama-3.1的优秀特性,并通过持续预训练和指令微调进一步优化。
📦 安装指南
确保你的 transformers
库版本为 4.43.0
或更高。可以使用以下命令进行更新:
pip install --upgrade transformers
💻 使用示例
基础用法
import transformers
import torch
model_id = "nvidia/Llama-3.1-Nemotron-8B-UltraLong-2M-Instruct"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
messages = [
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
{"role": "user", "content": "Who are you?"},
]
outputs = pipeline(
messages,
max_new_tokens=256,
)
print(outputs[0]["generated_text"][-1])
📚 详细文档
模型卡片
评估结果
我们在一系列多样化的基准测试中对奈莫特朗超长8B模型进行了评估,包括长上下文任务(如RULER、LV-Eval和InfiniteBench)和标准任务(如MMLU、MATH、GSM-8K和HumanEval)。超长8B模型在超长上下文任务中表现卓越,同时在标准基准测试中也保持了有竞争力的结果。
大海捞针任务

长上下文评估

标准能力评估

🔧 技术细节
奈莫特朗超长8B模型基于Llama-3.1架构构建,通过持续预训练和指令微调来增强其长上下文理解和指令遵循能力。持续预训练阶段使用了特定的训练数据和采样方法,以提高模型在长序列上的性能。监督微调阶段则在多个领域的开源指令数据集上进行,进一步优化模型的性能。
📄 许可证
本模型采用CC BY-NC 4.0许可证。
联系方式
- Chejian Xu (chejian2@illinois.edu)
- Wei Ping (wping@nvidia.com)
引用
@article{ulralong2025,
title={From 128K to 4M: Efficient Training of Ultra-Long Context Large Language Models},
author={Xu, Chejian and Ping, Wei and Xu, Peng and Liu, Zihan and Wang, Boxin and Shoeybi, Mohammad and Catanzaro, Bryan},
journal={arXiv preprint},
year={2025}
}