SunW7777 commited on
Commit
3bd8e30
Β·
verified Β·
1 Parent(s): d4f15c8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +182 -3
README.md CHANGED
@@ -1,3 +1,182 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ # KTAE: A Model-Free Algorithm to Key-Tokens Advantage Estimation in Mathematical Reasoning
6
+
7
+ <div align="center">
8
+ <br>
9
+ <a>Wei Sun</a>,
10
+ <a>Wen Yang</a>,
11
+ <a>Pu Jian</a>,
12
+
13
+ <a>Qianlong Du</a>,
14
+ <a>Fuwei Cui</a>,
15
+ <a>Shuo Ren</a>,
16
+ <a>Jiajun Zhang</a>
17
+ <br> Institute of Automation Chinese Academy of Sciences <br>
18
+
19
+ ![Mathematical-Reasoning](https://img.shields.io/badge/Task-Mathematical--Reasoning-red) ![Reinforcement-Learning](https://img.shields.io/badge/Method-Reinforcement--Learning-red) <a href='https://arxiv.org/abs/2505.16826'><img src='https://img.shields.io/badge/Paper-Arxiv-red'></a> <a href='https://github.com/xiaolizh1/KTAE'><img src='https://img.shields.io/badge/Project-Github-red'></a>
20
+ </div>
21
+
22
+ ## πŸ”– Overview
23
+ Recent advances have demonstrated that integrating reinforcement learning with rule-based rewards can significantly enhance the reasoning capabilities of large language models (LLMs), even without supervised fine-tuning (SFT). However, prevalent reinforcement learning algorithms such as GRPO and its variants like DAPO, suffer from a coarse granularity issue when computing the advantage. Specifically, they compute rollout-level advantages that assign identical values to every token within a sequence, failing to capture token-specific contributions. To address this limitation, we propose Key-token Advantage Estimation ($\textit{KTAE}$)β€”a novel algorithm that estimates fine-grained, token-level advantages without introducing additional models. KTAE leverages the correctness of sampled rollouts and applies statistical analysis to quantify the importance of individual tokens within a sequence to the final outcome. This quantified token-level importance is then combined with the rollout-level advantage to obtain a more fine-grained token-level advantage estimation. Empirical results show that models trained with GRPO+KTAE and DAPO+KTAE outperform baseline methods across five mathematical reasoning benchmarks. Notably, they achieve higher accuracy with shorter responses and even surpass R1-Distill-Qwen-1.5B using the same base model.
24
+
25
+ <p align="center">
26
+ <img src=https://cdn-uploads.huggingface.co/production/uploads/654a05493ee6a84ff2fd3fc1/-dygcr2iG28gI6jRh0KG1.png width="100%" height="100%">
27
+ </p>
28
+
29
+
30
+ In summary, the KTAE algorithm offers several advantages:
31
+
32
+ + KTAE provides more fine-grained advantage information without introducing extra models, resulting in lower training costs.
33
+
34
+ + KTAE directly computes the importance differences between tokens using statistical analysis methods, offering strong interpretability.
35
+
36
+ + KTAE's key-token value is computed based on the correctness of the final answer and retains the original rollout-level advantage, making it less susceptible to reward hacking.
37
+
38
+ + KTAE can make the model pay more attention to key tokens and reduce the learning of irrelevant tokens, which can effectively reduce the response length.
39
+
40
+ ## πŸ”₯ Update
41
+ - [21/05/2025]πŸ”₯Key-token Advantage Estimation is coming!
42
+
43
+ ## πŸ“ƒ Contents
44
+
45
+ - [Models](#Available_Models)
46
+ - [Setup](#Setup)
47
+ - [Preparation](#Preparation)
48
+ - [Train](#Train)
49
+ - [Inference](#Inference)
50
+ - [Experiments](#Experiments)
51
+ - [Citation](#citation)
52
+
53
+ ## 🧠 Available Models
54
+
55
+ | Model Size | DAPO+KTAE | GRPO+KTAE |
56
+ |------------|--------------|--------------|
57
+ | 1.5B | <a href="https://huggingface.co/SunW7777/DAPO_KTAE_1.5B"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="HF" width="20"/> DAPO_KTAE_1.5B</a> | <a href="https://huggingface.co/SunW7777/GRPO_KTAE_1.5B"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="HF" width="20"/> GRPO_KTAE_1.5B</a> |
58
+ | 7B | <a href="https://huggingface.co/SunW7777/DAPO_KTAE-7B"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="HF" width="20"/> DAPO_KTAE-7B</a> | <a href="https://huggingface.co/SunW7777/GRPO_KTAE-7B"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="HF" width="20"/> GRPO_KTAE-7B</a> |
59
+
60
+
61
+
62
+ ## πŸ“· Setup
63
+
64
+ Please follow the instructions below to install the required packages.
65
+
66
+
67
+ 1. Clone this repository
68
+
69
+ ```bash
70
+ https://github.com/xiaolizh1/KTAE.git
71
+ ```
72
+
73
+ 2. Install Package
74
+
75
+ ```bash
76
+ conda create -n KTAE python=3.10 -y
77
+ conda activate KTAE
78
+ cd KTAE
79
+ pip install -r requirements.txt
80
+ ```
81
+
82
+ ## πŸ“ˆ Train
83
+
84
+ Our training is mostly performed on [Verl](https://github.com/volcengine/verl) code base and makes some changes.
85
+
86
+ ## πŸ“Œ GRPO+KTAE
87
+
88
+ ```bash
89
+ bash examples/grpo_trainer/run_qwen2.5_7b.sh #train 7b model
90
+ bash examples/grpo_trainer/run_qwen2.5_math_1.5b.sh #train 1.5b model
91
+ ```
92
+
93
+ ## πŸ“Œ DAPO+KTAE
94
+
95
+ ```bash
96
+ bash recipe/dapo/run_dapo_qwen2.5_7b.sh #train 7b model
97
+ bash recipe/dapo/run_dapo_qwen2.5_1.5b.sh #train 1.5b model
98
+ ```
99
+
100
+ ## πŸ“Œ Merge Model
101
+
102
+ ```bash
103
+ cd scripts
104
+ bash merge_model.sh #merge checkpoint
105
+ ```
106
+
107
+ ## βœ… Evaluation
108
+
109
+ Our evaluate code is base on [Dr.GRPO](https://github.com/sail-sg/understand-r1-zero)
110
+
111
+ ```bash
112
+ cd eval
113
+ bash run_eval.sh
114
+ ```
115
+
116
+ ## πŸ‘€ Experiments
117
+
118
+ We provide some results in this section. More detailed results can be found in our paper.
119
+ <div align=center>
120
+ <img width="90%" src=https://cdn-uploads.huggingface.co/production/uploads/654a05493ee6a84ff2fd3fc1/exOLI0iPBFljL6x2ZOIFe.jpeg>
121
+ </div>
122
+
123
+ ### Main Results
124
+
125
+ + Method validation result.
126
+ <div align=center>
127
+ <img width="90%" src=https://cdn-uploads.huggingface.co/production/uploads/654a05493ee6a84ff2fd3fc1/kFJiRcr47hGylp29x9pqx.png>
128
+ </div>
129
+
130
+ + Comparison with baselines on Accuracy.
131
+ <div align=center>
132
+ <img width="90%" src=https://cdn-uploads.huggingface.co/production/uploads/654a05493ee6a84ff2fd3fc1/N5tKMS6w12ir0geF1oIgz.jpeg>
133
+ </div>
134
+
135
+ + Comparison with baselines on Efficiency.
136
+ <div align=center>
137
+ <img width="90%" src=https://cdn-uploads.huggingface.co/production/uploads/654a05493ee6a84ff2fd3fc1/nfypL2d3jS1GuH7mM_v9y.jpeg>
138
+ </div>
139
+
140
+
141
+ ### πŸ“Š More Analysis
142
+ + Ablation analysis.
143
+ <div align=center>
144
+ <img width="80%" src=https://cdn-uploads.huggingface.co/production/uploads/654a05493ee6a84ff2fd3fc1/Qphwk_uwp_uIJOTp4RAMw.png>
145
+ </div>
146
+
147
+ + Visualization example.
148
+ <div align=center>
149
+ <img width="80%" src=https://cdn-uploads.huggingface.co/production/uploads/654a05493ee6a84ff2fd3fc1/5aj7uS9uohvvLDoCyFSr0.png>
150
+ </div>
151
+
152
+
153
+ ## πŸ”— Citation
154
+
155
+ If you find this repo useful for your research, please consider citing the paper
156
+
157
+ ```
158
+ @misc{sun2025ktaemodelfreealgorithmkeytokens,
159
+ title={KTAE: A Model-Free Algorithm to Key-Tokens Advantage Estimation in Mathematical Reasoning},
160
+ author={Wei Sun and Wen Yang and Pu Jian and Qianlong Du and Fuwei Cui and Shuo Ren and Jiajun Zhang},
161
+ year={2025},
162
+ eprint={2505.16826},
163
+ archivePrefix={arXiv},
164
+ primaryClass={cs.AI},
165
+ url={https://arxiv.org/abs/2505.16826},
166
+ }
167
+ ```
168
+
169
+ ## 🌈 Acknowledgement
170
+
171
+ We would like to thank the following repos for their great work:
172
+
173
+ + [Verl](https://github.com/volcengine/verl) for providing the training framework
174
+ + [Vllm](https://github.com/vllm-project/vllm) for the efficient inference engine with high throughput
175
+ + [transformers](https://github.com/huggingface/transformers) for providing the model-base and fune-tuning framework
176
+
177
+
178
+ ## πŸ”Ž License
179
+
180
+ This project is released under the Apache 2.0 license. Parts of this project contain code and models from other sources, which are subject to their respective licenses.
181
+
182
+