Haoxiang-Wang commited on
Commit
28c4c99
·
verified ·
1 Parent(s): 0aae0ca

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +287 -5
README.md CHANGED
@@ -1,5 +1,287 @@
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-Math-7B
8
+ pipeline_tag: text-generation
9
+ license: other
10
+ license_name: nvidia-non-commercial-license
11
+ license_link: https://huggingface.co/nvidia/NFT-7B/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-7B 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-7B is a math reasoning model finetuned from [Qwen2.5-Math-7B](https://huggingface.co/Qwen/Qwen2.5-Math-7B) 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 model demonstrates that self-reflective improvement is not exclusive to RL methods—supervised learning can effectively leverage negative feedback for continuous improvement in mathematical reasoning tasks.
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-7B/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
81
+
82
+ NFT-7B is post-trained based on [Qwen2.5-Math-7B](https://huggingface.co/Qwen/Qwen2.5-Math-7B) and follows the same model architecture. The model has 7B parameters.
83
+
84
+ ## Input
85
+
86
+ **Input Type(s):** Text
87
+
88
+ **Input Format:** String
89
+
90
+ **Input Parameters:** One-dimensional (1D)
91
+
92
+ **Other Properties Related to Input:**
93
+ - Context length up to 32,768 tokens
94
+ - Mathematical problems should be clearly stated
95
+ - Supports LaTeX notation for mathematical expressions
96
+
97
+ ## Output
98
+
99
+ **Output Type(s):** Text
100
+
101
+ **Output Format:** String
102
+
103
+ **Output Parameters:** One-dimensional (1D)
104
+
105
+ **Other Properties Related to Output:**
106
+ - Step-by-step mathematical reasoning
107
+ - Final answers should be enclosed in `\boxed{}`
108
+ - Supports LaTeX notation for mathematical expressions
109
+ - Maximum generation length: 8,192 tokens
110
+
111
+
112
+ ## Software Integration
113
+
114
+ 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.
115
+
116
+ **Runtime Engine(s):**
117
+ - Transformers
118
+ - vLLM
119
+ - TensorRT-LLM
120
+
121
+ **Supported Hardware Microarchitecture Compatibility:**
122
+ - NVIDIA Ampere
123
+ - NVIDIA Hopper
124
+ - NVIDIA Blackwell
125
+
126
+ **Operating System(s):**
127
+ - Linux
128
+
129
+ **Model version:** v1.0
130
+
131
+ ## Training Method
132
+
133
+ ![NFT Method](./assets/method_NFT.jpg)
134
+
135
+ The NFT training pipeline consists of three main components:
136
+
137
+ 1. **Data Collection:** The model generates answers to math questions, which are split into positive (correct) and negative (incorrect) datasets based on answer correctness.
138
+
139
+ 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.
140
+
141
+ 3. **Policy Optimization:** Both positive and negative answers are used to optimize the LLM policy via supervised learning with the NFT objective:
142
+
143
+ ```
144
+ L_NFT(θ) = r[-log(π_θ⁺(a|q) / π(a|q))] + (1-r)[-log((1 - r_q * (π_θ⁺(a|q) / π(a|q))) / (1-r_q))]
145
+ ```
146
+
147
+ ![Policy Distribution](./assets/distribution_NFT.jpg)
148
+
149
+ ## Training Datasets
150
+
151
+ **Dataset:** [DAPO-Math-17k](https://huggingface.co/datasets/BytedTsinghua-SIA/DAPO-Math-17k)
152
+
153
+ **Dataset Size:** 17k (math problems)
154
+
155
+ **Data Collection Method:** Automated
156
+
157
+ **Labeling Method by dataset**: Automated
158
+
159
+ The whole dataset is used for training. We directly evaluate the model on several other math evaluation datasets.
160
+
161
+ ## Evaluation Datasets
162
+
163
+ NFT-7B is evaluated on 6 mathematical reasoning benchmarks:
164
+ - **AIME 2024 (30 problems) & 2025 (30 problems):** American Invitational Mathematics Examination
165
+ - **AMC 2023 (40 problems):** American Mathematics Competitions
166
+ - **MATH500 (500 problems):** A subset of the MATH dataset
167
+ - **OlympiadBench (675 problems):** International Mathematical Olympiad problems
168
+ - **Minerva Math (272 problems):** Google's mathematical reasoning benchmark
169
+
170
+ **Data Collection Method:** Human
171
+
172
+ **Labeling Method by dataset**: Human
173
+
174
+ ## Performance
175
+
176
+ ![Performance Comparison](./assets/main_compare_NFT.jpg)
177
+
178
+ NFT-7B achieves competitive performance compared to other 7B math models, with particularly strong results on competition mathematics:
179
+
180
+ | Benchmark | NFT-7B | Qwen2.5-Math-7B | Improvement |
181
+ |-----------|--------|-----------------|-------------|
182
+ | AIME24 (avg@32) | 32.0% | 13.3% | +18.7% |
183
+ | AIME25 (avg@32) | 18.3% | 5.5% | +12.8% |
184
+ | MATH500 | 83.2% | 69.0% | +14.2% |
185
+ | AMC23 (avg@32) | 88.5% | 45.8% | +42.7% |
186
+ | OlympiadBench | 47.3% | 34.7% | +12.6% |
187
+ | Minerva Math | 40.8% | 21.3% | +19.5% |
188
+ | **Average** | **51.7%** | **31.6%** | **+20.1%** |
189
+
190
+ ![Validation Curves](./assets/val_acc_curve_NFT.jpg)
191
+
192
+
193
+ ## Usage
194
+
195
+ > [!Important]
196
+ > **NFT-7B** is optimized for mathematical reasoning tasks. For best results, use clear mathematical prompts and request step-by-step reasoning.
197
+
198
+ The model can be used with the Hugging Face Transformers library:
199
+
200
+ ```python
201
+ from transformers import AutoModelForCausalLM, AutoTokenizer
202
+
203
+ model_name = "nvidia/NFT-7B"
204
+ device = "cuda" # the device to load the model onto
205
+
206
+ model = AutoModelForCausalLM.from_pretrained(
207
+ model_name,
208
+ torch_dtype="auto",
209
+ device_map="auto"
210
+ )
211
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
212
+
213
+ # Example math problem
214
+ problem = "Find the value of $x$ that satisfies the equation $\\sqrt{x+7} = x-5$."
215
+
216
+ # Format the prompt to encourage step-by-step reasoning
217
+ prompt = f"{problem}\nPlease reason step by step, and put your final answer within \\boxed{{}}."
218
+
219
+ messages = [
220
+ {"role": "user", "content": prompt}
221
+ ]
222
+
223
+ text = tokenizer.apply_chat_template(
224
+ messages,
225
+ tokenize=False,
226
+ add_generation_prompt=True
227
+ )
228
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
229
+
230
+ # Generate response
231
+ generated_ids = model.generate(
232
+ **model_inputs,
233
+ max_new_tokens=512,
234
+ temperature=0 # Use 0 for deterministic output
235
+ )
236
+ generated_ids = [
237
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
238
+ ]
239
+
240
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
241
+ print(response)
242
+ ```
243
+
244
+ ### Usage Recommendations
245
+
246
+ 1. **Temperature:** Use temperature=0 for deterministic outputs, or 0.1-0.3 for slight variation
247
+ 2. **Sampling:** For best results on competition problems, consider using multiple samples with majority voting
248
+ 3. **Format:** Include instructions for step-by-step reasoning directly in the user prompt
249
+ 4. **Final Answer:** Instruct the model to put the final answer in `\boxed{}`
250
+ 5. **Language:** This model is primarily trained on English mathematical problems
251
+
252
+ ## Requirements
253
+
254
+ The code of Qwen2.5 has been integrated into Hugging Face `transformers`, and we recommend using the latest version:
255
+ - `transformers>=4.37.0`
256
+
257
+
258
+ ## Citation
259
+ If you find our project helpful, please consider citing
260
+ ```bibtex
261
+ @article{chen2025bridging,
262
+ title = {Bridging Supervised Learning and Reinforcement Learning in Math Reasoning},
263
+ author = {Huayu Chen, Kaiwen Zheng, Qinsheng Zhang, Ganqu Cui, Yin Cui, Haotian Ye, Tsung-Yi Lin, Ming-Yu Liu, Jun Zhu, Haoxiang Wang},
264
+ journal = {arXiv preprint arXiv:2505.18116},
265
+ year = {2025}
266
+ }
267
+ ```
268
+
269
+ ## Known Limitations
270
+
271
+ 1. **Domain Specificity:** This model is specifically trained for mathematical reasoning and may not perform well on general conversation or non-mathematical tasks
272
+ 2. **Calculation Errors:** While the model shows strong reasoning abilities, it may still make arithmetic errors in complex calculations
273
+ 3. **Context Understanding:** The model may struggle with problems requiring real-world context or domain knowledge outside mathematics
274
+
275
+ ## Bias Considerations
276
+
277
+ 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.
278
+
279
+ ## Inference:
280
+ - **Acceleration Engine:** TensorRT-LLM, vLLM, SGLang
281
+ - **Test Hardware:** NVIDIA H100
282
+
283
+ ## Ethical Considerations
284
+
285
+ 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.
286
+
287
+ Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).