🚀 lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese
Deepseek的R1模型是優秀的、最先進的推理模型,它們經過訓練可以同時處理英語和中文。然而,這些模型在輸出語言上並不一致,當使用日語進行提示時,它們常常會輸出中文或英語。因此,我們開發了lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese,作為R1模型的日語版本。
該模型是deepseek-ai/DeepSeek-R1-Distill-Qwen-7B在我們的lightblue/distilabel-reasoning-R1-Llama-70B數據集上進行日語微調的版本,它能夠可靠且準確地以日語響應提示。
此模型在阿里雲的8 x L20實例(ecs.gn8is-8x.32xlarge)上訓練了不到10分鐘。
🚀 快速開始
使用建議
當使用這些模型時,我們建議將採樣溫度設置在0.5 - 0.7之間,正如原始的蒸餾R1模型所建議的那樣。
此外,我們觀察到該模型有時比原始的R1模型更容易出現重複內容的情況。因此,如果模型在處理你的提示時出現重複內容,我們建議將repetition_penalty
設置為1.1或更高。
代碼示例
我們提供了在vLLM中使用此模型的腳本:
基礎用法
from vllm import LLM, SamplingParams
llm = LLM(
model="lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese",
max_model_len=8_000
)
sampling_params = SamplingParams(
temperature=0.5,
max_tokens=8_000,
repetition_penalty=1.1
)
prompts = [
"""學校には1クラスにつき20人の生徒がおり、クラスは合計3つあります。
學校全體では男子と女子がそれぞれ50%ずついます。
1つ目のクラスには女子が15人、2つ目のクラスには女子が12人います。
3つ目のクラスには何人の男子がいますか?"""
]
conversations = [
[{"role": "user", "content": x}] for x in prompts
]
outputs = llm.chat(conversations, sampling_params=sampling_params)
for output in outputs:
print(output.outputs[0].text)
<think>
...
...
📚 詳細文檔
評估
我們使用gsm8k-ja-test_250-1319數據集的前50行,對該模型的輸出準確性和有效日語<think>
部分的比例進行了評估。
我們將其與原始的R1模型進行了比較,並在重複懲罰係數分別為1.0和1.1的兩種情況下進行了測試:
模型名稱 |
重複懲罰係數 |
答案准確率(%) |
有效日語<think> 比例(%) |
deepseek-ai/DeepSeek-R1-Distill-Qwen-7B |
1.0 |
60 |
94 |
deepseek-ai/DeepSeek-R1-Distill-Qwen-7B |
1.1 |
62 |
96 |
lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese |
1.0 |
66 |
92 |
lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese |
1.1 |
70 |
98 |
SakanaAI/gsm8k-ja-test_250-1319評估的代碼可以在這裡找到。
我們進一步使用DeL-TaiseiOzaki/Tengentoppa-sft-reasoning-ja的前50個提示,評估了模型響應中有效日語<think>
部分的比例。這個基準測試包含了更多樣化和複雜的提示,這意味著它能更真實地評估該模型輸出日語的可靠性。
模型名稱 |
重複懲罰係數 |
有效日語<think> 比例(%) |
deepseek-ai/DeepSeek-R1-Distill-Qwen-7B |
1.0 |
48 |
deepseek-ai/DeepSeek-R1-Distill-Qwen-7B |
1.1 |
48 |
lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese |
1.0 |
84 |
lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese |
1.1 |
94 |
DeL-TaiseiOzaki/Tengentoppa-sft-reasoning-ja評估的代碼可以在這裡找到。
模型製作過程
我們通過以下步驟為該模型創建了數據:
- 從argilla/distilabel-reasoning-prompts中採樣英語推理風格的提示。
- 使用基於BAAI/bge-m3嵌入的文本相似度,去除相似的提示。
- 使用gpt-4o-mini-2024-07-18將英語提示翻譯成日語。
- 使用deepseek-ai/DeepSeek-R1-Distill-Llama-70B生成提示的答案。
- 過濾掉不滿足以下條件的響應:
- 在2048個標記內完成。
- 包含有效的
<think>
部分。
<think>
部分用日語書寫。
我們使用這些數據在LLaMA-Factory上通過監督微調訓練了我們的模型,使用的是ecs.gn8is-8x.32xlarge實例。
訓練詳情
完整訓練配置
訓練配置YAML文件
model_name_or_path: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
stage: sft
do_train: true
finetuning_type: full
deepspeed: /root/LLaMA-Factory/examples/deepspeed/ds_z2_config.json
dataset: distilabel-reasoning-R1-Llama-70B-ja-train
template: qwen
cutoff_len: 4500
overwrite_cache: true
preprocessing_num_workers: 16
packing: true
output_dir: /root/train_outputs/DeepSeek-R1-Distill-Qwen-7B/distilabel-reasoning-R1-Llama-70B-ja-train
logging_steps: 1
save_steps: 0.99999
plot_loss: true
overwrite_output_dir: true
per_device_train_batch_size: 1
gradient_accumulation_steps: 1
learning_rate: 1.0e-5
num_train_epochs: 1.0
lr_scheduler_type: cosine
warmup_ratio: 0.01
bf16: true
ddp_timeout: 180000000
val_size: 0.01
per_device_eval_batch_size: 1
eval_strategy: steps
eval_steps: 0.1
訓練運行腳本
echo '{
"distilabel-reasoning-R1-Llama-70B-ja-train": {
"hf_hub_url": "lightblue/distilabel-reasoning-R1-Llama-70B-ja-train",
"formatting": "sharegpt"
}
}' > /root/LLaMA-Factory/data/dataset_info.json
cd /root/LLaMA-Factory && llamafactory-cli train /root/reasoning_train.yaml
rm -r /root/train_outputs/DeepSeek-R1-Distill-Qwen-7B/distilabel-reasoning-R1-Llama-70B-ja-train/checkpoint*
huggingface-cli upload lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese /root/train_outputs/DeepSeek-R1-Distill-Qwen-7B/distilabel-reasoning-R1-Llama-70B-ja-train
訓練超參數
訓練期間使用了以下超參數:
- 學習率:1e-05
- 訓練批次大小:1
- 評估批次大小:1
- 隨機種子:42
- 分佈式類型:多GPU
- 設備數量:8
- 總訓練批次大小:8
- 總評估批次大小:8
- 優化器:使用adamw_torch,β1 = 0.9,β2 = 0.999,ε = 1e-08,無額外優化器參數
- 學習率調度器類型:餘弦
- 學習率預熱比例:0.01
- 訓練輪數:1.0
訓練結果
訓練損失 |
輪數 |
步數 |
驗證損失 |
0.766 |
0.1087 |
5 |
0.5912 |
0.5873 |
0.2174 |
10 |
0.5282 |
0.3868 |
0.3261 |
15 |
0.4958 |
0.5101 |
0.4348 |
20 |
0.4761 |
0.4085 |
0.5435 |
25 |
0.4644 |
0.5561 |
0.6522 |
30 |
0.4578 |
0.4683 |
0.7609 |
35 |
0.4542 |
0.5055 |
0.8696 |
40 |
0.4526 |
0.5359 |
0.9783 |
45 |
0.4519 |
框架版本
- Transformers 4.46.1
- Pytorch 2.5.1+cu124
- Datasets 3.1.0
- Tokenizers 0.20.3
📄 許可證
我們根據Apache 2.0許可證共享此模型。
開發者信息
該模型由Peter Devine(ptrdvn)為Lightblue訓練。