🚀 超長上下文語言模型 Nemotron-UltraLong-8B
Nemotron-UltraLong-8B 是一系列超長上下文語言模型,旨在處理大量文本序列(最多可達 100 萬、200 萬和 400 萬個標記),同時在標準基準測試中保持有競爭力的性能。該模型基於 Llama-3.1 構建,採用了系統的訓練方法,將高效的持續預訓練與指令微調相結合,以增強長上下文理解和指令遵循能力。這種方法使模型能夠在不犧牲整體性能的情況下,有效擴展其上下文窗口。
🚀 快速開始
從 transformers >= 4.43.0
版本開始,你可以使用 Transformers 的 pipeline
抽象或藉助 generate()
函數的 Auto 類來運行對話推理。
請確保通過 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])
📚 詳細文檔
模型列表
模型卡片
屬性 |
詳情 |
基礎模型 |
meta-llama/Llama-3.1-8B-Instruct |
持續預訓練 |
訓練數據包含 10 億個標記,這些標記來自預訓練語料庫,採用基於樣本長度的按域上採樣方法。模型在序列長度為 200 萬、全局批次大小為 2 的情況下訓練了 245 步。 |
監督微調(SFT) |
在通用、數學和代碼領域的開源指令數據集上使用 10 億個標記進行微調。我們從 AceMath-Instruct 的 ‘general_sft_stage2’ 中對數據進行子採樣。 |
最大上下文窗口 |
200 萬個標記 |
評估結果
我們在一系列多樣化的基準測試中對 Nemotron-UltraLong-8B 進行了評估,包括長上下文任務(如 RULER、LV-Eval 和 InfiniteBench)和標準任務(如 MMLU、MATH、GSM-8K 和 HumanEval)。UltraLong-8B 在超長上下文任務中表現出色,同時在標準基準測試中也保持了有競爭力的結果。
大海撈針任務

長上下文評估

標準能力評估

聯繫方式
- 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}
}
📄 許可證
本項目採用 CC BY-NC 4.0 許可證。