Haoxiang-Wang commited on
Commit
f8b463e
·
verified ·
1 Parent(s): 8a5f881

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +292 -5
README.md CHANGED
@@ -1,5 +1,292 @@
1
- ---
2
- license: other
3
- license_name: nvidia-non-commercial-license
4
- license_link: LICENSE
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - BytedTsinghua-SIA/DAPO-Math-17k
4
+ language:
5
+ - en
6
+ base_model:
7
+ - Qwen/Qwen2.5-32B
8
+ pipeline_tag: text-generation
9
+ license: other
10
+ license_name: nvidia-non-commercial-license
11
+ license_link: https://huggingface.co/nvidia/NFT-32B/blob/main/LICENSE
12
+ library_name: transformers
13
+ tags:
14
+ - nvidia
15
+ - math
16
+ - reasoning
17
+ - post-training
18
+ - qwen
19
+ ---
20
+
21
+ # Negative-aware Fine-Tuning: Bridging Supervised Learning and Reinforcement Learning in Math Reasoning
22
+
23
+ > [!Warning]
24
+ > <div align="center">
25
+ > <b>
26
+ > 🚨 NFT-32B is specifically designed for mathematical reasoning tasks. We do not recommend using this model for general conversation or non-mathematical tasks.
27
+ > </b>
28
+ > </div>
29
+
30
+ **Tsinghua University, NVIDIA, Stanford University**
31
+
32
+ [Huayu Chen](https://github.com/chendrag), [Kaiwen Zheng](https://github.com/kaiwenzheng), [Qinsheng Zhang](https://github.com/qzhang), [Ganqu Cui](https://github.com/ganqucui), [Yin Cui](https://research.nvidia.com/person/yin-cui), [Haotian Ye](https://github.com/haotianye), [Tsung-Yi Lin](https://research.nvidia.com/person/tsung-yi-lin), [Ming-Yu Liu](https://research.nvidia.com/person/ming-yu-liu), [Jun Zhu](https://ml.cs.tsinghua.edu.cn/~jun/index.shtml), [Haoxiang Wang](https://research.nvidia.com/person/haoxiang-wang)
33
+
34
+ [[Paper](https://arxiv.org/abs/2505.18116)] | [[Blog](https://research.nvidia.com/labs/dir/Negative-aware-Fine-Tuning/)] | [[Code](https://github.com/nvidia/NFT)] | [[Dataset](https://huggingface.co/datasets/BytedTsinghua-SIA/DAPO-Math-17k)] | [[Models](https://huggingface.co/collections/nvidia/nft-models)] | [[Citation](#citation)]
35
+
36
+ ![Algorithm Spectrum](../assets/algorithm_spectrum_NFT.jpg)
37
+
38
+ ## Model Overview
39
+
40
+ ### Description
41
+
42
+ NFT-32B is a math reasoning model finetuned from [Qwen2.5-32B](https://huggingface.co/Qwen/Qwen2.5-32B) using the Negative-aware Fine-Tuning (NFT) algorithm. NFT is a supervised learning approach that enables LLMs to reflect on their failures and improve autonomously with no external teachers. Unlike traditional supervised methods that discard incorrect answers, NFT constructs an implicit negative policy to model and learn from these failures, achieving performance comparable to leading RL algorithms like GRPO and DAPO.
43
+
44
+ This larger 32B model demonstrates strong scaling properties, achieving substantial improvements in mathematical reasoning while maintaining the efficiency of supervised learning methods.
45
+
46
+ This model is for research and development only.
47
+
48
+ ### Model Developer
49
+
50
+ NVIDIA, Tsinghua University, Stanford University
51
+
52
+ ### License
53
+
54
+ [NVIDIA Non-Commercial License](https://huggingface.co/nvidia/NFT-32B/blob/main/LICENSE)
55
+
56
+ This model is released under the NVIDIA Non-Commercial License. The model is for research and development only.
57
+
58
+ ### Deployment Geography
59
+
60
+ Global
61
+
62
+ ### Release Date
63
+
64
+ Huggingface 06/27/2025
65
+
66
+ - NFT-7B: https://huggingface.co/nvidia/NFT-7B/
67
+ - NFT-32B: https://huggingface.co/nvidia/NFT-32B/
68
+
69
+ ### Use Case
70
+
71
+ Mathematical reasoning and problem-solving, including:
72
+ - Competition-level mathematics (AIME, AMC, Olympiad)
73
+ - General mathematical reasoning (MATH500, Minerva Math)
74
+ - Step-by-step mathematical solution generation
75
+
76
+ ## Model Architecture
77
+
78
+ **Architecture Type:** Transformer decoder-only language model
79
+
80
+ **Network Architecture:** Qwen2.5 with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
81
+
82
+ NFT-32B is post-trained based on [Qwen2.5-32B](https://huggingface.co/Qwen/Qwen2.5-32B) and follows the same model architecture:
83
+ - Number of Parameters: 32.5B
84
+ - Number of Parameters (Non-Embedding): 31.0B
85
+ - Number of Layers: 64
86
+ - Number of Attention Heads (GQA): 40 for Q and 8 for KV
87
+
88
+ ## Input
89
+
90
+ **Input Type(s):** Text
91
+
92
+ **Input Format:** String
93
+
94
+ **Input Parameters:** One-dimensional (1D)
95
+
96
+ **Other Properties Related to Input:**
97
+ - Context length up to 131,072 tokens
98
+ - Mathematical problems should be clearly stated
99
+ - Supports LaTeX notation for mathematical expressions
100
+
101
+ ## Output
102
+
103
+ **Output Type(s):** Text
104
+
105
+ **Output Format:** String
106
+
107
+ **Output Parameters:** One-dimensional (1D)
108
+
109
+ **Other Properties Related to Output:**
110
+ - Step-by-step mathematical reasoning
111
+ - Final answers should be enclosed in `\boxed{}`
112
+ - Supports LaTeX notation for mathematical expressions
113
+ - Can generate up to 8,192 tokens
114
+
115
+ ## Software Integration
116
+
117
+ Our AI models are designed and/or optimized to run on NVIDIA GPU-accelerated systems. By leveraging NVIDIA’s hardware (e.g. GPU cores) and software frameworks (e.g., CUDA libraries), the model achieves faster training and inference times compared to CPU-only solutions.
118
+
119
+ **Runtime Engine(s):**
120
+ - Transformers (4.37.0+)
121
+ - vLLM
122
+ - TensorRT-LLM
123
+
124
+ **Supported Hardware Microarchitecture Compatibility:**
125
+ - NVIDIA Ampere
126
+ - NVIDIA Hopper
127
+ - NVIDIA Blackwell
128
+
129
+ **Operating System(s):**
130
+ - Linux
131
+
132
+ **Model version:** v1.0
133
+
134
+ ## Training Method
135
+
136
+ ![NFT Method](../assets/method_NFT.jpg)
137
+
138
+ The NFT training pipeline consists of three main components:
139
+
140
+ 1. **Data Collection:** The model generates answers to math questions, which are split into positive (correct) and negative (incorrect) datasets based on answer correctness.
141
+
142
+ 2. **Implicit Negative Policy:** NFT constructs an implicit negative policy to model negative answers, parameterized with the same positive policy targeted for optimization, enabling direct policy optimization on all generations.
143
+
144
+ 3. **Policy Optimization:** Both positive and negative answers are used to optimize the LLM policy via supervised learning with the NFT objective:
145
+
146
+ ```
147
+ L_NFT(θ) = r[-log(π_θ⁺(a|q) / π(a|q))] + (1-r)[-log((1 - r_q * (π_θ⁺(a|q) / π(a|q))) / (1-r_q))]
148
+ ```
149
+
150
+ ![Policy Distribution](../assets/distribution_NFT.jpg)
151
+
152
+ ## Training Datasets
153
+
154
+ **Dataset:** [DAPO-Math-17k](https://huggingface.co/datasets/BytedTsinghua-SIA/DAPO-Math-17k)
155
+
156
+ **Dataset Size:** 17k (math problems)
157
+
158
+ **Data Collection Method:** Automated
159
+
160
+ **Labeling Method by dataset**: Automated
161
+
162
+ The whole dataset is used for training. We directly evaluate the model on several other math evaluation datasets.
163
+
164
+ ## Evaluation Datasets
165
+
166
+ NFT-32B is evaluated on 6 mathematical reasoning benchmarks:
167
+ - **AIME 2024 (30 problems) & 2025 (30 problems):** American Invitational Mathematics Examination
168
+ - **AMC 2023 (40 problems):** American Mathematics Competitions
169
+ - **MATH500 (500 problems):** A subset of the MATH dataset
170
+ - **OlympiadBench (675 problems):** International Mathematical Olympiad problems
171
+ - **Minerva Math (272 problems):** Google's mathematical reasoning benchmark
172
+
173
+ **Data Collection Method:** Human
174
+
175
+ **Labeling Method by dataset**: Human
176
+
177
+ ## Performance
178
+
179
+ ![Performance Comparison](../assets/main_compare_NFT.jpg)
180
+
181
+ NFT-32B achieves state-of-the-art performance among supervised learning methods for mathematical reasoning:
182
+
183
+ | Benchmark | NFT-32B | Qwen2.5-32B | Improvement |
184
+ |-----------|---------|-------------|-------------|
185
+ | AIME24 (avg@32) | 37.8% | 4.1% | +33.7% |
186
+ | AIME25 (avg@32) | 31.5% | 1.0% | +30.5% |
187
+ | MATH500 | 88.4% | 68.6% | +19.8% |
188
+ | AMC23 (avg@32) | 93.8% | 45.0% | +48.8% |
189
+ | OlympiadBench | 55.0% | 31.1% | +23.9% |
190
+ | Minerva Math | 48.9% | 27.9% | +21.0% |
191
+ | **Average** | **59.2%** | **29.6%** | **+29.6%** |
192
+
193
+ Notably, NFT-32B performs similarly to DAPO (59.2% vs 59.9%) while using a simpler supervised learning approach.
194
+
195
+ ![Validation Curves](../assets/val_acc_curve_NFT.jpg)
196
+
197
+ ## Usage
198
+
199
+ > [!Important]
200
+ > **NFT-32B** is optimized for mathematical reasoning tasks. For best results, use clear mathematical prompts and request step-by-step reasoning.
201
+
202
+ The model can be used with the Hugging Face Transformers library:
203
+
204
+ ```python
205
+ from transformers import AutoModelForCausalLM, AutoTokenizer
206
+
207
+ model_name = "nvidia/NFT-32B"
208
+ device = "cuda" # the device to load the model onto
209
+
210
+ model = AutoModelForCausalLM.from_pretrained(
211
+ model_name,
212
+ torch_dtype="auto",
213
+ device_map="auto"
214
+ )
215
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
216
+
217
+ # Example math problem
218
+ problem = "Find the value of $x$ that satisfies the equation $\\sqrt{x+7} = x-5$."
219
+
220
+ # Format the prompt to encourage step-by-step reasoning
221
+ prompt = f"{problem}\nPlease reason step by step, and put your final answer within \\boxed{{}}."
222
+
223
+ messages = [
224
+ {"role": "user", "content": prompt}
225
+ ]
226
+
227
+ text = tokenizer.apply_chat_template(
228
+ messages,
229
+ tokenize=False,
230
+ add_generation_prompt=True
231
+ )
232
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
233
+
234
+ # Generate response
235
+ generated_ids = model.generate(
236
+ **model_inputs,
237
+ max_new_tokens=512,
238
+ temperature=0 # Use 0 for deterministic output
239
+ )
240
+ generated_ids = [
241
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
242
+ ]
243
+
244
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
245
+ print(response)
246
+ ```
247
+
248
+ ### Usage Recommendations
249
+
250
+ 1. **Temperature:** Use temperature=0 for deterministic outputs, or 0.1-0.3 for slight variation
251
+ 2. **Sampling:** For best results on competition problems, consider using multiple samples with majority voting
252
+ 3. **Format:** Include instructions for step-by-step reasoning directly in the user prompt
253
+ 4. **Final Answer:** Instruct the model to put the final answer in `\boxed{}`
254
+ 5. **Long Context:** This model supports up to 131K tokens context, making it suitable for complex multi-step problems
255
+ 6. **Language:** This model is primarily trained on English mathematical problems
256
+
257
+ ## Requirements
258
+
259
+ The code of Qwen2.5 has been integrated into Hugging Face `transformers`, and we recommend using the latest version:
260
+ - `transformers>=4.37.0`
261
+
262
+ ## Citation
263
+ If you find our project helpful, please consider citing
264
+ ```bibtex
265
+ @article{chen2025bridging,
266
+ title = {Bridging Supervised Learning and Reinforcement Learning in Math Reasoning},
267
+ author = {Huayu Chen, Kaiwen Zheng, Qinsheng Zhang, Ganqu Cui, Yin Cui, Haotian Ye, Tsung-Yi Lin, Ming-Yu Liu, Jun Zhu, Haoxiang Wang},
268
+ journal = {arXiv preprint arXiv:2505.18116},
269
+ year = {2025}
270
+ }
271
+ ```
272
+
273
+ ## Known Limitations
274
+
275
+ 1. **Domain Specificity:** This model is specifically trained for mathematical reasoning and may not perform well on general conversation or non-mathematical tasks
276
+ 2. **Calculation Errors:** While the model shows strong reasoning abilities, it may still make arithmetic errors in complex calculations
277
+ 3. **Context Understanding:** The model may struggle with problems requiring real-world context or domain knowledge outside mathematics
278
+ 4. **Resource Requirements:** The 32B model requires significant GPU memory for inference
279
+
280
+ ## Bias Considerations
281
+
282
+ The model is trained on mathematical problems which are inherently objective. However, the training data may reflect biases in problem selection, difficulty distribution, and mathematical notation preferences from the source datasets.
283
+
284
+ ## Inference:
285
+ - **Acceleration Engine:** TensorRT-LLM, vLLM, SGLang
286
+ - **Test Hardware:** NVIDIA H100
287
+
288
+ ## Ethical Considerations
289
+
290
+ NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
291
+
292
+ Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).