Spaces:
Sleeping
Sleeping
Added chat template correction for Mistral
Browse files
app.py
CHANGED
|
@@ -9,6 +9,10 @@ checkpoint = "mistralai/Mistral-7B-Instruct-v0.2"
|
|
| 9 |
# Inference client with the model (And HF-token if needed)
|
| 10 |
client = InferenceClient(checkpoint)
|
| 11 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def format_prompt(message,chatbot,system_prompt):
|
| 14 |
messages = [{"role": "system","content": system_prompt}]
|
|
|
|
| 9 |
# Inference client with the model (And HF-token if needed)
|
| 10 |
client = InferenceClient(checkpoint)
|
| 11 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 12 |
+
# Tokenizer chat template correction(Only works for mistral models)
|
| 13 |
+
chat_template = open("mistral-instruct.jinja").read()
|
| 14 |
+
chat_template = chat_template.replace(' ', '').replace('\n', '')
|
| 15 |
+
tokenizer.chat_template = chat_template
|
| 16 |
|
| 17 |
def format_prompt(message,chatbot,system_prompt):
|
| 18 |
messages = [{"role": "system","content": system_prompt}]
|