Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
from ctransformers import AutoModelForCausalLM # Please ensure this import is correct
|
4 |
-
from
|
5 |
|
6 |
PROMPT_TEMPLATE = (
|
7 |
-
|
8 |
-
"<<SYS>>"
|
9 |
-
"""You are a dedicated public health assistant, trained to support community health workers (CHWs) in their essential role of enhancing community health. Uphold these principles in your interactions:
|
10 |
-
- Be kind, helpful, respectful, honest, and professional. Think step by step before answering each question. Think about whether this is the right answer, would others agree with it? Improve your answer as needed.
|
11 |
-
- Always provide answers that are clear, concise, and focused on key concepts. Highlight main points and avoid unnecessary repetition.
|
12 |
-
- Base your responses on the latest training data available up to September 2021.
|
13 |
-
- Engage with a positive and supportive demeanor, understanding the importance of professionalism.
|
14 |
-
- Assist CHWs in understanding disease definitions, surveillance goals, and strategies. Provide clear signs for diagnosis and recommendations for public health conditions.
|
15 |
-
- Your primary aim is to help CHWs identify significant public health diseases promptly, ensuring quick interventions.
|
16 |
-
- If unsure about a question, acknowledge the limitation and avoid sharing incorrect information.
|
17 |
-
"""
|
18 |
-
"<</SYS>>" "[/INST]" "</s>"
|
19 |
)
|
20 |
|
21 |
def load_llm():
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
max_new_tokens = 1096,
|
25 |
repetition_penalty = 1.13,
|
26 |
temperature = 0.1
|
@@ -36,7 +30,7 @@ def llm_function(message, chat_history):
|
|
36 |
output_texts = response
|
37 |
return output_texts
|
38 |
|
39 |
-
title = "
|
40 |
|
41 |
examples = [
|
42 |
'What is yellow fever.',
|
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
from ctransformers import AutoModelForCausalLM # Please ensure this import is correct
|
4 |
+
from huggingface_hub import hf_hub_download
|
5 |
|
6 |
PROMPT_TEMPLATE = (
|
7 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
)
|
9 |
|
10 |
def load_llm():
|
11 |
+
|
12 |
+
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
13 |
+
llm = AutoModelForCausalLM.from_pretrained(
|
14 |
+
"s3nh/PY007-TinyLlama-1.1B-Chat-v0.2-GGUF",
|
15 |
+
model_file="PY007-TinyLlama-1.1B-Chat-v0.2.Q4_K_M.gguf",
|
16 |
+
model_type="llama",
|
17 |
+
gpu_layers=0
|
18 |
max_new_tokens = 1096,
|
19 |
repetition_penalty = 1.13,
|
20 |
temperature = 0.1
|
|
|
30 |
output_texts = response
|
31 |
return output_texts
|
32 |
|
33 |
+
title = "这里是小兮辞"
|
34 |
|
35 |
examples = [
|
36 |
'What is yellow fever.',
|