Spaces:
Runtime error
Runtime error
Removed default system prompt
Browse files
app.py
CHANGED
|
@@ -34,25 +34,29 @@ examples=[
|
|
| 34 |
]
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Stream text
|
| 38 |
def predict(message, chatbot, system_prompt="", temperature=0.9, max_new_tokens=256, top_p=0.6, repetition_penalty=1.0,):
|
| 39 |
|
| 40 |
if system_prompt != "":
|
| 41 |
-
|
| 42 |
else:
|
| 43 |
-
|
| 44 |
|
| 45 |
temperature = float(temperature)
|
| 46 |
if temperature < 1e-2:
|
| 47 |
temperature = 1e-2
|
| 48 |
top_p = float(top_p)
|
| 49 |
|
| 50 |
-
input_prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n "
|
| 51 |
for interaction in chatbot:
|
| 52 |
-
input_prompt = input_prompt + str(interaction[0]) + " [/INST] " + str(interaction[1]) + " </s><s>
|
| 53 |
|
| 54 |
input_prompt = input_prompt + str(message) + " [/INST] "
|
| 55 |
-
|
| 56 |
data = {
|
| 57 |
"inputs": input_prompt,
|
| 58 |
"parameters": {
|
|
@@ -101,18 +105,17 @@ def predict(message, chatbot, system_prompt="", temperature=0.9, max_new_tokens=
|
|
| 101 |
def predict_batch(message, chatbot, system_prompt="", temperature=0.9, max_new_tokens=256, top_p=0.6, repetition_penalty=1.0,):
|
| 102 |
|
| 103 |
if system_prompt != "":
|
| 104 |
-
|
| 105 |
else:
|
| 106 |
-
|
| 107 |
|
| 108 |
temperature = float(temperature)
|
| 109 |
if temperature < 1e-2:
|
| 110 |
temperature = 1e-2
|
| 111 |
top_p = float(top_p)
|
| 112 |
|
| 113 |
-
input_prompt = f"[INST]<<SYS>>\n{system_message}\n<</SYS>>\n\n "
|
| 114 |
for interaction in chatbot:
|
| 115 |
-
input_prompt = input_prompt + str(interaction[0]) + " [/INST] " + str(interaction[1]) + " </s><s>
|
| 116 |
|
| 117 |
input_prompt = input_prompt + str(message) + " [/INST] "
|
| 118 |
|
|
@@ -225,4 +228,4 @@ with gr.Blocks() as demo:
|
|
| 225 |
chatbot_batch.like(vote, None, None)
|
| 226 |
chat_interface_batch.render()
|
| 227 |
|
| 228 |
-
demo.queue(concurrency_count=75, max_size=100).launch(debug=True)
|
|
|
|
| 34 |
]
|
| 35 |
|
| 36 |
|
| 37 |
+
# Note: We have removed default system prompt as requested by the paper authors [Dated: 13/Oct/2023]
|
| 38 |
+
# Prompting style for Llama2 without using system prompt
|
| 39 |
+
# <s>[INST] {{ user_msg_1 }} [/INST] {{ model_answer_1 }} </s><s>[INST] {{ user_msg_2 }} [/INST]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
# Stream text
|
| 43 |
def predict(message, chatbot, system_prompt="", temperature=0.9, max_new_tokens=256, top_p=0.6, repetition_penalty=1.0,):
|
| 44 |
|
| 45 |
if system_prompt != "":
|
| 46 |
+
input_prompt = f"<s>[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n "
|
| 47 |
else:
|
| 48 |
+
input_prompt = f"<s>[INST] "
|
| 49 |
|
| 50 |
temperature = float(temperature)
|
| 51 |
if temperature < 1e-2:
|
| 52 |
temperature = 1e-2
|
| 53 |
top_p = float(top_p)
|
| 54 |
|
|
|
|
| 55 |
for interaction in chatbot:
|
| 56 |
+
input_prompt = input_prompt + str(interaction[0]) + " [/INST] " + str(interaction[1]) + " </s><s>[INST] "
|
| 57 |
|
| 58 |
input_prompt = input_prompt + str(message) + " [/INST] "
|
| 59 |
+
|
| 60 |
data = {
|
| 61 |
"inputs": input_prompt,
|
| 62 |
"parameters": {
|
|
|
|
| 105 |
def predict_batch(message, chatbot, system_prompt="", temperature=0.9, max_new_tokens=256, top_p=0.6, repetition_penalty=1.0,):
|
| 106 |
|
| 107 |
if system_prompt != "":
|
| 108 |
+
input_prompt = f"<s>[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n "
|
| 109 |
else:
|
| 110 |
+
input_prompt = f"<s>[INST] "
|
| 111 |
|
| 112 |
temperature = float(temperature)
|
| 113 |
if temperature < 1e-2:
|
| 114 |
temperature = 1e-2
|
| 115 |
top_p = float(top_p)
|
| 116 |
|
|
|
|
| 117 |
for interaction in chatbot:
|
| 118 |
+
input_prompt = input_prompt + str(interaction[0]) + " [/INST] " + str(interaction[1]) + " </s><s>[INST] "
|
| 119 |
|
| 120 |
input_prompt = input_prompt + str(message) + " [/INST] "
|
| 121 |
|
|
|
|
| 228 |
chatbot_batch.like(vote, None, None)
|
| 229 |
chat_interface_batch.render()
|
| 230 |
|
| 231 |
+
demo.queue(concurrency_count=75, max_size=100).launch(debug=True)
|