commit 882ae982015674b943e7039207aefb0b8bf8f12b Author: ModelHub XC Date: Wed Jun 3 18:30:12 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: nv-community/NFT-7B Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3d8180b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,41 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +assets/algorithm_spectrum_NFT.jpg filter=lfs diff=lfs merge=lfs -text +assets/main_compare_NFT.jpg filter=lfs diff=lfs merge=lfs -text +assets/main_table.png filter=lfs diff=lfs merge=lfs -text +assets/method_NFT.jpg filter=lfs diff=lfs merge=lfs -text +assets/val_acc_curve_NFT.jpg filter=lfs diff=lfs merge=lfs -text +tokenizer.json filter=lfs diff=lfs merge=lfs -text diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f9b72c1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6dbfcc882a24c46e97b34bdf7de831d4cfbaf6103b354322f52a5ce609b2ebe +size 4092 diff --git a/README.md b/README.md new file mode 100644 index 0000000..1cb384a --- /dev/null +++ b/README.md @@ -0,0 +1,287 @@ +--- +datasets: +- BytedTsinghua-SIA/DAPO-Math-17k +language: +- en +base_model: +- Qwen/Qwen2.5-Math-7B +pipeline_tag: text-generation +license: other +license_name: nvidia-non-commercial-license +license_link: https://huggingface.co/nvidia/NFT-7B/blob/main/LICENSE +library_name: transformers +tags: +- nvidia +- math +- reasoning +- post-training +- qwen +--- + +# Negative-aware Fine-Tuning: Bridging Supervised Learning and Reinforcement Learning in Math Reasoning + +> [!Warning] +>
+> +> 🚨 NFT-7B is specifically designed for mathematical reasoning tasks. We do not recommend using this model for general conversation or non-mathematical tasks. +> +>
+ +**Tsinghua University, NVIDIA, Stanford University** + +[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) + +[[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)] + +![Algorithm Spectrum](./assets/algorithm_spectrum_NFT.jpg) + +## Model Overview + +### Description + +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. + +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. + +This model is for research and development only. + +### Model Developer + +NVIDIA, Tsinghua University, Stanford University + +### License + +[NVIDIA Non-Commercial License](https://huggingface.co/nvidia/NFT-7B/blob/main/LICENSE) + +This model is released under the NVIDIA Non-Commercial License. The model is for research and development only. + +### Deployment Geography + +Global + +### Release Date + +Huggingface 06/27/2025 + +- NFT-7B: https://huggingface.co/nvidia/NFT-7B/ +- NFT-32B: https://huggingface.co/nvidia/NFT-32B/ + +### Use Case + +Mathematical reasoning and problem-solving, including: +- Competition-level mathematics (AIME, AMC, Olympiad) +- General mathematical reasoning (MATH500, Minerva Math) +- Step-by-step mathematical solution generation + +## Model Architecture + +**Architecture Type:** Transformer decoder-only language model + +**Network Architecture:** Qwen2.5 + +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. + +## Input + +**Input Type(s):** Text + +**Input Format:** String + +**Input Parameters:** One-dimensional (1D) + +**Other Properties Related to Input:** +- Context length up to 32,768 tokens +- Mathematical problems should be clearly stated +- Supports LaTeX notation for mathematical expressions + +## Output + +**Output Type(s):** Text + +**Output Format:** String + +**Output Parameters:** One-dimensional (1D) + +**Other Properties Related to Output:** +- Step-by-step mathematical reasoning +- Final answers should be enclosed in `\boxed{}` +- Supports LaTeX notation for mathematical expressions +- Maximum generation length: 8,192 tokens + + +## Software Integration + +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. + +**Runtime Engine(s):** +- Transformers +- vLLM +- TensorRT-LLM + +**Supported Hardware Microarchitecture Compatibility:** +- NVIDIA Ampere +- NVIDIA Hopper +- NVIDIA Blackwell + +**Operating System(s):** +- Linux + +**Model version:** v1.0 + +## Training Method + +![NFT Method](./assets/method_NFT.jpg) + +The NFT training pipeline consists of three main components: + +1. **Data Collection:** The model generates answers to math questions, which are split into positive (correct) and negative (incorrect) datasets based on answer correctness. + +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. + +3. **Policy Optimization:** Both positive and negative answers are used to optimize the LLM policy via supervised learning with the NFT objective: + +``` +L_NFT(θ) = r[-log(π_θ⁺(a|q) / π(a|q))] + (1-r)[-log((1 - r_q * (π_θ⁺(a|q) / π(a|q))) / (1-r_q))] +``` + +![Policy Distribution](./assets/distribution_NFT.jpg) + +## Training Datasets + +**Dataset:** [DAPO-Math-17k](https://huggingface.co/datasets/BytedTsinghua-SIA/DAPO-Math-17k) + +**Dataset Size:** 17k (math problems) + +**Data Collection Method:** Automated + +**Labeling Method by dataset**: Automated + +The whole dataset is used for training. We directly evaluate the model on several other math evaluation datasets. + +## Evaluation Datasets + +NFT-7B is evaluated on 6 mathematical reasoning benchmarks: +- **AIME 2024 (30 problems) & 2025 (30 problems):** American Invitational Mathematics Examination +- **AMC 2023 (40 problems):** American Mathematics Competitions +- **MATH500 (500 problems):** A subset of the MATH dataset +- **OlympiadBench (675 problems):** International Mathematical Olympiad problems +- **Minerva Math (272 problems):** Google's mathematical reasoning benchmark + +**Data Collection Method:** Human + +**Labeling Method by dataset**: Human + +## Performance + +![Performance Comparison](./assets/main_compare_NFT.jpg) + +NFT-7B achieves competitive performance compared to other 7B math models, with particularly strong results on competition mathematics: + +| Benchmark | NFT-7B | Qwen2.5-Math-7B | Improvement | +|-----------|--------|-----------------|-------------| +| AIME24 (avg@32) | 32.0% | 13.3% | +18.7% | +| AIME25 (avg@32) | 18.3% | 5.5% | +12.8% | +| MATH500 | 83.2% | 69.0% | +14.2% | +| AMC23 (avg@32) | 88.5% | 45.8% | +42.7% | +| OlympiadBench | 47.3% | 34.7% | +12.6% | +| Minerva Math | 40.8% | 21.3% | +19.5% | +| **Average** | **51.7%** | **31.6%** | **+20.1%** | + +![Validation Curves](./assets/val_acc_curve_NFT.jpg) + + +## Usage + +> [!Important] +> **NFT-7B** is optimized for mathematical reasoning tasks. For best results, use clear mathematical prompts and request step-by-step reasoning. + +The model can be used with the Hugging Face Transformers library: + +```python +from transformers import AutoModelForCausalLM, AutoTokenizer + +model_name = "nvidia/NFT-7B" +device = "cuda" # the device to load the model onto + +model = AutoModelForCausalLM.from_pretrained( + model_name, + torch_dtype="auto", + device_map="auto" +) +tokenizer = AutoTokenizer.from_pretrained(model_name) + +# Example math problem +problem = "Find the value of $x$ that satisfies the equation $\\sqrt{x+7} = x-5$." + +# Format the prompt to encourage step-by-step reasoning +prompt = f"{problem}\nPlease reason step by step, and put your final answer within \\boxed{{}}." + +messages = [ + {"role": "user", "content": prompt} +] + +text = tokenizer.apply_chat_template( + messages, + tokenize=False, + add_generation_prompt=True +) +model_inputs = tokenizer([text], return_tensors="pt").to(device) + +# Generate response +generated_ids = model.generate( + **model_inputs, + max_new_tokens=512, + temperature=0 # Use 0 for deterministic output +) +generated_ids = [ + output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids) +] + +response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0] +print(response) +``` + +### Usage Recommendations + +1. **Temperature:** Use temperature=0 for deterministic outputs, or 0.1-0.3 for slight variation +2. **Sampling:** For best results on competition problems, consider using multiple samples with majority voting +3. **Format:** Include instructions for step-by-step reasoning directly in the user prompt +4. **Final Answer:** Instruct the model to put the final answer in `\boxed{}` +5. **Language:** This model is primarily trained on English mathematical problems + +## Requirements + +The code of Qwen2.5 has been integrated into Hugging Face `transformers`, and we recommend using the latest version: +- `transformers>=4.37.0` + + +## Citation +If you find our project helpful, please consider citing +```bibtex +@article{chen2025bridging, + title = {Bridging Supervised Learning and Reinforcement Learning in Math Reasoning}, + author = {Huayu Chen, Kaiwen Zheng, Qinsheng Zhang, Ganqu Cui, Yin Cui, Haotian Ye, Tsung-Yi Lin, Ming-Yu Liu, Jun Zhu, Haoxiang Wang}, + journal = {arXiv preprint arXiv:2505.18116}, + year = {2025} +} +``` + +## Known Limitations + +1. **Domain Specificity:** This model is specifically trained for mathematical reasoning and may not perform well on general conversation or non-mathematical tasks +2. **Calculation Errors:** While the model shows strong reasoning abilities, it may still make arithmetic errors in complex calculations +3. **Context Understanding:** The model may struggle with problems requiring real-world context or domain knowledge outside mathematics + +## Bias Considerations + +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. + +## Inference: +- **Acceleration Engine:** TensorRT-LLM, vLLM, SGLang +- **Test Hardware:** NVIDIA H100 + +## Ethical Considerations + +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. + +Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/). \ No newline at end of file diff --git a/added_tokens.json b/added_tokens.json new file mode 100644 index 0000000..482ced4 --- /dev/null +++ b/added_tokens.json @@ -0,0 +1,24 @@ +{ + "": 151658, + "": 151657, + "<|box_end|>": 151649, + "<|box_start|>": 151648, + "<|endoftext|>": 151643, + "<|file_sep|>": 151664, + "<|fim_middle|>": 151660, + "<|fim_pad|>": 151662, + "<|fim_prefix|>": 151659, + "<|fim_suffix|>": 151661, + "<|im_end|>": 151645, + "<|im_start|>": 151644, + "<|image_pad|>": 151655, + "<|object_ref_end|>": 151647, + "<|object_ref_start|>": 151646, + "<|quad_end|>": 151651, + "<|quad_start|>": 151650, + "<|repo_name|>": 151663, + "<|video_pad|>": 151656, + "<|vision_end|>": 151653, + "<|vision_pad|>": 151654, + "<|vision_start|>": 151652 +} diff --git a/assets/algorithm_spectrum_NFT.jpg b/assets/algorithm_spectrum_NFT.jpg new file mode 100644 index 0000000..910d547 --- /dev/null +++ b/assets/algorithm_spectrum_NFT.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6877b613a6a23d99c10db8d24831b113db154b33a53feb2c82c344efd140e1ac +size 127032 diff --git a/assets/distribution_NFT.jpg b/assets/distribution_NFT.jpg new file mode 100644 index 0000000..9f86f0c --- /dev/null +++ b/assets/distribution_NFT.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:755ab012fef851b2a3cfa953edb25b52f93737ded91d97908371b8a712730f83 +size 60614 diff --git a/assets/main_compare_NFT.jpg b/assets/main_compare_NFT.jpg new file mode 100644 index 0000000..e878c60 --- /dev/null +++ b/assets/main_compare_NFT.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6212363193d0add3f324a216f57d2333e119a8e896597b38d1c9510ff8b96e22 +size 120912 diff --git a/assets/main_table.png b/assets/main_table.png new file mode 100644 index 0000000..d0b7e34 --- /dev/null +++ b/assets/main_table.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed5a4ffc9f166f70b6699bf3ca73b1f975e19d997cba218db6e6459bd94508c3 +size 197424 diff --git a/assets/method_NFT.jpg b/assets/method_NFT.jpg new file mode 100644 index 0000000..f05063e --- /dev/null +++ b/assets/method_NFT.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14a1f05cb34cba31f8dca87f9586e4f07bca31bad67f79576afad6644ab16905 +size 118206 diff --git a/assets/note.txt b/assets/note.txt new file mode 100644 index 0000000..e69de29 diff --git a/assets/val_acc_curve_NFT.jpg b/assets/val_acc_curve_NFT.jpg new file mode 100644 index 0000000..ab5b163 --- /dev/null +++ b/assets/val_acc_curve_NFT.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c15ecd856ee25173c7452f6bb87c1f71df3e55a5bd2be1cb7312a509c5f2639 +size 137903 diff --git a/config.json b/config.json new file mode 100644 index 0000000..116b2a6 --- /dev/null +++ b/config.json @@ -0,0 +1,32 @@ +{ + "_name_or_path": "./NFT_7B/huggingface", + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "embd_pdrop": 0.0, + "eos_token_id": 151643, + "hidden_act": "silu", + "hidden_size": 3584, + "initializer_range": 0.02, + "intermediate_size": 18944, + "max_position_embeddings": 4096, + "max_window_layers": 28, + "model_type": "qwen2", + "num_attention_heads": 28, + "num_hidden_layers": 28, + "num_key_value_heads": 4, + "pad_token_id": 151643, + "resid_pdrop": 0.0, + "rms_norm_eps": 1e-06, + "rope_scaling": null, + "rope_theta": 10000, + "sliding_window": 4096, + "tie_word_embeddings": false, + "torch_dtype": "bfloat16", + "transformers_version": "4.49.0", + "use_cache": true, + "use_mrope": false, + "use_sliding_window": false, + "vocab_size": 152064 +} diff --git a/configuration.json b/configuration.json new file mode 100644 index 0000000..bbeeda1 --- /dev/null +++ b/configuration.json @@ -0,0 +1 @@ +{"framework": "pytorch", "task": "text-generation", "allow_remote": true} \ No newline at end of file diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..8529c18 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,6 @@ +{ + "_from_model_config": true, + "eos_token_id": 151643, + "pad_token_id": 151643, + "transformers_version": "4.49.0" +} diff --git a/merges.txt b/merges.txt new file mode 100644 index 0000000..80c1a19 --- /dev/null +++ b/merges.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8831e4f1a044471340f7c0a83d7bd71306a5b867e95fd870f74d0c5308a904d5 +size 1671853 diff --git a/model-00001-of-00004.safetensors b/model-00001-of-00004.safetensors new file mode 100644 index 0000000..4f69d02 --- /dev/null +++ b/model-00001-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b34c2ef721a6d6b4ba77e823d3860e17a9a68d1f662b19e9487df52062dfddf +size 4877660776 diff --git a/model-00002-of-00004.safetensors b/model-00002-of-00004.safetensors new file mode 100644 index 0000000..c991d26 --- /dev/null +++ b/model-00002-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:825a1f97ed37840cad726e8c2ca3426fffea77b77bd5ae069fe30534604d7d48 +size 4932751008 diff --git a/model-00003-of-00004.safetensors b/model-00003-of-00004.safetensors new file mode 100644 index 0000000..d2db796 --- /dev/null +++ b/model-00003-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:795b28ec3b666d93e2c67379f82d67f00d780813ce41df81a1ab7cf05b44d35b +size 4330865200 diff --git a/model-00004-of-00004.safetensors b/model-00004-of-00004.safetensors new file mode 100644 index 0000000..507c6d7 --- /dev/null +++ b/model-00004-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fead78ddd54a6eeff2b099fceb6cef2b8d4e1c3ed6e27d9898b89e1729ba5615 +size 1089994880 diff --git a/model.safetensors.index.json b/model.safetensors.index.json new file mode 100644 index 0000000..a358575 --- /dev/null +++ b/model.safetensors.index.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:998a078123ffc97763690de7f2a677eb89168af5eaf8a5e12e6bc24d18e25bdb +size 27752 diff --git a/special_tokens_map.json b/special_tokens_map.json new file mode 100644 index 0000000..17305b3 --- /dev/null +++ b/special_tokens_map.json @@ -0,0 +1,31 @@ +{ + "additional_special_tokens": [ + "<|im_start|>", + "<|im_end|>", + "<|object_ref_start|>", + "<|object_ref_end|>", + "<|box_start|>", + "<|box_end|>", + "<|quad_start|>", + "<|quad_end|>", + "<|vision_start|>", + "<|vision_end|>", + "<|vision_pad|>", + "<|image_pad|>", + "<|video_pad|>" + ], + "eos_token": { + "content": "<|endoftext|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "pad_token": { + "content": "<|endoftext|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + } +} diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..51ebb3b --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa +size 11421896 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..423dbe4 --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c90413caefc621f6fcfb8d9e5ce8ba9c949f5b65bcf8a4808f994fb9c51cf91 +size 7349 diff --git a/vocab.json b/vocab.json new file mode 100644 index 0000000..6c49fc6 --- /dev/null +++ b/vocab.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910 +size 2776833