mav23 commited on
Commit
49a97de
•
1 Parent(s): e794d0f

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +131 -0
  3. supercorrect-7b.Q4_0.gguf +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ supercorrect-7b.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ metrics:
6
+ - accuracy
7
+ base_model:
8
+ - Qwen/Qwen2.5-Math-7B-Instruct
9
+ library_name: transformers
10
+ ---
11
+ ## SuperCorrect: Supervising and Correcting Language Models with Error-Driven Insights
12
+
13
+ > [SuperCorrect: Supervising and Correcting Language Models with Error-Driven Insights](link)
14
+ > [Ling Yang\*](https://yangling0818.github.io/), [Zhaochen Yu*](https://github.com/BitCodingWalkin), [Tianjun Zhang](https://tianjunz.github.io/), [Minkai Xu](https://minkaixu.com/), [Joseph E. Gonzalez](https://people.eecs.berkeley.edu/~jegonzal/),[Bin Cui](https://cuibinpku.github.io/), [Shuicheng Yan](https://yanshuicheng.info/)
15
+ >
16
+ > Peking University, Skywork AI, UC Berkeley, Stanford University
17
+
18
+ <p align="left">
19
+ <a href='https://arxiv.org/abs/2410.09008'>
20
+ <img src='https://img.shields.io/badge/Arxiv-2410.09008-A42C25?style=flat&logo=arXiv&logoColor=A42C25'></a>
21
+ </p>
22
+
23
+ ## Introduction
24
+
25
+ ![image](intro.png)
26
+
27
+ This repo provides the official implementation of **SuperCorrect** a novel two-stage fine-tuning method for improving both reasoning accuracy and self-correction ability for LLMs.
28
+
29
+ Notably, our **SupperCorrect-7B** model significantly surpasses powerful **DeepSeekMath-7B by 7.8%/5.3% and Qwen2.5-Math-7B by 15.1%/6.3% on MATH/GSM8K benchmarks**, achieving new SOTA performance among all 7B models.
30
+
31
+ <div align="left">
32
+ 🚨 Unlike other LLMs, we incorporate LLMs with our pre-defined hierarchical thought template ([Buffer of Thought (BoT)](https://github.com/YangLing0818/buffer-of-thought-llm)) to conduct more deliberate reasoning than conventional CoT. It should be noted that our evaluation methods relies on pure mathematical reasoning abilities of LLMs, instead of leverage other programming methods such as PoT and ToRA.
33
+ </div>
34
+
35
+ ## Examples
36
+
37
+ ![image](example1.png)
38
+
39
+ <div align="left">
40
+ <b>
41
+ 🚨 For more concise and clear presentation, we omit some XML tags.
42
+ </b>
43
+ </div>
44
+
45
+ ### Model details
46
+ *You can check our [Github repo](https://github.com/YangLing0818/SuperCorrect-llm) for more details.*
47
+
48
+ ## Quick Start
49
+
50
+ ### Requirements
51
+
52
+ * Since our current model is based on Qwen2.5-Math series, `transformers>=4.37.0` is needed for Qwen2.5-Math models. The latest version is recommended.
53
+
54
+ > [!Warning]
55
+ >
56
+ > <div align="center">
57
+ > <b>
58
+ > 🚨 This is a must because `transformers` integrated Qwen2 codes since `4.37.0`.
59
+ > </b>
60
+ > </div>
61
+
62
+ ### Inference
63
+
64
+ #### 🤗 Hugging Face Transformers
65
+
66
+ ```python
67
+ from transformers import AutoModelForCausalLM, AutoTokenizer
68
+
69
+ model_name = "BitStarWalkin/SuperCorrect-7B"
70
+ device = "cuda"
71
+
72
+ model = AutoModelForCausalLM.from_pretrained(
73
+ model_name,
74
+ torch_dtype="auto",
75
+ device_map="auto"
76
+ )
77
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
78
+
79
+ prompt = "Find the distance between the foci of the ellipse \[9x^2 + \frac{y^2}{9} = 99.\]"
80
+ hierarchical_prompt = "Solve the following math problem in a step-by-step XML format, each step should be enclosed within tags like <Step1></Step1>. For each step enclosed within the tags, determine if this step is challenging and tricky, if so, add detailed explanation and analysis enclosed within <Key> </Key> in this step, as helpful annotations to help you thinking and remind yourself how to conduct reasoning correctly. After all the reasoning steps, summarize the common solution and reasoning steps to help you and your classmates who are not good at math generalize to similar problems within <Generalized></Generalized>. Finally present the final answer within <Answer> </Answer>."
81
+ # HT
82
+ messages = [
83
+ {"role": "system", "content":hierarchical_prompt },
84
+ {"role": "user", "content": prompt}
85
+ ]
86
+
87
+ text = tokenizer.apply_chat_template(
88
+ messages,
89
+ tokenize=False,
90
+ add_generation_prompt=True
91
+ )
92
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
93
+
94
+ generated_ids = model.generate(
95
+ **model_inputs,
96
+ max_new_tokens=1024
97
+ )
98
+ generated_ids = [
99
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
100
+ ]
101
+
102
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
103
+ print(response)
104
+ ```
105
+
106
+ ## Performance
107
+
108
+ We evaluate our SupperCorrect-7B on two widely used English math benchmarks GSM8K and MATH. All evaluations are tested with our evaluation method which is zero-shot hierarchical thought based prompting.
109
+
110
+ ![image](table.png)
111
+
112
+ ## Citation
113
+
114
+ ```bash
115
+ @article{yang2024supercorrect,
116
+ title={SuperCorrect: Supervising and Correcting Language Models with Error-Driven Insights}
117
+ author={Yang, Ling and Yu, Zhaochen and Zhang, Tianjun and Xu, Minkai and Gonzalez, Joseph E and Cui, Bin and Yan, Shuicheng},
118
+ journal={arXiv preprint arXiv:2410.09008},
119
+ year={2024}
120
+ }
121
+ @article{yang2024buffer,
122
+ title={Buffer of Thoughts: Thought-Augmented Reasoning with Large Language Models},
123
+ author={Yang, Ling and Yu, Zhaochen and Zhang, Tianjun and Cao, Shiyi and Xu, Minkai and Zhang, Wentao and Gonzalez, Joseph E and Cui, Bin},
124
+ journal={arXiv preprint arXiv:2406.04271},
125
+ year={2024}
126
+ }
127
+ ```
128
+
129
+ ## Acknowledgements
130
+
131
+ Our SuperCorrect is a two-stage fine-tuning model which based on several extraordinary open-source models like [Qwen2.5-Math](https://github.com/QwenLM/Qwen2.5-Math), [DeepSeek-Math](https://github.com/deepseek-ai/DeepSeek-Math), [Llama3-Series](https://github.com/meta-llama/llama3). Our evaluation method is based on the code base of outstanding works like [Qwen2.5-Math](https://github.com/QwenLM/Qwen2.5-Math) and [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness). We also want to express our gratitude for amazing works such as [BoT](https://github.com/YangLing0818/buffer-of-thought-llm) which provides the idea of thought template.
supercorrect-7b.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7510b2e01ebc1525f3116aefa10ff47fdcbbfc0fb6484d64c874ccbc9760df55
3
+ size 4431390944