Spaces:
Sleeping
Sleeping
add extra inputs for generation parameters
Browse files
app.py
CHANGED
@@ -43,6 +43,8 @@ def flatten(l):
|
|
43 |
|
44 |
|
45 |
def run_model_with_frames(text, framesize=4, overlap=3):
|
|
|
|
|
46 |
frames = create_frames(text, framesize, overlap)
|
47 |
result = set()
|
48 |
for frame in frames:
|
@@ -90,9 +92,11 @@ progress and might still be a little bit buggy."""
|
|
90 |
with gr.Blocks() as iface:
|
91 |
gr.Markdown(description)
|
92 |
context = gr.Textbox(label="Input text")
|
|
|
|
|
93 |
questions = gr.Textbox(label="Questions")
|
94 |
generate_btn = gr.Button("Generate questions")
|
95 |
-
generate_btn.click(fn=run_model_with_frames, inputs=context, outputs=questions, api_name="generate_questions")
|
96 |
|
97 |
#iface = gr.Interface(fn=run_model_with_frames, inputs="text", outputs="text")
|
98 |
iface.launch()
|
|
|
43 |
|
44 |
|
45 |
def run_model_with_frames(text, framesize=4, overlap=3):
|
46 |
+
if overlap > framesize:
|
47 |
+
return "Overlap should be smaller than batch size"
|
48 |
frames = create_frames(text, framesize, overlap)
|
49 |
result = set()
|
50 |
for frame in frames:
|
|
|
92 |
with gr.Blocks() as iface:
|
93 |
gr.Markdown(description)
|
94 |
context = gr.Textbox(label="Input text")
|
95 |
+
frame_size = gr.Number(value=5, label="Batch size", info="Size of the subparts that are used to generate questions. Increase to speed up the generation", precision=0)
|
96 |
+
overlap = gr.Number(value=4, label="Overlap", info="Overlap between batches. Should be bigger than batch size. Decrease to speed up generation", precision=0)
|
97 |
questions = gr.Textbox(label="Questions")
|
98 |
generate_btn = gr.Button("Generate questions")
|
99 |
+
generate_btn.click(fn=run_model_with_frames, inputs=[context, frame_size, overlap], outputs=questions, api_name="generate_questions")
|
100 |
|
101 |
#iface = gr.Interface(fn=run_model_with_frames, inputs="text", outputs="text")
|
102 |
iface.launch()
|