Update README.md
Browse files
README.md
CHANGED
|
@@ -194,8 +194,22 @@ repetition_penalty: 1.05
|
|
| 194 |
> [!WARNING]
|
| 195 |
> ⚠️ The model cannot work as intended without one of these two system prompts.
|
| 196 |
|
| 197 |
-
**
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
```
|
| 200 |
<|startoftext|><|im_start|>system
|
| 201 |
Translate to Japanese.<|im_end|>
|
|
@@ -341,14 +355,28 @@ repetition_penalty: 1.05
|
|
| 341 |
> [!WARNING]
|
| 342 |
> ⚠️ これらのシステムプロンプトがなければモデルは意図通りに動作しません。
|
| 343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
例:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
```
|
| 346 |
<|startoftext|><|im_start|>system
|
| 347 |
-
Translate to
|
| 348 |
<|im_start|>user
|
| 349 |
-
C. elegansとは何ですか?<|im_end|>
|
| 350 |
-
<|im_start|>assistant
|
| 351 |
What is C. elegans?<|im_end|>
|
|
|
|
|
|
|
| 352 |
```
|
| 353 |
|
| 354 |
> [!WARNING]
|
|
|
|
| 194 |
> [!WARNING]
|
| 195 |
> ⚠️ The model cannot work as intended without one of these two system prompts.
|
| 196 |
|
| 197 |
+
**Chat Template**
|
| 198 |
|
| 199 |
+
The chat template can be applied using the dedicated [`.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating#applychattemplate) function from Hugging Face transformers.
|
| 200 |
+
However, you must supply the system prompt that specifies the translation directionality.
|
| 201 |
+
|
| 202 |
+
E.g.
|
| 203 |
+
```python
|
| 204 |
+
chat = [
|
| 205 |
+
{"role": "system", "content": "Translate to Japanese."},
|
| 206 |
+
{"role": "user", "content": "What is C. elegans?"}
|
| 207 |
+
]
|
| 208 |
+
|
| 209 |
+
tokenizer.apply_chat_template(chat, tokenize=False)
|
| 210 |
+
```
|
| 211 |
+
|
| 212 |
+
With the model response:
|
| 213 |
```
|
| 214 |
<|startoftext|><|im_start|>system
|
| 215 |
Translate to Japanese.<|im_end|>
|
|
|
|
| 355 |
> [!WARNING]
|
| 356 |
> ⚠️ これらのシステムプロンプトがなければモデルは意図通りに動作しません。
|
| 357 |
|
| 358 |
+
**チャットテンプレート**
|
| 359 |
+
|
| 360 |
+
チャットテンプレートは、Hugging Face Transformers の専用関数 [`.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating#applychattemplate) を使用して適用できます。
|
| 361 |
+
ただし、翻訳方向を指定するシステムプロンプトを与える必要があります。
|
| 362 |
+
|
| 363 |
例:
|
| 364 |
+
```python
|
| 365 |
+
chat = [
|
| 366 |
+
{"role": "system", "content": "Translate to Japanese."},
|
| 367 |
+
{"role": "user", "content": "What is C. elegans?"}
|
| 368 |
+
]
|
| 369 |
+
|
| 370 |
+
tokenizer.apply_chat_template(chat, tokenize=False)
|
| 371 |
+
```
|
| 372 |
+
モデルからの出力例:
|
| 373 |
```
|
| 374 |
<|startoftext|><|im_start|>system
|
| 375 |
+
Translate to Japanese.<|im_end|>
|
| 376 |
<|im_start|>user
|
|
|
|
|
|
|
| 377 |
What is C. elegans?<|im_end|>
|
| 378 |
+
<|im_start|>assistant
|
| 379 |
+
C. elegansとは何ですか?<|im_end|>
|
| 380 |
```
|
| 381 |
|
| 382 |
> [!WARNING]
|