模型概述
模型特點
模型能力
使用案例
🚀 OpenCodeReasoning-Nemotron-7B
OpenCodeReasoning-Nemotron-7B 是一個大型語言模型(LLM),它基於 Qwen2.5-7B-Instruct(參考模型)衍生而來。這是一個經過後訓練的推理模型,用於代碼生成推理,支持 32K 令牌的上下文長度。該模型可用於商業或非商業用途。
🚀 快速開始
運行編碼問題推理
import transformers
import torch
model_id = "nvidia/OpenCodeReasoning-Nemotron-7B"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
prompt = """You are a helpful and harmless assistant. You should think step-by-step before responding to the instruction below.
Please use python programming language only.
You must use ```python for just the final solution code block with the following format:
```python
# Your code here
{user} """
messages = [ { "role": "user", "content": prompt.format(user="Write a program to calculate the sum of the first $N$ fibonacci numbers")}, ]
outputs = pipeline( messages, max_new_tokens=32768, ) print(outputs[0]["generated_text"][-1]['content'])
## ✨ 主要特性
- 基於 Qwen2.5-7B-Instruct 開發,擁有 70 億模型參數。
- 支持 32K 令牌的上下文長度。
- 可用於商業和非商業用途。
- 設計並優化為在 NVIDIA GPU 加速系統上運行,相比僅使用 CPU 的解決方案,訓練和推理速度更快。
## 📦 安裝指南
文檔未提及安裝步驟,故跳過。
## 💻 使用示例
### 基礎用法
```python
# 運行編碼問題推理
import transformers
import torch
model_id = "nvidia/OpenCodeReasoning-Nemotron-7B"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
prompt = """You are a helpful and harmless assistant. You should think step-by-step before responding to the instruction below.
Please use python programming language only.
You must use ```python for just the final solution code block with the following format:
```python
# Your code here
{user} """
messages = [ { "role": "user", "content": prompt.format(user="Write a program to calculate the sum of the first $N$ fibonacci numbers")}, ]
outputs = pipeline( messages, max_new_tokens=32768, ) print(outputs[0]["generated_text"][-1]['content'])
## 📚 詳細文檔
### 模型架構
- **架構類型**:密集型僅解碼器 Transformer 模型
- **網絡架構**:Qwen-7B-Instruct
### 輸入
- **輸入類型**:文本
- **輸入格式**:字符串
- **輸入參數**:一維(1D)
- **其他輸入相關屬性**:上下文長度最大為 32,768 個令牌
### 輸出
- **輸出類型**:文本
- **輸出格式**:字符串
- **輸出參數**:一維(1D)
- **其他輸出相關屬性**:上下文長度最大為 32,768 個令牌
### 軟件集成
- **運行時引擎**:NeMo 2.3.0
- **推薦硬件微架構兼容性**:NVIDIA Ampere、NVIDIA Hopper
- **首選/支持的操作系統**:Linux
### 模型版本
- 1.0 (2025 年 4 月 25 日)
- OpenCodeReasoning-Nemotron-7B
- OpenCodeReasoning-Nemotron-14B
- OpenCodeReasoning-Nemotron-32B
- OpenCodeReasoning-Nemotron-32B-IOI
### 訓練和評估數據集
#### 訓練數據集
OpenCodeReasoning-Nemotron-7B 的訓練語料庫是 [OpenCodeReasoning](https://huggingface.co/datasets/nvidia/OpenCodeReasoning) 數據集,由競賽編程問題和 DeepSeek-R1 生成的響應組成。
- **數據收集方法**:混合:自動、人工、合成
- **標註方法**:混合:自動、人工、合成
- **屬性**:來自 OpenCodeReasoning 的 736k 個樣本
#### 評估數據集
使用下一節列出的數據集對 OpenCodeReasoning-Nemotron-7B 進行評估。
- **數據收集方法**:混合:自動、人工、合成
- **標註方法**:混合:自動、人工、合成
### 許可證/使用條款
本模型的使用受 [Apache 2.0](https://huggingface.co/nvidia/OpenCode-Nemotron-2-7B/blob/main/LICENSE) 條款約束。
### 部署地域
全球
### 使用場景
本模型適用於構建大語言模型的開發者和研究人員。
### 發佈日期
2025 年 4 月 25 日通過 Huggingface [https://huggingface.co/nvidia/OpenCodeReasoning-Nemotron-7B/](https://huggingface.co/nvidia/OpenCodeReasoning-Nemotron-7B/) 發佈
### 參考資料
[2504.01943] OpenCodeReasoning: Advancing Data Distillation for Competitive Coding
### 推理
- **引擎**:vLLM
- **測試硬件**:NVIDIA H100 - 80GB
### 倫理考量
NVIDIA 認為可信 AI 是一項共同責任,並已制定政策和實踐,以支持廣泛的 AI 應用開發。當開發者按照服務條款下載或使用本模型時,應與內部模型團隊合作,確保該模型滿足相關行業和用例的要求,並解決意外的產品濫用問題。請在此報告安全漏洞或 NVIDIA AI 相關問題。
## 🔧 技術細節
文檔未提及技術實現細節,故跳過。
## 📄 許可證
本模型的使用受 [Apache 2.0](https://huggingface.co/nvidia/OpenCode-Nemotron-2-7B/blob/main/LICENSE) 許可證約束。
## 🔍 評估結果
以下結果是在每個基準測試上進行 **64 次評估** 的平均值。
| 模型 | LiveCodeBench 平均得分 | CodeContest 總分 |
|------------------------|--------------------|-----------------|
| DeepSeek - R1 | 65.6 | 26.2 |
| QwQ - 32B | 61.3 | 20.2 |
| **蒸餾 7B+ 模型** | | |
| Bespoke - Stratos - 7B | 14.7 | 2.0 |
| OpenThinker - 7B | 25.5 | 5.0 |
| R1 - Distill - Qwen - 7B | 38.0 | 11.1 |
| OlympicCoder - 7B | 40.9 | 10.6 |
| **OCR - Qwen - 7B** | **48.5** | **16.3** |
| **OCR - Qwen - 7B - Instruct** | **51.3** | **18.1** |
| **蒸餾 14B+ 模型** | | |
| R1 - Distill - Qwen - 14B | 51.3 | 17.6 |
| **OCR - Qwen - 14B** | **57.7** | **22.6** |
| **OCR - Qwen - 14B - Instruct** | **59.4** | **23.6** |
| **蒸餾 32B+ 模型** | | |
| Bespoke - Stratos - 32B | 30.1 | 6.3 |
| OpenThinker - 32B | 54.1 | 16.4 |
| R1 - Distill - Qwen - 32B | 58.1 | 18.3 |
| OlympicCoder - 32B | 57.4 | 18.0 |
| **OCR - Qwen - 32B** | **61.8** | **24.6** |
| **OCR - Qwen - 32B - Instruct** | **61.7** | **24.4** |
## 🔗 重現結果
- [模型](https://huggingface.co/collections/nvidia/opencodereasoning-2-68168f37cd7c6beb1e3f92e7)
- [數據集](https://huggingface.co/datasets/nvidia/OpenCodeReasoning)
- [論文](https://arxiv.org/abs/2504.01943)
## 📚 引用
如果您發現這些數據有用,請引用:
@article{ahmad2025opencodereasoning, title={OpenCodeReasoning: Advancing Data Distillation for Competitive Coding}, author={Wasi Uddin Ahmad, Sean Narenthiran, Somshubra Majumdar, Aleksander Ficek, Siddhartha Jain, Jocelyn Huang, Vahid Noroozi, Boris Ginsburg}, year={2025}, eprint={2504.01943}, archivePrefix={arXiv}, primaryClass={cs.CL}, url={https://arxiv.org/abs/2504.01943}, }



