Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,10 @@ token = os.environ.get('HF_TOKEN')
|
|
7 |
|
8 |
# Load model and tokenizer from Hugging Face
|
9 |
model_name = "iqrabatool/finetuned_LLaMA"
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
|
13 |
def respond(message, system_message, max_tokens, temperature, top_p):
|
14 |
# Generate response
|
@@ -17,21 +19,21 @@ def respond(message, system_message, max_tokens, temperature, top_p):
|
|
17 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
18 |
return response
|
19 |
|
20 |
-
# Define interface components
|
21 |
additional_inputs = [
|
22 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
23 |
-
gr.Slider(minimum=1, maximum=
|
24 |
-
gr.Slider(minimum=0.1, maximum=
|
25 |
-
gr.Slider(minimum=0.1, maximum=
|
26 |
]
|
27 |
|
28 |
-
# Create the ChatInterface
|
29 |
demo = gr.Interface(
|
30 |
fn=respond,
|
31 |
inputs=["text", "text", "number", "number", "number"],
|
32 |
outputs="text",
|
33 |
title="Health Bot",
|
34 |
-
description="A chatbot for health-related inquiries.",
|
35 |
article="The Health Bot assists users with health-related questions and provides information based on a pre-trained language model.",
|
36 |
examples=[["What are the symptoms of COVID-19?", "Health Bot: COVID-19 symptoms include..."]],
|
37 |
additional_inputs=additional_inputs
|
|
|
7 |
|
8 |
# Load model and tokenizer from Hugging Face
|
9 |
model_name = "iqrabatool/finetuned_LLaMA"
|
10 |
+
|
11 |
+
# Define a smaller subset of the model or load a smaller version if available
|
12 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, token=token)
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, token=token)
|
14 |
|
15 |
def respond(message, system_message, max_tokens, temperature, top_p):
|
16 |
# Generate response
|
|
|
19 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
20 |
return response
|
21 |
|
22 |
+
# Define simplified interface components
|
23 |
additional_inputs = [
|
24 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
25 |
+
gr.Slider(minimum=1, maximum=512, value=256, step=1, label="Max new tokens"), # Limit max tokens
|
26 |
+
gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature"), # Reduce temperature range
|
27 |
+
gr.Slider(minimum=0.1, maximum=0.9, value=0.5, step=0.05, label="Top-p (nucleus sampling)"), # Reduce top-p range
|
28 |
]
|
29 |
|
30 |
+
# Create the simplified ChatInterface
|
31 |
demo = gr.Interface(
|
32 |
fn=respond,
|
33 |
inputs=["text", "text", "number", "number", "number"],
|
34 |
outputs="text",
|
35 |
title="Health Bot",
|
36 |
+
description="A simplified chatbot for health-related inquiries.",
|
37 |
article="The Health Bot assists users with health-related questions and provides information based on a pre-trained language model.",
|
38 |
examples=[["What are the symptoms of COVID-19?", "Health Bot: COVID-19 symptoms include..."]],
|
39 |
additional_inputs=additional_inputs
|