merve HF staff commited on
Commit
272ce33
1 Parent(s): 26bcd5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -25
app.py CHANGED
@@ -128,31 +128,31 @@ with gr.Blocks(theme="abidlabs/Lime") as demo:
128
  gr.Markdown("Pre-trained TURNA. Enter text to start generating.")
129
  with gr.Column():
130
  with gr.Row():
131
- max_new_tokens = gr.Slider(label = "Maximum length",
132
- minimum = 0,
133
- maximum = 512,
134
- value = 128)
135
- length_penalty = gr.Slider(label = "Length penalty",
136
- value=1.0)
137
- top_k = gr.Slider(label = "Top-k", value=10)
138
- top_p = gr.Slider(label = "Top-p", value=0.95)
139
- temp = gr.Slider(label = "Temperature", value=1.0, minimum=0.1, maximum=100.0)
140
- repetition_penalty = gr.Slider(label = "Repetition Penalty", minimum=0.0, value=3.0, step=0.1)
141
- num_beams = gr.Slider(label = "Number of beams", minimum=1,
142
- maximum=10, value=3)
143
- do_sample = gr.Radio(choices = [True, False], value = True, label = "Sampling")
144
- generation_params = [max_new_tokens, length_penalty,
145
- top_k, top_p, temp, num_beams,
146
- do_sample]
147
- with gr.Row():
148
 
149
  text_gen_input = gr.Textbox(label="Text Generation Input")
150
 
151
  text_gen_submit = gr.Button()
152
  text_gen_output = gr.Textbox(label="Text Generation Output")
153
- text_gen_submit.click(turna, inputs=[text_gen_input, generation_params], outputs=text_gen_output)
 
 
154
  text_gen_example = [["Bir varmış, bir yokmuş, evvel zaman içinde, kalbur saman içinde, uzak diyarların birinde bir turna"]]
155
- text_gen_examples = gr.Examples(examples = text_gen_example, inputs = [text_gen_input, generation_params], outputs=text_gen_output, fn=turna)
 
156
 
157
  with gr.Tab("Text Categorization"):
158
  gr.Markdown("TURNA fine-tuned on text categorization. Enter text to categorize text or try the example.")
@@ -163,12 +163,8 @@ with gr.Blocks(theme="abidlabs/Lime") as demo:
163
 
164
  text_submit = gr.Button()
165
  text_output = gr.Textbox(label="Text Categorization Output")
166
- text_submit.click(categorize, inputs=[text_input, max_new_tokens, length_penalty,
167
- top_k, top_p, temp, num_beams,
168
- do_sample], outputs=text_output)
169
- text_examples = gr.Examples(examples = text_category_example, inputs = [text_input, max_new_tokens, length_penalty,
170
- top_k, top_p, temp, num_beams,
171
- do_sample], outputs=text_output, fn=categorize)
172
 
173
 
174
  with gr.Tab("NLI"):
 
128
  gr.Markdown("Pre-trained TURNA. Enter text to start generating.")
129
  with gr.Column():
130
  with gr.Row():
131
+ with gr.Column():
132
+ max_new_tokens = gr.Slider(label = "Maximum length",
133
+ minimum = 0,
134
+ maximum = 512,
135
+ value = 128)
136
+ length_penalty = gr.Slider(label = "Length penalty",
137
+ value=1.0)
138
+ top_k = gr.Slider(label = "Top-k", value=10)
139
+ top_p = gr.Slider(label = "Top-p", value=0.95)
140
+ temp = gr.Slider(label = "Temperature", value=1.0, minimum=0.1, maximum=100.0)
141
+ repetition_penalty = gr.Slider(label = "Repetition Penalty", minimum=0.0, value=3.0, step=0.1)
142
+ num_beams = gr.Slider(label = "Number of beams", minimum=1,
143
+ maximum=10, value=3)
144
+ do_sample = gr.Radio(choices = [True, False], value = True, label = "Sampling")
 
 
 
145
 
146
  text_gen_input = gr.Textbox(label="Text Generation Input")
147
 
148
  text_gen_submit = gr.Button()
149
  text_gen_output = gr.Textbox(label="Text Generation Output")
150
+ text_gen_submit.click(turna, inputs=[text_gen_input, max_new_tokens, length_penalty,
151
+ top_k, top_p, temperature=temp, num_beams,
152
+ do_sample], outputs=text_gen_output)
153
  text_gen_example = [["Bir varmış, bir yokmuş, evvel zaman içinde, kalbur saman içinde, uzak diyarların birinde bir turna"]]
154
+ text_gen_examples = gr.Examples(examples = text_gen_example, inputs = [text_gen_input, max_new_tokens, length_penalty,
155
+ top_k, top_p, temp, num_beams, do_sample], outputs=text_gen_output, fn=turna)
156
 
157
  with gr.Tab("Text Categorization"):
158
  gr.Markdown("TURNA fine-tuned on text categorization. Enter text to categorize text or try the example.")
 
163
 
164
  text_submit = gr.Button()
165
  text_output = gr.Textbox(label="Text Categorization Output")
166
+ text_submit.click(categorize, inputs=[text_input], outputs=text_output)
167
+ text_examples = gr.Examples(examples = text_category_example, fn=categorize)
 
 
 
 
168
 
169
 
170
  with gr.Tab("NLI"):