gabriellarson commited on
Commit
0379626
·
verified ·
1 Parent(s): b5e319c

Create README.md

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