Commit
·
ef1e30c
1
Parent(s):
df75840
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,16 @@ import gradio as gr
|
|
| 3 |
|
| 4 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
def format_prompt(message, history):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
def generate(
|
| 15 |
prompt, history, temperature=0.2, max_new_tokens=512, top_p=0.95, repetition_penalty=1.0,
|
|
|
|
| 3 |
|
| 4 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 5 |
|
| 6 |
+
def tokenize(text):
|
| 7 |
+
return tok.encode(text, add_special_tokens=False)
|
| 8 |
+
|
| 9 |
def format_prompt(message, history):
|
| 10 |
+
prompt = ""
|
| 11 |
+
for user_prompt, bot_response in history:
|
| 12 |
+
prompt += "<s>" + tokenize("[INST]") + tokenize(user_prompt) + tokenize("[/INST]")
|
| 13 |
+
prompt += tokenize(bot_response) + "</s> "
|
| 14 |
+
prompt += tokenize("[INST]") + tokenize(message) + tokenize("[/INST]")
|
| 15 |
+
return prompt
|
| 16 |
|
| 17 |
def generate(
|
| 18 |
prompt, history, temperature=0.2, max_new_tokens=512, top_p=0.95, repetition_penalty=1.0,
|