Spaces:
Runtime error
Runtime error
add demo
Browse files
app.py
CHANGED
@@ -13,10 +13,8 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
13 |
device_map="auto",
|
14 |
torch_dtype=torch.bfloat16
|
15 |
)
|
16 |
-
|
17 |
-
#
|
18 |
-
if tokenizer.pad_token_id is None:
|
19 |
-
tokenizer.pad_token_id = tokenizer.eos_token_id
|
20 |
|
21 |
description = """
|
22 |
Salamandra-2b-instruct is a Transformer-based decoder-only language model that has been pre-trained on 7.8 trillion tokens of highly curated data.
|
@@ -47,7 +45,7 @@ def generate_text(system_prompt, user_prompt, temperature, max_new_tokens, top_p
|
|
47 |
)
|
48 |
|
49 |
inputs = tokenizer(chat_prompt, return_tensors="pt", padding=True, truncation=True)
|
50 |
-
inputs = {k: v.to(model.device) for k, v in inputs.items()}
|
51 |
|
52 |
outputs = model.generate(
|
53 |
**inputs,
|
@@ -71,23 +69,25 @@ with gr.Blocks() as demo:
|
|
71 |
|
72 |
with gr.Row():
|
73 |
with gr.Column(scale=1):
|
74 |
-
gr.
|
|
|
75 |
with gr.Column(scale=1):
|
76 |
-
gr.
|
|
|
77 |
|
78 |
with gr.Row():
|
79 |
with gr.Column(scale=1):
|
80 |
system_prompt = gr.Textbox(
|
81 |
lines=3,
|
82 |
label="π₯οΈ System Prompt",
|
83 |
-
value="You are a
|
84 |
)
|
85 |
user_prompt = gr.Textbox(lines=5, label="πββοΈ User Prompt")
|
86 |
generate_button = gr.Button("Generate with π¦ Salamandra-2b-instruct")
|
87 |
|
88 |
with gr.Accordion("π§ͺ Parameters", open=False):
|
89 |
temperature = gr.Slider(0.0, 1.0, value=0.7, label="π‘οΈ Temperature")
|
90 |
-
max_new_tokens = gr.Slider(1,
|
91 |
top_p = gr.Slider(0.0, 1.0, value=0.95, label="βοΈ Top P")
|
92 |
repetition_penalty = gr.Slider(1.0, 2.0, value=1.2, label="π Repetition Penalty")
|
93 |
|
|
|
13 |
device_map="auto",
|
14 |
torch_dtype=torch.bfloat16
|
15 |
)
|
16 |
+
# if tokenizer.pad_token_id is None:
|
17 |
+
# tokenizer.pad_token_id = tokenizer.eos_token_id
|
|
|
|
|
18 |
|
19 |
description = """
|
20 |
Salamandra-2b-instruct is a Transformer-based decoder-only language model that has been pre-trained on 7.8 trillion tokens of highly curated data.
|
|
|
45 |
)
|
46 |
|
47 |
inputs = tokenizer(chat_prompt, return_tensors="pt", padding=True, truncation=True)
|
48 |
+
# inputs = {k: v.to(model.device) for k, v in inputs.items()}
|
49 |
|
50 |
outputs = model.generate(
|
51 |
**inputs,
|
|
|
69 |
|
70 |
with gr.Row():
|
71 |
with gr.Column(scale=1):
|
72 |
+
with gr.Group():
|
73 |
+
gr.Markdown(description)
|
74 |
with gr.Column(scale=1):
|
75 |
+
with gr.Group():
|
76 |
+
gr.Markdown(join_us)
|
77 |
|
78 |
with gr.Row():
|
79 |
with gr.Column(scale=1):
|
80 |
system_prompt = gr.Textbox(
|
81 |
lines=3,
|
82 |
label="π₯οΈ System Prompt",
|
83 |
+
value="You are Tonic-ai a senior expert assistant known for their abilities to explain and answer questions."
|
84 |
)
|
85 |
user_prompt = gr.Textbox(lines=5, label="πββοΈ User Prompt")
|
86 |
generate_button = gr.Button("Generate with π¦ Salamandra-2b-instruct")
|
87 |
|
88 |
with gr.Accordion("π§ͺ Parameters", open=False):
|
89 |
temperature = gr.Slider(0.0, 1.0, value=0.7, label="π‘οΈ Temperature")
|
90 |
+
max_new_tokens = gr.Slider(1, 2046, value=450, step=1, label="π’ Max New Tokens")
|
91 |
top_p = gr.Slider(0.0, 1.0, value=0.95, label="βοΈ Top P")
|
92 |
repetition_penalty = gr.Slider(1.0, 2.0, value=1.2, label="π Repetition Penalty")
|
93 |
|