Spaces:
Runtime error
Runtime error
fix Mixtral's system prompt
Browse files
run.py
CHANGED
@@ -150,27 +150,25 @@ else:
|
|
150 |
#------------
|
151 |
|
152 |
def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=None, zeichenlimit=None,historylimit=4): #float("Inf")
|
|
|
153 |
if zeichenlimit is None: zeichenlimit=1000000000 # :-)
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
template2=" {response}</s> " # Variante: Antworten folgen unmittelbar, enden ohne Leerzeichen vor </s>
|
158 |
-
if("discolm_german_7b" in modelPath): #https://huggingface.co/DiscoResearch/DiscoLM_German_7b_v1
|
159 |
-
template0="<|im_start|>system\n{system}<|im_end|>\n"
|
160 |
-
template1="<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n"
|
161 |
-
template2="{response}<|im_end|>\n"
|
162 |
-
if("mixtral-8x7b-instruct" in modelPath): # https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1
|
163 |
-
template0="<s>[INST] {system} [/INST] Gerne.</s> " # <s>
|
164 |
-
template1="[INST] {message} [/INST]"
|
165 |
-
template2="{response}</s> "
|
166 |
-
if("Mistral-7B-Instruct" in modelPath): #https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2
|
167 |
-
template0="<s>[INST] {system} [/INST] Gerne.</s> " # <s>
|
168 |
-
template1="[INST] {message} [/INST]"
|
169 |
-
template2=" {response}</s> "
|
170 |
if("gemma-" in modelPath): # https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1
|
171 |
template0="<start_of_turn>user{system}</end_of_turn>"
|
172 |
template1="<start_of_turn>user{message}</end_of_turn><start_of_turn>model"
|
173 |
template2="{response}</end_of_turn>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
if("openchat-3.5" in modelPath): #https://huggingface.co/TheBloke/openchat-3.5-0106-GGUF
|
175 |
template0="GPT4 Correct User: {system}<|end_of_turn|>GPT4 Correct Assistant: Okay.<|end_of_turn|>"
|
176 |
template1="GPT4 Correct User: {message}<|end_of_turn|>GPT4 Correct Assistant: "
|
@@ -179,6 +177,10 @@ def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=
|
|
179 |
template0="<|im_start|>system\n{system}<|im_end|>\n"
|
180 |
template1="<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n"
|
181 |
template2="{response}<|im_end|>\n"
|
|
|
|
|
|
|
|
|
182 |
if("WizardLM-13B-V1.2" in modelPath): #https://huggingface.co/WizardLM/WizardLM-13B-V1.2
|
183 |
template0="{system} " #<s>
|
184 |
template1="USER: {message} ASSISTANT: "
|
@@ -199,7 +201,7 @@ def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=
|
|
199 |
if message is not None: prompt += template1.format(message=message[:zeichenlimit]) #"[INST] {message} [/INST]"
|
200 |
if system2 is not None:
|
201 |
prompt += system2
|
202 |
-
return prompt
|
203 |
|
204 |
import gradio as gr
|
205 |
import requests
|
|
|
150 |
#------------
|
151 |
|
152 |
def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=None, zeichenlimit=None,historylimit=4): #float("Inf")
|
153 |
+
startOfString=""
|
154 |
if zeichenlimit is None: zeichenlimit=1000000000 # :-)
|
155 |
+
template0=" [INST]{system}\n [/INST] </s>" if onPrem else "<s> [INST] {system} [/INST] </s>"
|
156 |
+
template1=" [INST] {message} [/INST]"
|
157 |
+
template2=" {response}</s>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
if("gemma-" in modelPath): # https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1
|
159 |
template0="<start_of_turn>user{system}</end_of_turn>"
|
160 |
template1="<start_of_turn>user{message}</end_of_turn><start_of_turn>model"
|
161 |
template2="{response}</end_of_turn>"
|
162 |
+
if("mixtral-8x7b-instruct" in modelPath): # https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1
|
163 |
+
startOfString="<s>"
|
164 |
+
template0=" [INST]{system}\n [/INST] </s>" if onPrem else "<s> [INST]{system}\n [/INST] </s>"
|
165 |
+
template1=" [INST] {message} [/INST]"
|
166 |
+
template2=" {response}</s>"
|
167 |
+
if("Mistral-7B-Instruct" in modelPath): #https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2
|
168 |
+
startOfString="<s>"
|
169 |
+
template0="[INST]{system}\n [/INST]</s>" if onPrem else "<s>[INST]{system}\n [/INST]</s>"
|
170 |
+
template1="[INST] {message} [/INST]"
|
171 |
+
template2=" {response}</s>"
|
172 |
if("openchat-3.5" in modelPath): #https://huggingface.co/TheBloke/openchat-3.5-0106-GGUF
|
173 |
template0="GPT4 Correct User: {system}<|end_of_turn|>GPT4 Correct Assistant: Okay.<|end_of_turn|>"
|
174 |
template1="GPT4 Correct User: {message}<|end_of_turn|>GPT4 Correct Assistant: "
|
|
|
177 |
template0="<|im_start|>system\n{system}<|im_end|>\n"
|
178 |
template1="<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n"
|
179 |
template2="{response}<|im_end|>\n"
|
180 |
+
if("discolm_german_7b" in modelPath): #https://huggingface.co/DiscoResearch/DiscoLM_German_7b_v1
|
181 |
+
template0="<|im_start|>system\n{system}<|im_end|>\n"
|
182 |
+
template1="<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n"
|
183 |
+
template2="{response}<|im_end|>\n"
|
184 |
if("WizardLM-13B-V1.2" in modelPath): #https://huggingface.co/WizardLM/WizardLM-13B-V1.2
|
185 |
template0="{system} " #<s>
|
186 |
template1="USER: {message} ASSISTANT: "
|
|
|
201 |
if message is not None: prompt += template1.format(message=message[:zeichenlimit]) #"[INST] {message} [/INST]"
|
202 |
if system2 is not None:
|
203 |
prompt += system2
|
204 |
+
return startOfString+prompt
|
205 |
|
206 |
import gradio as gr
|
207 |
import requests
|