Spaces:
Running
on
Zero
Running
on
Zero
fix: parameters
Browse files
app.py
CHANGED
@@ -35,12 +35,12 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
35 |
@spaces.GPU
|
36 |
def generate(
|
37 |
user_input,
|
38 |
-
prompt_style,
|
39 |
temperature,
|
40 |
max_tokens,
|
41 |
top_k,
|
42 |
repetition_penalty,
|
43 |
top_p,
|
|
|
44 |
):
|
45 |
streamer = TextIteratorStreamer(
|
46 |
tokenizer, skip_prompt=True, skip_special_tokens=True
|
@@ -155,6 +155,7 @@ with gr.Blocks(
|
|
155 |
# Update button states based on input and output text changes for interactivity
|
156 |
def update_button_states_sq(input_text, output_text):
|
157 |
return [
|
|
|
158 |
gr.update(interactive=bool(input_text)),
|
159 |
gr.update(interactive=bool(input_text or output_text)),
|
160 |
]
|
@@ -176,7 +177,6 @@ with gr.Blocks(
|
|
176 |
fn=generate,
|
177 |
inputs=[
|
178 |
input_text_sq,
|
179 |
-
gr.Textbox(value=""), # No style prompt needed for simple question
|
180 |
temperature_sq,
|
181 |
max_tokens_sq,
|
182 |
top_k_sq,
|
@@ -205,6 +205,7 @@ with gr.Blocks(
|
|
205 |
)
|
206 |
style_dropdown = gr.Dropdown(
|
207 |
choices=["Formalny", "Nieformalny", "Neutralny"],
|
|
|
208 |
elem_id="style-dropdown",
|
209 |
show_label=False,
|
210 |
elem_classes="same-height",
|
@@ -245,15 +246,15 @@ with gr.Blocks(
|
|
245 |
|
246 |
# Event handlers for button actions to process and clear text
|
247 |
generate_btn.click(
|
248 |
-
fn=lambda input_text, style: generate(
|
249 |
input_text,
|
250 |
-
STYLE_PROMPTS[style],
|
251 |
0.3, # Hardcoded temperature
|
252 |
1024, # Hardcoded max_tokens
|
253 |
40, # Hardcoded top_k
|
254 |
1.1, # Hardcoded repetition_penalty
|
255 |
-
0.95 # Hardcoded top_p
|
256 |
-
|
|
|
257 |
inputs=[
|
258 |
input_text,
|
259 |
style_dropdown
|
|
|
35 |
@spaces.GPU
|
36 |
def generate(
|
37 |
user_input,
|
|
|
38 |
temperature,
|
39 |
max_tokens,
|
40 |
top_k,
|
41 |
repetition_penalty,
|
42 |
top_p,
|
43 |
+
prompt_style="",
|
44 |
):
|
45 |
streamer = TextIteratorStreamer(
|
46 |
tokenizer, skip_prompt=True, skip_special_tokens=True
|
|
|
155 |
# Update button states based on input and output text changes for interactivity
|
156 |
def update_button_states_sq(input_text, output_text):
|
157 |
return [
|
158 |
+
gr.update(interactive=bool(input_text)),
|
159 |
gr.update(interactive=bool(input_text)),
|
160 |
gr.update(interactive=bool(input_text or output_text)),
|
161 |
]
|
|
|
177 |
fn=generate,
|
178 |
inputs=[
|
179 |
input_text_sq,
|
|
|
180 |
temperature_sq,
|
181 |
max_tokens_sq,
|
182 |
top_k_sq,
|
|
|
205 |
)
|
206 |
style_dropdown = gr.Dropdown(
|
207 |
choices=["Formalny", "Nieformalny", "Neutralny"],
|
208 |
+
value="Neutralny", # Set a default value
|
209 |
elem_id="style-dropdown",
|
210 |
show_label=False,
|
211 |
elem_classes="same-height",
|
|
|
246 |
|
247 |
# Event handlers for button actions to process and clear text
|
248 |
generate_btn.click(
|
249 |
+
fn=lambda input_text, style: "".join(generate(
|
250 |
input_text,
|
|
|
251 |
0.3, # Hardcoded temperature
|
252 |
1024, # Hardcoded max_tokens
|
253 |
40, # Hardcoded top_k
|
254 |
1.1, # Hardcoded repetition_penalty
|
255 |
+
0.95, # Hardcoded top_p
|
256 |
+
STYLE_PROMPTS[style],
|
257 |
+
)),
|
258 |
inputs=[
|
259 |
input_text,
|
260 |
style_dropdown
|