feat/tools-in-chat-template
#21
by
lcahill
- opened
- README.md +0 -1
- tokenizer_config.json +1 -1
README.md
CHANGED
|
@@ -123,7 +123,6 @@ If you want to use Hugging Face `transformers` to generate text, you can do some
|
|
| 123 |
from transformers import pipeline
|
| 124 |
|
| 125 |
messages = [
|
| 126 |
-
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
|
| 127 |
{"role": "user", "content": "Who are you?"},
|
| 128 |
]
|
| 129 |
chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3")
|
|
|
|
| 123 |
from transformers import pipeline
|
| 124 |
|
| 125 |
messages = [
|
|
|
|
| 126 |
{"role": "user", "content": "Who are you?"},
|
| 127 |
]
|
| 128 |
chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3")
|
tokenizer_config.json
CHANGED
|
@@ -6173,7 +6173,7 @@
|
|
| 6173 |
}
|
| 6174 |
},
|
| 6175 |
"bos_token": "<s>",
|
| 6176 |
-
"chat_template": "{{ bos_token }}{% for message in messages %}{% if
|
| 6177 |
"clean_up_tokenization_spaces": false,
|
| 6178 |
"eos_token": "</s>",
|
| 6179 |
"legacy": false,
|
|
|
|
| 6173 |
}
|
| 6174 |
},
|
| 6175 |
"bos_token": "<s>",
|
| 6176 |
+
"chat_template": "{{ bos_token }}{% for message in messages %}{% if loop.index0 == 0 and message['role'] not in ['available_tools', 'user'] %}{{ raise_exception('The first message must be either available_tools or user role!') }}{% endif %}{% if message['role'] not in ['user', 'assistant', 'available_tools', 'tool_call', 'tool_results'] %}{{ raise_exception('Only user, assistant, available_tools, tool_call, and tool_results roles are supported!') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + '[/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token }}{% elif message['role'] == 'available_tools' %}{{ '[AVAILABLE_TOOLS] ' + message['content'] + '[/AVAILABLE_TOOLS]' }}{% elif message['role'] == 'tool_call' %}{{ '[TOOL_CALLS]' + message['content'] + eos_token }}{% elif message['role'] == 'tool_results' %}{{ '[TOOL_RESULTS]' + message['content'] + '[/TOOL_RESULTS]' }}{% endif %}{% endfor %}",
|
| 6177 |
"clean_up_tokenization_spaces": false,
|
| 6178 |
"eos_token": "</s>",
|
| 6179 |
"legacy": false,
|