Update app
Browse files
app.py
CHANGED
@@ -6,29 +6,22 @@ import gradio as gr
|
|
6 |
|
7 |
|
8 |
def generate_prompt(history):
|
9 |
-
prompt =
|
10 |
for chain in history[:-1]:
|
11 |
-
prompt += f"
|
12 |
-
|
13 |
-
prompt += f"<|im_start|>user\n{history[-1][0]}<|im_end|>" +\
|
14 |
-
"<|im_start|>assistant\n"
|
15 |
return prompt
|
16 |
|
17 |
def generate(history):
|
18 |
prompt = generate_prompt(history)
|
19 |
|
20 |
-
streamer = llm(prompt,
|
21 |
return streamer
|
22 |
|
23 |
|
24 |
|
25 |
-
llm = AutoModelForCausalLM.from_pretrained("model/
|
26 |
-
|
27 |
-
|
28 |
-
start_message = """<|im_start|>system
|
29 |
-
You are a helpful assistant chatbot.<|im_end|>
|
30 |
-
"""
|
31 |
-
|
32 |
|
33 |
|
34 |
with gr.Blocks() as demo:
|
@@ -53,4 +46,4 @@ with gr.Blocks() as demo:
|
|
53 |
|
54 |
demo.queue()
|
55 |
if __name__ == "__main__":
|
56 |
-
demo.launch(
|
|
|
6 |
|
7 |
|
8 |
def generate_prompt(history):
|
9 |
+
prompt = "<s> "
|
10 |
for chain in history[:-1]:
|
11 |
+
prompt += f"<human>: {chain[0]}\n<bot>: {chain[1]}{end_token}\n"
|
12 |
+
prompt += f"<human>: {history[-1][0]}\n<bot>: "
|
|
|
|
|
13 |
return prompt
|
14 |
|
15 |
def generate(history):
|
16 |
prompt = generate_prompt(history)
|
17 |
|
18 |
+
streamer = llm(prompt, temperature=0, stream=True)
|
19 |
return streamer
|
20 |
|
21 |
|
22 |
|
23 |
+
llm = AutoModelForCausalLM.from_pretrained("model/model_q4_0.bin", model_type='llama')
|
24 |
+
end_token = "</s>"
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
|
27 |
with gr.Blocks() as demo:
|
|
|
46 |
|
47 |
demo.queue()
|
48 |
if __name__ == "__main__":
|
49 |
+
demo.launch()
|