File size: 10,991 Bytes
885bbb3 3498406 885bbb3 3e738a9 885bbb3 f5cb775 3e738a9 3ce561d 885bbb3 3498406 885bbb3 3498406 2819707 3498406 2819707 3e738a9 2819707 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 3e738a9 3498406 2819707 3e738a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
---
library_name: transformers
tags:
- DPO
license: apache-2.0
datasets:
- lightblue/response-dataset-plus-qwen-judged
language:
- ja
base_model:
- Qwen/Qwen2.5-7B-Instruct
---
[日本語モデルカード/Japanese model card](#japanese)
[日本語のブログ/Full Japanese dev blog](https://note.com/lightblue_tech/n/n6967ff462f4a?sub_rt=share_pb)
[Development source code/開発ソースコード](https://github.com/lightblue-tech/karasu_dpo_202501)
# Karasu-DPO-7B
This is a Japanese version of the [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) model which was DPO trained using synthetic Japanese conversation data.
This model outperforms the base [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) model on the [arena-hard-auto-multilingual](https://github.com/lightblue-tech/arena-hard-auto-multilingual) chat benchmark:
|Qwen2.5-7B-Instruct|Karasu-DPO-7B|
|----|----|
|50.0|66.2|
We recommend this model for use as a general conversation AI.
# How to use
This model can be used in the same way as any Qwen 2.5 model. We recommend using vLLM for simplicity and speed.
<ul>
<li><b>vLLM</b>
Install [vLLM](https://github.com/vllm-project/vllm/) using `pip install vllm`.
<details open>
<summary>Show vLLM code</summary>
```python
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.0,
max_tokens=8_000,
)
prompts = [
"""ナイジェリアの首都はどこですか?""",
"""鉄は何度に溶けますか?""",
"""父が好きそうなプレゼントのおすすめを教えて""",
]
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)
print("-"*32)
# ナイジェリアの首都はアブジャ(Abuja)です。以前はラゴスが首都でしたが、1991年に新しい首都としてアブジャが建設され、1991年12月12日に首都としての地位を正式に取得しました。アブジャは政治中心地として機能していますが、経済の中心地は依然としてラゴスが占めています。
# --------------------------------
# 鉄は非常に高い温度で溶けます。鉄の融点は約1,538℃(2,800°F)です。これは、一般的な家庭用のオーブン(最大約200-300℃)では絶対に達成できません。鉄を溶かすためには、より高温の設備が必要で、例えば、電気炉やガス炉などがあります。
# --------------------------------
# もちろんです。父さんへのプレゼント選びは楽しみですね。以下に、父が喜ぶ2つのプレゼントを提案します:
# 1. **高級コーヒーメーカー**:
# - 父さんがコーヒーを愛飲しているなら、高品質なコーヒーメーカーは大変喜ばれるプレゼントです。例えば、手動式のコーヒーメーカーなら、毎日のコーヒー作りがより楽しく、手作り感も楽しめます。また、自動式のコーヒーメーカーなら、忙しい朝でも美味しいコーヒーが楽しめます。
# 2. **趣味に合わせたギフトセット**:
# - 父さんの趣味や興味に合わせたギフトセットは、とても喜ばれます。例えば、ゴルフ好きなら、最新のゴルフクラブやゴルフバッグ、ゴルフボールセットなどが良いでしょう。また、車好きなら、高品質な車用アクセサリー(カーフィルム、カーボンシートなど)や車載用の充電器などが喜ばれます。
# これらのプレゼントは、父さんの趣味や興味に合わせて選べば、きっと喜んでもらえることでしょう。
# --------------------------------
```
</details>
<br/>
# How this model was made
We made this model through the following procedure:
1. Sample Japanese and English prompts from the following datasets:
* lmsys/lmsys-chat-1m
* RyokoAI/ShareGPT52K
* openchat/openchat_sharegpt_v3
* OpenAssistant/oasst2
* Open-Orca/slimorca-deduped-cleaned-corrected
* HuggingFaceH4/ultrachat_200k
2. Translate English prompts to Japanese using [gpt-4o-mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/).
3. Correct translations with [gpt-4o-mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/).
4. Get responses to all Japanese prompts (both original and translated) with [gpt-4o-mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/).
5. Correct responses using [gpt-4o-mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/).
We QLoRA DPO trained a [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) model on this data to create Karasu-DPO-7B.
<h1 style="font-size: 48px;" id="japanese">日本語</h3>
こちらのモデルは[Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct)の日本語版です。生成した日本語会話データとDPO学習で作成しました。
このモデルは、[arena-hard-auto-multilingual](https://github.com/lightblue-tech/arena-hard-auto-multilingual)チャットベンチマークにおいて、ベースモデルである[Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct)を上回る性能を発揮します:
|Qwen2.5-7B-Instruct|Karasu-DPO-7B|
|----|----|
|50.0|66.2|
このモデルは、一般的な会話AIとしての使用を推奨します。
# 使用方法
このモデルは、他のQwen 2.5モデルと同様の方法で使用できます。シンプルで高速な操作のためにはvLLMの使用を推奨します。
<ul>
<li><b>vLLM</b>
[vLLM](https://github.com/vllm-project/vllm/)を`pip install vllm`でインストールしてください。
<details open>
<summary>vLLMコードを見る</summary>
```python
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.0,
max_tokens=8_000,
)
prompts = [
"""ナイジェリアの首都はどこですか?""",
"""鉄は何度に溶けますか?""",
"""父が好きそうなプレゼントのおすすめを教えて""",
]
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)
print("-"*32)
# ナイジェリアの首都はアブジャ(Abuja)です。以前はラゴスが首都でしたが、1991年に新しい首都としてアブジャが建設され、1991年12月12日に首都としての地位を正式に取得しました。アブジャは政治中心地として機能していますが、経済の中心地は依然としてラゴスが占めています。
# --------------------------------
# 鉄は非常に高い温度で溶けます。鉄の融点は約1,538℃(2,800°F)です。これは、一般的な家庭用のオーブン(最大約200-300℃)では絶対に達成できません。鉄を溶かすためには、より高温の設備が必要で、例えば、電気炉やガス炉などがあります。
# --------------------------------
# もちろんです。父さんへのプレゼント選びは楽しみですね。以下に、父が喜ぶ2つのプレゼントを提案します:
# 1. **高級コーヒーメーカー**:
# - 父さんがコーヒーを愛飲しているなら、高品質なコーヒーメーカーは大変喜ばれるプレゼントです。例えば、手動式のコーヒーメーカーなら、毎日のコーヒー作りがより楽しく、手作り感も楽しめます。また、自動式のコーヒーメーカーなら、忙しい朝でも美味しいコーヒーが楽しめます。
# 2. **趣味に合わせたギフトセット**:
# - 父さんの趣味や興味に合わせたギフトセットは、とても喜ばれます。例えば、ゴルフ好きなら、最新のゴルフクラブやゴルフバッグ、ゴルフボールセットなどが良いでしょう。また、車好きなら、高品質な車用アクセサリー(カーフィルム、カーボンシートなど)や車載用の充電器などが喜ばれます。
# これらのプレゼントは、父さんの趣味や興味に合わせて選べば、きっと喜んでもらえることでしょう。
# --------------------------------
```
</details>
<br/>
# このモデルの作成方法
このモデルは以下の手順を通して作成されました:
1. 以下のデータセットから日本語および英語のプロンプトをサンプリング:
* lmsys/lmsys-chat-1m
* RyokoAI/ShareGPT52K
* openchat/openchat_sharegpt_v3
* OpenAssistant/oasst2
* Open-Orca/slimorca-deduped-cleaned-corrected
* HuggingFaceH4/ultrachat_200k
2. 英語のプロンプトを[gpt-4o-mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/)を使って日本語に翻訳。
3. [gpt-4o-mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/)を使って翻訳を修正。
4. 日本語のプロンプト(オリジナルと翻訳の両方)に対する応答を[gpt-4o-mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/)で取得。
5. [gpt-4o-mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/)を使用して応答を修正。
[Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct)モデルを基に、QLoRA DPOトレーニングを行い、Karasu-DPO-7Bを作成しました。
### Model Details
- Model size: 7B
- Context length: 1024
- Language: Japanese
#### Training Procudure
- learning_rate: 5e-6
- train_batch_size: 4
- eval_batch_size: 2
- gradient_accumulation_steps: 4
- lr_scheduler_type: cosine
#### Training Results
|**Step**|**Traning Loss**|**Validation Loss**|
|----|----|----|
|10|0.678400| 0.665870|
|20|0.608500| 0.638361|
|30|0.577300| 0.607468|
|40|0.526700| 0.559432|
|50|0.489200| 0.523419|
|60|0.502800| 0.511645|
|70|0.462300| 0.506989|
|80|0.419600| 0.509142|
|90|0.445200| 0.510396|
|100|0.424400| 0.511653|
# License
We share this model under an Apache 2.0 license.
# Developed by
<a href="https://www.lightblue-tech.com">
<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"/>
</a>
This model was trained by Jun Sashihara ([junsashihara](https://huggingface.co/junsashihara)) and supervised by Peter Devine ([ptrdvn](https://huggingface.co/ptrdvn)) for Lightblue。
|