shimmyshimmer lbourdois commited on
Commit
bdd4041
·
verified ·
1 Parent(s): 83ad4a8

Improve language tag (#1)

Browse files

- Improve language tag (4ab977b86118b8c09641a29c2c63d245265e3baf)


Co-authored-by: Loïck BOURDOIS <[email protected]>

Files changed (1) hide show
  1. README.md +174 -162
README.md CHANGED
@@ -1,163 +1,175 @@
1
- ---
2
- base_model: Qwen/Qwen2.5-7B-Instruct
3
- language:
4
- - en
5
- library_name: transformers
6
- license: apache-2.0
7
- tags:
8
- - unsloth
9
- - transformers
10
- - qwen
11
- - qwen2
12
- ---
13
-
14
- # Finetune Llama 3.1, Gemma 2, Mistral 2-5x faster with 70% less memory via Unsloth!
15
-
16
- We have a Qwen 2.5 (all model sizes) [free Google Colab Tesla T4 notebook](https://colab.research.google.com/drive/1Kose-ucXO1IBaZq5BvbwWieuubP7hxvQ?usp=sharing).
17
- Also a [Qwen 2.5 conversational style notebook](https://colab.research.google.com/drive/1qN1CEalC70EO1wGKhNxs1go1W9So61R5?usp=sharing).
18
-
19
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/Discord%20button.png" width="200"/>](https://discord.gg/unsloth)
20
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
21
-
22
- ## ✨ Finetune for Free
23
-
24
- All notebooks are **beginner friendly**! Add your dataset, click "Run All", and you'll get a 2x faster finetuned model which can be exported to GGUF, vLLM or uploaded to Hugging Face.
25
-
26
- | Unsloth supports | Free Notebooks | Performance | Memory use |
27
- |-----------------|--------------------------------------------------------------------------------------------------------------------------|-------------|----------|
28
- | **Llama-3.2 (3B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Ys44kVvmeZtnICzWz0xgpRnrIOjZAuxp?usp=sharing) | 2.4x faster | 58% less |
29
- | **Llama-3.2 (11B vision)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1j0N4XTY1zXXy7mPAhOC1_gMYZ2F2EBlk?usp=sharing) | 2x faster | 60% less |
30
- | **Llama-3.1 (8B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Ys44kVvmeZtnICzWz0xgpRnrIOjZAuxp?usp=sharing) | 2.4x faster | 58% less |
31
- | **Qwen2 VL (7B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1whHb54GNZMrNxIsi2wm2EY_-Pvo2QyKh?usp=sharing) | 1.8x faster | 60% less |
32
- | **Qwen2.5 (7B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Kose-ucXO1IBaZq5BvbwWieuubP7hxvQ?usp=sharing) | 2x faster | 60% less |
33
- | **Phi-3.5 (mini)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1lN6hPQveB_mHSnTOYifygFcrO8C1bxq4?usp=sharing) | 2x faster | 50% less |
34
- | **Gemma 2 (9B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1vIrqH5uYDQwsJ4-OO3DErvuv4pBgVwk4?usp=sharing) | 2.4x faster | 58% less |
35
- | **Mistral (7B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Dyauq4kTZoLewQ1cApceUQVNcnnNTzg_?usp=sharing) | 2.2x faster | 62% less |
36
- | **DPO - Zephyr** | [▶️ Start on Colab](https://colab.research.google.com/drive/15vttTpzzVXv_tJwEk-hIcQ0S9FcEWvwP?usp=sharing) | 1.9x faster | 19% less |
37
-
38
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="200"/>](https://docs.unsloth.ai)
39
-
40
- - This [conversational notebook](https://colab.research.google.com/drive/1Aau3lgPzeZKQ-98h69CCu1UJcvIBLmy2?usp=sharing) is useful for ShareGPT ChatML / Vicuna templates.
41
- - This [text completion notebook](https://colab.research.google.com/drive/1ef-tab5bhkvWmBOObepl1WgJvfvSzn5Q?usp=sharing) is for raw text. This [DPO notebook](https://colab.research.google.com/drive/15vttTpzzVXv_tJwEk-hIcQ0S9FcEWvwP?usp=sharing) replicates Zephyr.
42
- - \* Kaggle has 2x T4s, but we use 1. Due to overhead, 1x T4 is 5x faster.
43
-
44
- # Qwen2.5-7B-Instruct
45
-
46
- ## Introduction
47
-
48
- Qwen2.5 is the latest series of Qwen large language models. For Qwen2.5, we release a number of base language models and instruction-tuned language models ranging from 0.5 to 72 billion parameters. Qwen2.5 brings the following improvements upon Qwen2:
49
-
50
- - Significantly **more knowledge** and has greatly improved capabilities in **coding** and **mathematics**, thanks to our specialized expert models in these domains.
51
- - Significant improvements in **instruction following**, **generating long texts** (over 8K tokens), **understanding structured data** (e.g, tables), and **generating structured outputs** especially JSON. **More resilient to the diversity of system prompts**, enhancing role-play implementation and condition-setting for chatbots.
52
- - **Long-context Support** up to 128K tokens and can generate up to 8K tokens.
53
- - **Multilingual support** for over 29 languages, including Chinese, English, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Vietnamese, Thai, Arabic, and more.
54
-
55
- **This repo contains the instruction-tuned 7B Qwen2.5 model**, which has the following features:
56
- - Type: Causal Language Models
57
- - Training Stage: Pretraining & Post-training
58
- - Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
59
- - Number of Parameters: 7.61B
60
- - Number of Paramaters (Non-Embedding): 6.53B
61
- - Number of Layers: 28
62
- - Number of Attention Heads (GQA): 28 for Q and 4 for KV
63
- - Context Length: Full 131,072 tokens and generation 8192 tokens
64
- - Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
65
-
66
- For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2.5/), [GitHub](https://github.com/QwenLM/Qwen2.5), and [Documentation](https://qwen.readthedocs.io/en/latest/).
67
-
68
- ## Requirements
69
-
70
- The code of Qwen2.5 has been in the latest Hugging face `transformers` and we advise you to use the latest version of `transformers`.
71
-
72
- With `transformers<4.37.0`, you will encounter the following error:
73
- ```
74
- KeyError: 'qwen2'
75
- ```
76
-
77
- ## Quickstart
78
-
79
- Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
80
-
81
- ```python
82
- from transformers import AutoModelForCausalLM, AutoTokenizer
83
-
84
- model_name = "Qwen/Qwen2.5-7B-Instruct"
85
-
86
- model = AutoModelForCausalLM.from_pretrained(
87
- model_name,
88
- torch_dtype="auto",
89
- device_map="auto"
90
- )
91
- tokenizer = AutoTokenizer.from_pretrained(model_name)
92
-
93
- prompt = "Give me a short introduction to large language model."
94
- messages = [
95
- {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
96
- {"role": "user", "content": prompt}
97
- ]
98
- text = tokenizer.apply_chat_template(
99
- messages,
100
- tokenize=False,
101
- add_generation_prompt=True
102
- )
103
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
104
-
105
- generated_ids = model.generate(
106
- **model_inputs,
107
- max_new_tokens=512
108
- )
109
- generated_ids = [
110
- output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
111
- ]
112
-
113
- response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
114
- ```
115
-
116
- ### Processing Long Texts
117
-
118
- The current `config.json` is set for context length up to 32,768 tokens.
119
- To handle extensive inputs exceeding 32,768 tokens, we utilize [YaRN](https://arxiv.org/abs/2309.00071), a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
120
-
121
- For supported frameworks, you could add the following to `config.json` to enable YaRN:
122
- ```json
123
- {
124
- ...,
125
- "rope_scaling": {
126
- "factor": 4.0,
127
- "original_max_position_embeddings": 32768,
128
- "type": "yarn"
129
- }
130
- }
131
- ```
132
-
133
- For deployment, we recommend using vLLM.
134
- Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
135
- Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
136
- We advise adding the `rope_scaling` configuration only when processing long contexts is required.
137
-
138
- ## Evaluation & Performance
139
-
140
- Detailed evaluation results are reported in this [📑 blog](https://qwenlm.github.io/blog/qwen2.5/).
141
-
142
- For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
143
-
144
- ## Citation
145
-
146
- If you find our work helpful, feel free to give us a cite.
147
-
148
- ```
149
- @misc{qwen2.5,
150
- title = {Qwen2.5: A Party of Foundation Models},
151
- url = {https://qwenlm.github.io/blog/qwen2.5/},
152
- author = {Qwen Team},
153
- month = {September},
154
- year = {2024}
155
- }
156
-
157
- @article{qwen2,
158
- title={Qwen2 Technical Report},
159
- author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
160
- journal={arXiv preprint arXiv:2407.10671},
161
- year={2024}
162
- }
 
 
 
 
 
 
 
 
 
 
 
 
163
  ```
 
1
+ ---
2
+ base_model: Qwen/Qwen2.5-7B-Instruct
3
+ language:
4
+ - zho
5
+ - eng
6
+ - fra
7
+ - spa
8
+ - por
9
+ - deu
10
+ - ita
11
+ - rus
12
+ - jpn
13
+ - kor
14
+ - vie
15
+ - tha
16
+ - ara
17
+ library_name: transformers
18
+ license: apache-2.0
19
+ tags:
20
+ - unsloth
21
+ - transformers
22
+ - qwen
23
+ - qwen2
24
+ ---
25
+
26
+ # Finetune Llama 3.1, Gemma 2, Mistral 2-5x faster with 70% less memory via Unsloth!
27
+
28
+ We have a Qwen 2.5 (all model sizes) [free Google Colab Tesla T4 notebook](https://colab.research.google.com/drive/1Kose-ucXO1IBaZq5BvbwWieuubP7hxvQ?usp=sharing).
29
+ Also a [Qwen 2.5 conversational style notebook](https://colab.research.google.com/drive/1qN1CEalC70EO1wGKhNxs1go1W9So61R5?usp=sharing).
30
+
31
+ [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/Discord%20button.png" width="200"/>](https://discord.gg/unsloth)
32
+ [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
33
+
34
+ ## Finetune for Free
35
+
36
+ All notebooks are **beginner friendly**! Add your dataset, click "Run All", and you'll get a 2x faster finetuned model which can be exported to GGUF, vLLM or uploaded to Hugging Face.
37
+
38
+ | Unsloth supports | Free Notebooks | Performance | Memory use |
39
+ |-----------------|--------------------------------------------------------------------------------------------------------------------------|-------------|----------|
40
+ | **Llama-3.2 (3B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Ys44kVvmeZtnICzWz0xgpRnrIOjZAuxp?usp=sharing) | 2.4x faster | 58% less |
41
+ | **Llama-3.2 (11B vision)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1j0N4XTY1zXXy7mPAhOC1_gMYZ2F2EBlk?usp=sharing) | 2x faster | 60% less |
42
+ | **Llama-3.1 (8B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Ys44kVvmeZtnICzWz0xgpRnrIOjZAuxp?usp=sharing) | 2.4x faster | 58% less |
43
+ | **Qwen2 VL (7B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1whHb54GNZMrNxIsi2wm2EY_-Pvo2QyKh?usp=sharing) | 1.8x faster | 60% less |
44
+ | **Qwen2.5 (7B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Kose-ucXO1IBaZq5BvbwWieuubP7hxvQ?usp=sharing) | 2x faster | 60% less |
45
+ | **Phi-3.5 (mini)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1lN6hPQveB_mHSnTOYifygFcrO8C1bxq4?usp=sharing) | 2x faster | 50% less |
46
+ | **Gemma 2 (9B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1vIrqH5uYDQwsJ4-OO3DErvuv4pBgVwk4?usp=sharing) | 2.4x faster | 58% less |
47
+ | **Mistral (7B)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Dyauq4kTZoLewQ1cApceUQVNcnnNTzg_?usp=sharing) | 2.2x faster | 62% less |
48
+ | **DPO - Zephyr** | [▶️ Start on Colab](https://colab.research.google.com/drive/15vttTpzzVXv_tJwEk-hIcQ0S9FcEWvwP?usp=sharing) | 1.9x faster | 19% less |
49
+
50
+ [<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="200"/>](https://docs.unsloth.ai)
51
+
52
+ - This [conversational notebook](https://colab.research.google.com/drive/1Aau3lgPzeZKQ-98h69CCu1UJcvIBLmy2?usp=sharing) is useful for ShareGPT ChatML / Vicuna templates.
53
+ - This [text completion notebook](https://colab.research.google.com/drive/1ef-tab5bhkvWmBOObepl1WgJvfvSzn5Q?usp=sharing) is for raw text. This [DPO notebook](https://colab.research.google.com/drive/15vttTpzzVXv_tJwEk-hIcQ0S9FcEWvwP?usp=sharing) replicates Zephyr.
54
+ - \* Kaggle has 2x T4s, but we use 1. Due to overhead, 1x T4 is 5x faster.
55
+
56
+ # Qwen2.5-7B-Instruct
57
+
58
+ ## Introduction
59
+
60
+ Qwen2.5 is the latest series of Qwen large language models. For Qwen2.5, we release a number of base language models and instruction-tuned language models ranging from 0.5 to 72 billion parameters. Qwen2.5 brings the following improvements upon Qwen2:
61
+
62
+ - Significantly **more knowledge** and has greatly improved capabilities in **coding** and **mathematics**, thanks to our specialized expert models in these domains.
63
+ - Significant improvements in **instruction following**, **generating long texts** (over 8K tokens), **understanding structured data** (e.g, tables), and **generating structured outputs** especially JSON. **More resilient to the diversity of system prompts**, enhancing role-play implementation and condition-setting for chatbots.
64
+ - **Long-context Support** up to 128K tokens and can generate up to 8K tokens.
65
+ - **Multilingual support** for over 29 languages, including Chinese, English, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Vietnamese, Thai, Arabic, and more.
66
+
67
+ **This repo contains the instruction-tuned 7B Qwen2.5 model**, which has the following features:
68
+ - Type: Causal Language Models
69
+ - Training Stage: Pretraining & Post-training
70
+ - Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
71
+ - Number of Parameters: 7.61B
72
+ - Number of Paramaters (Non-Embedding): 6.53B
73
+ - Number of Layers: 28
74
+ - Number of Attention Heads (GQA): 28 for Q and 4 for KV
75
+ - Context Length: Full 131,072 tokens and generation 8192 tokens
76
+ - Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
77
+
78
+ For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2.5/), [GitHub](https://github.com/QwenLM/Qwen2.5), and [Documentation](https://qwen.readthedocs.io/en/latest/).
79
+
80
+ ## Requirements
81
+
82
+ The code of Qwen2.5 has been in the latest Hugging face `transformers` and we advise you to use the latest version of `transformers`.
83
+
84
+ With `transformers<4.37.0`, you will encounter the following error:
85
+ ```
86
+ KeyError: 'qwen2'
87
+ ```
88
+
89
+ ## Quickstart
90
+
91
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
92
+
93
+ ```python
94
+ from transformers import AutoModelForCausalLM, AutoTokenizer
95
+
96
+ model_name = "Qwen/Qwen2.5-7B-Instruct"
97
+
98
+ model = AutoModelForCausalLM.from_pretrained(
99
+ model_name,
100
+ torch_dtype="auto",
101
+ device_map="auto"
102
+ )
103
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
104
+
105
+ prompt = "Give me a short introduction to large language model."
106
+ messages = [
107
+ {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
108
+ {"role": "user", "content": prompt}
109
+ ]
110
+ text = tokenizer.apply_chat_template(
111
+ messages,
112
+ tokenize=False,
113
+ add_generation_prompt=True
114
+ )
115
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
116
+
117
+ generated_ids = model.generate(
118
+ **model_inputs,
119
+ max_new_tokens=512
120
+ )
121
+ generated_ids = [
122
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
123
+ ]
124
+
125
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
126
+ ```
127
+
128
+ ### Processing Long Texts
129
+
130
+ The current `config.json` is set for context length up to 32,768 tokens.
131
+ To handle extensive inputs exceeding 32,768 tokens, we utilize [YaRN](https://arxiv.org/abs/2309.00071), a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
132
+
133
+ For supported frameworks, you could add the following to `config.json` to enable YaRN:
134
+ ```json
135
+ {
136
+ ...,
137
+ "rope_scaling": {
138
+ "factor": 4.0,
139
+ "original_max_position_embeddings": 32768,
140
+ "type": "yarn"
141
+ }
142
+ }
143
+ ```
144
+
145
+ For deployment, we recommend using vLLM.
146
+ Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
147
+ Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
148
+ We advise adding the `rope_scaling` configuration only when processing long contexts is required.
149
+
150
+ ## Evaluation & Performance
151
+
152
+ Detailed evaluation results are reported in this [📑 blog](https://qwenlm.github.io/blog/qwen2.5/).
153
+
154
+ For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
155
+
156
+ ## Citation
157
+
158
+ If you find our work helpful, feel free to give us a cite.
159
+
160
+ ```
161
+ @misc{qwen2.5,
162
+ title = {Qwen2.5: A Party of Foundation Models},
163
+ url = {https://qwenlm.github.io/blog/qwen2.5/},
164
+ author = {Qwen Team},
165
+ month = {September},
166
+ year = {2024}
167
+ }
168
+
169
+ @article{qwen2,
170
+ title={Qwen2 Technical Report},
171
+ author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
172
+ journal={arXiv preprint arXiv:2407.10671},
173
+ year={2024}
174
+ }
175
  ```