Improve the chat prompt explanation and example
Browse files
README.md
CHANGED
@@ -61,11 +61,22 @@ Each message should be a dict with two keys:
|
|
61 |
|
62 |
For example:
|
63 |
```python
|
|
|
|
|
|
|
|
|
64 |
messages = [
|
65 |
{"role": "user", "content": "Solve for x: 3x=4"},
|
66 |
{"role": "assistant", "content": "3x=4\n(3x)/3=(4)/3\nx=4/3"},
|
67 |
{"role": "user", "content": "Please explain your work."},
|
68 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
```
|
70 |
|
71 |
See the example code in the included `chat_class.py` module for more details.
|
|
|
61 |
|
62 |
For example:
|
63 |
```python
|
64 |
+
from transformers import AutoTokenizer
|
65 |
+
|
66 |
+
tokenizer = AutoTokenizer.from_pretrained("mathewhe/DCLM-7B-Chat")
|
67 |
+
|
68 |
messages = [
|
69 |
{"role": "user", "content": "Solve for x: 3x=4"},
|
70 |
{"role": "assistant", "content": "3x=4\n(3x)/3=(4)/3\nx=4/3"},
|
71 |
{"role": "user", "content": "Please explain your work."},
|
72 |
]
|
73 |
+
print(tokenizer.apply_chat_template(messages, tokenize=False)
|
74 |
+
```
|
75 |
+
outputs
|
76 |
+
```
|
77 |
+
<|endoftext|>[INST] Solve for x: 3x=4 [/INST][ASST] 3x=4
|
78 |
+
(3x)/3=(4)/3
|
79 |
+
x=4/3 [/ASST]<|endoftext|><|endoftext|>[INST] Please explain your work [/INST]
|
80 |
```
|
81 |
|
82 |
See the example code in the included `chat_class.py` module for more details.
|