Update app.py
Browse files
app.py
CHANGED
@@ -2,23 +2,25 @@ import gradio as gr
|
|
2 |
from gpt4all import GPT4All
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
|
5 |
-
title = "
|
6 |
description = """
|
7 |
-
|
8 |
"""
|
9 |
|
10 |
-
model_path = "
|
11 |
-
model_name = "
|
12 |
-
hf_hub_download(repo_id="
|
13 |
|
14 |
print("Start the model init process")
|
15 |
model = model = GPT4All(model_name, model_path, allow_download = True, device="cpu")
|
16 |
print("Finish the model init process")
|
17 |
|
18 |
-
model.config["promptTemplate"] = '''
|
|
|
|
|
19 |
|
20 |
'''
|
21 |
-
model.config["systemPrompt"] = "You are a helpful assistant named
|
22 |
model._is_chat_session_activated = True
|
23 |
|
24 |
max_new_tokens = 2048
|
@@ -27,7 +29,7 @@ def generater(message, history, temperature, top_p, top_k):
|
|
27 |
prompt = ""
|
28 |
for user_message, assistant_message in history:
|
29 |
prompt += model.config["promptTemplate"].format(user_message)
|
30 |
-
prompt += assistant_message + "<|
|
31 |
prompt += model.config["promptTemplate"].format(message)
|
32 |
outputs = []
|
33 |
for token in model.generate(prompt=prompt, temp=temperature, top_k = top_k, top_p = top_p, max_tokens = max_new_tokens, streaming=True):
|
|
|
2 |
from gpt4all import GPT4All
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
|
5 |
+
title = "安风"
|
6 |
description = """
|
7 |
+
Infer service
|
8 |
"""
|
9 |
|
10 |
+
model_path = "tastypear/CausalLM-7B-DPO-alpha-GGUF"
|
11 |
+
model_name = "causallm_7b-dpo-alpha.Q4_K_M.gguf"
|
12 |
+
hf_hub_download(repo_id="tastypear/CausalLM-7B-DPO-alpha-GGUF", filename=model_name, local_dir=model_path, local_dir_use_symlinks=True)
|
13 |
|
14 |
print("Start the model init process")
|
15 |
model = model = GPT4All(model_name, model_path, allow_download = True, device="cpu")
|
16 |
print("Finish the model init process")
|
17 |
|
18 |
+
model.config["promptTemplate"] = '''<|im_start|>user
|
19 |
+
{0}<|im_end|>
|
20 |
+
<|im_start|>assistant
|
21 |
|
22 |
'''
|
23 |
+
model.config["systemPrompt"] = "You are a helpful assistant named 安风."
|
24 |
model._is_chat_session_activated = True
|
25 |
|
26 |
max_new_tokens = 2048
|
|
|
29 |
prompt = ""
|
30 |
for user_message, assistant_message in history:
|
31 |
prompt += model.config["promptTemplate"].format(user_message)
|
32 |
+
prompt += assistant_message + "<|im_end|>"
|
33 |
prompt += model.config["promptTemplate"].format(message)
|
34 |
outputs = []
|
35 |
for token in model.generate(prompt=prompt, temp=temperature, top_k = top_k, top_p = top_p, max_tokens = max_new_tokens, streaming=True):
|