Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
license:
|
4 |
base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
|
5 |
tags:
|
6 |
- llama-factory
|
@@ -9,32 +9,259 @@ tags:
|
|
9 |
model-index:
|
10 |
- name: distilabel-reasoning-R1-Llama-70B-ja-train
|
11 |
results: []
|
|
|
|
|
|
|
|
|
12 |
---
|
13 |
|
14 |
-
|
15 |
-
should probably proofread and complete it, then remove this comment. -->
|
16 |
|
17 |
-
#
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
-
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
|
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
### model
|
39 |
model_name_or_path: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
|
40 |
|
@@ -76,6 +303,8 @@ eval_strategy: steps
|
|
76 |
eval_steps: 0.1
|
77 |
```
|
78 |
|
|
|
|
|
79 |
```shell
|
80 |
echo '{
|
81 |
"distilabel-reasoning-R1-Llama-70B-ja-train": {
|
@@ -127,3 +356,18 @@ The following hyperparameters were used during training:
|
|
127 |
- Pytorch 2.5.1+cu124
|
128 |
- Datasets 3.1.0
|
129 |
- Tokenizers 0.20.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
license: apache-2.0
|
4 |
base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
|
5 |
tags:
|
6 |
- llama-factory
|
|
|
9 |
model-index:
|
10 |
- name: distilabel-reasoning-R1-Llama-70B-ja-train
|
11 |
results: []
|
12 |
+
datasets:
|
13 |
+
- lightblue/distilabel-reasoning-R1-Llama-70B
|
14 |
+
language:
|
15 |
+
- ja
|
16 |
---
|
17 |
|
18 |
+
[日本語はこちら](#japanese)
|
|
|
19 |
|
20 |
+
# lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese
|
21 |
|
22 |
+
[Deepseek's R1 models](https://huggingface.co/collections/deepseek-ai/deepseek-r1-678e1e131c0169c0bc89728d) are excellent, state-of-the-art reasoning models which have been trained to work bilingually, with English and Chinese.
|
23 |
+
However, these models are inconsistent in the language that they produce - often outputting Chinese or English when prompted in Japanese.
|
24 |
+
For this reason, we developed [lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese](https://huggingface.co/lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese) as a Japanese version of R1.
|
25 |
|
26 |
+
This model is a Japanese fine-tuned version of [deepseek-ai/DeepSeek-R1-Distill-Qwen-7B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B) on our [lightblue/distilabel-reasoning-R1-Llama-70B](https://huggingface.co/datasets/lightblue/distilabel-reasoning-R1-Llama-70B) dataset.
|
27 |
|
28 |
+
This model was trained was trained for \<10 minutes on the 8 x L20 instance ([ecs.gn8is-8x.32xlarge](https://www.alibabacloud.com/help/en/ecs/user-guide/gpu-accelerated-compute-optimized-and-vgpu-accelerated-instance-families-1)) on [Alibaba Cloud](https://www.alibabacloud.com/).
|
29 |
|
30 |
+
# How to use
|
31 |
|
32 |
+
When using these models, we recommend using a sampling temperature of between 0.5-0.7, [as per the original distilled R1 models](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B#usage-recommendations).
|
33 |
|
34 |
+
Additionally, we have observed that the model sometimes tends to repeat itself more than the original R1 model, so we also recommend setting `repetition_penalty` to 1.1, or higher if the model repeats itself when processing your prompts.
|
35 |
|
36 |
+
We include scripts to use this model in vLLM:
|
37 |
|
38 |
+
<ul>
|
39 |
+
<li><b>vLLM</b>
|
40 |
|
41 |
+
Install [vLLM](https://github.com/vllm-project/vllm/) using `pip install vllm`.
|
42 |
+
|
43 |
+
<details open>
|
44 |
+
<summary>Show vLLM code</summary>
|
45 |
+
|
46 |
+
```python
|
47 |
+
from vllm import LLM, SamplingParams
|
48 |
+
|
49 |
+
llm = LLM(
|
50 |
+
model="lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese",
|
51 |
+
max_model_len=8_000
|
52 |
+
)
|
53 |
+
|
54 |
+
sampling_params = SamplingParams(
|
55 |
+
temperature=0.5,
|
56 |
+
max_tokens=8_000,
|
57 |
+
repetition_penalty=1.1
|
58 |
+
)
|
59 |
+
|
60 |
+
prompts = [
|
61 |
+
"""学校には1クラスにつき20人の生徒がおり、クラスは合計3つあります。
|
62 |
+
学校全体では男子と女子がそれぞれ50%ずついます。
|
63 |
+
1つ目のクラスには女子が15人、2つ目のクラスには女子が12人います。
|
64 |
+
3つ目のクラスには何人の男子がいますか?"""
|
65 |
+
]
|
66 |
+
|
67 |
+
conversations = [
|
68 |
+
[{"role": "user", "content": x}] for x in prompts
|
69 |
+
]
|
70 |
+
|
71 |
+
outputs = llm.chat(conversations, sampling_params=sampling_params)
|
72 |
+
|
73 |
+
for output in outputs:
|
74 |
+
print(output.outputs[0].text)
|
75 |
+
|
76 |
+
<think>
|
77 |
+
# まず、学校の総生徒数を算出します。各クラスに20人の生徒があり、クラスは3つあるため、総生徒数は60人です。
|
78 |
+
|
79 |
+
# 次に、学校全体で男子と女子は同じ人数で分布しています。したがって、男子と女子各有30人。
|
80 |
+
...
|
81 |
+
# したがって、3つ目のクラスの男子数は20 - 3 = 17人です。
|
82 |
+
# </think>
|
83 |
+
|
84 |
+
# **解答:**
|
85 |
+
|
86 |
+
# 学校の総生徒数を算出します。
|
87 |
+
...
|
88 |
+
# **最終的な答え:**
|
89 |
+
# \[
|
90 |
+
# \boxed{17}
|
91 |
+
# \]
|
92 |
+
```
|
93 |
+
|
94 |
+
</details></li>
|
95 |
+
</ul>
|
96 |
+
|
97 |
+
# Evaluation
|
98 |
+
|
99 |
+
We evaluated this model for output accuracy and the percentage of valid Japanese `<think>` sections using the first 50 rows of the (SakanaAI/gsm8k-ja-test_250-1319)[https://huggingface.co/datasets/SakanaAI/gsm8k-ja-test_250-1319] dataset.
|
100 |
+
|
101 |
+
We compare this to the original R1 model and test in both regimes where repetition penalty is 1.0 and 1.1:
|
102 |
+
|
103 |
+
| | Repetition Penalty | Answer accuracy (%) | Valid Japanese `<think>` (%) |
|
104 |
+
|------------------------------------------------|--------------------|---------------------|----------------------------|
|
105 |
+
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | 1.0 | 60 | 94 |
|
106 |
+
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | 1.1 | 62 | 96 |
|
107 |
+
| lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese | 1.0 | 66 | 92 |
|
108 |
+
| lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese | 1.1 | 70 | 98 |
|
109 |
+
|
110 |
+
Code for the SakanaAI/gsm8k-ja-test_250-1319 evaluation can be found [here](https://drive.google.com/file/d/1gCzCJv5vasw8R3KVQimfoIDFyfxwxNvC/view?usp=sharing):
|
111 |
+
|
112 |
+
|
113 |
+
We further use the first 50 prompts from (DeL-TaiseiOzaki/Tengentoppa-sft-reasoning-ja)[https://huggingface.co/datasets/DeL-TaiseiOzaki/Tengentoppa-sft-reasoning-ja] to evaluate the percentage of valid Japanese `\<think\>` sections in model responses.
|
114 |
+
This benchmark contains more varied and complex prompts, meaning this is a more realistic evaluation of how reliably this model can output Japanese.
|
115 |
+
|
116 |
+
| | Repetition Penalty | Valid Japanese `<think>` (%) |
|
117 |
+
|------------------------------------------------|--------------------|----------------------------|
|
118 |
+
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | 1.0 | 48 |
|
119 |
+
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | 1.1 | 48 |
|
120 |
+
| lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese | 1.0 | 84 |
|
121 |
+
| lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese | 1.1 | 94 |
|
122 |
+
|
123 |
+
Code for the DeL-TaiseiOzaki/Tengentoppa-sft-reasoning-ja evaluation can be found [here](https://drive.google.com/file/d/1f75IM5x1SZrb300odkEsLMfKsfibrxvR/view?usp=sharing):
|
124 |
+
|
125 |
+
# How this model was made
|
126 |
+
|
127 |
+
We made the data for this model using the following steps:
|
128 |
+
|
129 |
+
1. Sample English reasoning-style prompts from [argilla/distilabel-reasoning-prompts](https://huggingface.co/datasets/argilla/distilabel-reasoning-prompts).
|
130 |
+
2. Remove similar prompts using text similarity based on [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3) embeddings.
|
131 |
+
3. Translate English prompts to Japanese using [gpt-4o-mini-2024-07-18](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/).
|
132 |
+
4. Generate answers to prompts using [deepseek-ai/DeepSeek-R1-Distill-Llama-70B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-70B).
|
133 |
+
5. Filter out responses which did not:
|
134 |
+
* Finish within 2048 tokens
|
135 |
+
* Contain a valid `\<think\>` section
|
136 |
+
* Have the `\<think\>` section written in Japanese
|
137 |
+
|
138 |
+
We used this data to train our model using supervised fine tuning on [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory) with the [ecs.gn8is-8x.32xlarge](https://www.alibabacloud.com/help/en/ecs/user-guide/gpu-accelerated-compute-optimized-and-vgpu-accelerated-instance-families-1) instance.
|
139 |
+
|
140 |
+
|
141 |
+
<br/>
|
142 |
+
<br/>
|
143 |
+
<h1 style="font-size: 48px;" id="japanese">日本語</h3>
|
144 |
+
|
145 |
+
[DeepseekのR1モデル](https://huggingface.co/collections/deepseek-ai/deepseek-r1-678e1e131c0169c0bc89728d)は優れた、最先端の推論モデルであり、英語と中国語のバイリンガルで動作するように訓練されています。しかし、これらのモデルは出力される言語が一貫していないことがあり、日本語でプロンプトを与えると中国語や英語を出力することがあります。そこで、我々はR1の日本語版として[lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese](https://huggingface.co/lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese)を開発しました。
|
146 |
+
|
147 |
+
このモデルは、我々の[lightblue/distilabel-reasoning-R1-Llama-70B](https://huggingface.co/datasets/lightblue/distilabel-reasoning-R1-Llama-70B) データセットを使用して、[deepseek-ai/DeepSeek-R1-Distill-Qwen-7B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B)の日本語版として微調整されています。
|
148 |
+
|
149 |
+
このモデルは、[Alibaba Cloud](https://www.alibabacloud.com/)の8 x L20インスタンス([ecs.gn8is-8x.32xlarge](https://www.alibabacloud.com/help/en/ecs/user-guide/gpu-accelerated-compute-optimized-and-vgpu-accelerated-instance-families-1))で\<10分間訓練されました。
|
150 |
+
|
151 |
+
# 使用方法
|
152 |
+
|
153 |
+
これらのモデルを使用する際は、元の蒸留R1モデルで推奨されているように、サンプリング温度を0.5から0.7の間で使用することをお勧めします。
|
154 |
+
|
155 |
+
また、モデルが元のR1モデルよりも繰り返しがちな傾向があるため、プロンプトを処理する際にモデルが自分を繰り返す場合は、`repetition_penalty`を1.1またはそれ以上に設定することをお勧めします。
|
156 |
+
|
157 |
+
このモデルをvLLMで使用するためのスクリプトを含めています:
|
158 |
+
|
159 |
+
<ul>
|
160 |
+
<li><b>vLLM</b>
|
161 |
+
|
162 |
+
[vLLM](https://github.com/vllm-project/vllm/)をインストールするには、 `pip install vllm`を使用します。
|
163 |
+
|
164 |
+
<details open>
|
165 |
+
<summary>vLLMコードを表示</summary>
|
166 |
+
|
167 |
+
```python
|
168 |
+
from vllm import LLM, SamplingParams
|
169 |
+
|
170 |
+
llm = LLM(
|
171 |
+
model="lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese",
|
172 |
+
max_model_len=8_000
|
173 |
+
)
|
174 |
+
|
175 |
+
sampling_params = SamplingParams(
|
176 |
+
temperature=0.5,
|
177 |
+
max_tokens=8_000,
|
178 |
+
repetition_penalty=1.1
|
179 |
+
)
|
180 |
+
|
181 |
+
prompts = [
|
182 |
+
"""学校には1クラスにつき20人の生徒がおり、クラスは合計3つあります。
|
183 |
+
学校全体では男子と女子がそれぞれ50%ずついます。
|
184 |
+
1つ目のクラスには女子が15人、2つ目のクラスには女子が12人います。
|
185 |
+
3つ目のクラスには何人の男子がいますか?"""
|
186 |
+
]
|
187 |
+
|
188 |
+
conversations = [
|
189 |
+
[{"role": "user", "content": x}] for x in prompts
|
190 |
+
]
|
191 |
+
|
192 |
+
outputs = llm.chat(conversations, sampling_params=sampling_params)
|
193 |
+
|
194 |
+
for output in outputs:
|
195 |
+
print(output.outputs[0].text)
|
196 |
+
|
197 |
+
<think>
|
198 |
+
# まず、学校の総生徒数を算出します。各クラスに20人の生徒があり、クラスは3つあるため、総生徒数は60人です。
|
199 |
+
|
200 |
+
# 次に、学校全体で男子と女子は同じ人数で分布しています。したがって、男子と女子各有30人。
|
201 |
+
...
|
202 |
+
# したがって、3つ目のクラスの男子数は20 - 3 = 17人です。
|
203 |
+
# </think>
|
204 |
+
|
205 |
+
# **解答:**
|
206 |
+
|
207 |
+
# 学校の総生徒数を算出します。
|
208 |
+
...
|
209 |
+
# **最終的な答え:**
|
210 |
+
# \[
|
211 |
+
# \boxed{17}
|
212 |
+
# \]
|
213 |
+
```
|
214 |
+
|
215 |
+
</details></li>
|
216 |
+
</ul>
|
217 |
+
|
218 |
+
# 評価
|
219 |
+
|
220 |
+
このモデルは、(SakanaAI/gsm8k-ja-test_250-1319)[https://huggingface.co/datasets/SakanaAI/gsm8k-ja-test_250-1319]データセットの最初の50行を使用して、出力の正確性と有効な日本語の`<think>`セクションの割合を評価しました。
|
221 |
+
|
222 |
+
これは元のR1モデルと比較し、繰り返しペナルティが1.0と1.1の両方の条件でテストを行いました:
|
223 |
+
|
224 |
+
| | Repetition Penalty | Answer accuracy (%) | Valid Japanese `<think>` (%) |
|
225 |
+
|------------------------------------------------|--------------------|---------------------|----------------------------|
|
226 |
+
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | 1.0 | 60 | 94 |
|
227 |
+
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | 1.1 | 62 | 96 |
|
228 |
+
| lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese | 1.0 | 66 | 92 |
|
229 |
+
| lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese | 1.1 | 70 | 98 |
|
230 |
+
|
231 |
+
SakanaAI/gsm8k-ja-test_250-1319の評価コードは[こちら](https://drive.google.com/file/d/1gCzCJv5vasw8R3KVQimfoIDFyfxwxNvC/view?usp=sharing)にあります:
|
232 |
+
|
233 |
+
さらに、(DeL-TaiseiOzaki/Tengentoppa-sft-reasoning-ja)[https://huggingface.co/datasets/DeL-TaiseiOzaki/Tengentoppa-sft-reasoning-ja]の最初の50プロンプトを使用して、モデル応答における有効な日本語の`<think>`セクションの割合を評価します。このベンチマークにはより多様で複雑なプロンプトが含まれており、モデルが日本語を信頼性高く出力できるかどうかを、より現実的に評価します。
|
234 |
+
|
235 |
+
| | Repetition Penalty | Valid Japanese `<think>` (%) |
|
236 |
+
|------------------------------------------------|--------------------|----------------------------|
|
237 |
+
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | 1.0 | 48 |
|
238 |
+
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | 1.1 | 48 |
|
239 |
+
| lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese | 1.0 | 84 |
|
240 |
+
| lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese | 1.1 | 94 |
|
241 |
+
|
242 |
+
DeL-TaiseiOzaki/Tengentoppa-sft-reasoning-ja評価コードは[こちら](https://drive.google.com/file/d/1f75IM5x1SZrb300odkEsLMfKsfibrxvR/view?usp=sharing)にあります:
|
243 |
+
|
244 |
+
# 作成方法
|
245 |
+
|
246 |
+
このモデルのデータは以下の手順で作成されました:
|
247 |
+
|
248 |
+
1. [argilla/distilabel-reasoning-prompts](https://huggingface.co/datasets/argilla/distilabel-reasoning-prompts)から英語の推論スタイルのプロンプトをサンプルします。
|
249 |
+
2. [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3)埋め込みに基づくテキスト類似度を使用して、類似したプロンプトを削除します。
|
250 |
+
3. [gpt-4o-mini-2024-07-18](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/)を使用して、英語のプロンプトを日本語に翻訳します。
|
251 |
+
4. [deepseek-ai/DeepSeek-R1-Distill-Llama-70B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-70B)を使用して、プロンプトに対する回答を生成します。
|
252 |
+
5. 以下の条件を満たさない応答をフィルタリングします:
|
253 |
+
* 2048トークン以内に終了すること
|
254 |
+
* 有効な`<think>`セクションを含んでいること
|
255 |
+
* `<think>`セクションが日本語で書かれていること
|
256 |
+
|
257 |
+
|
258 |
+
# Training details
|
259 |
+
<details>
|
260 |
+
<summary>Full training config</summary>
|
261 |
+
|
262 |
+
### Training config yaml
|
263 |
+
|
264 |
+
```yaml
|
265 |
### model
|
266 |
model_name_or_path: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
|
267 |
|
|
|
303 |
eval_steps: 0.1
|
304 |
```
|
305 |
|
306 |
+
### Training run script
|
307 |
+
|
308 |
```shell
|
309 |
echo '{
|
310 |
"distilabel-reasoning-R1-Llama-70B-ja-train": {
|
|
|
356 |
- Pytorch 2.5.1+cu124
|
357 |
- Datasets 3.1.0
|
358 |
- Tokenizers 0.20.3
|
359 |
+
</details>
|
360 |
+
|
361 |
+
<br/>
|
362 |
+
|
363 |
+
# License
|
364 |
+
|
365 |
+
We share this model under an Apache 2.0 license.
|
366 |
+
|
367 |
+
# Developed by
|
368 |
+
|
369 |
+
<a href="https://www.lightblue-tech.com">
|
370 |
+
<img src="https://www.lightblue-tech.com/wp-content/uploads/2023/08/color_%E6%A8%AA%E5%9E%8B-1536x469.png" alt="Lightblue technology logo" width="400"/>
|
371 |
+
</a>
|
372 |
+
|
373 |
+
This model was trained by Peter Devine ([ptrdvn](https://huggingface.co/ptrdvn)) for Lightblue
|