Spaces:
Runtime error
Runtime error
Anonymous
commited on
Commit
·
028491e
1
Parent(s):
f31b1b7
update app
Browse files- app.py +26 -24
- generate_prompt.py +2 -6
app.py
CHANGED
|
@@ -41,37 +41,39 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 41 |
with gr.Row():
|
| 42 |
task = gr.Dropdown(label="Task", choices=list(tasks_datasets.keys()), value=QA)
|
| 43 |
language = gr.Dropdown(label="Source Language", choices=languages, value="English")
|
| 44 |
-
model_type = gr.Dropdown(label="Model Type", choices=["Multilingual", "
|
| 45 |
config_recommendation = gr.Button("Recommend Configuration")
|
| 46 |
with gr.Row():
|
| 47 |
config_prompt = gr.Textbox(label="Recommended Configuration", interactive=False,
|
| 48 |
placeholder="Recommended Configuration for this scenerio")
|
| 49 |
with gr.Row():
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
| 52 |
# Set the same background style across all components
|
| 53 |
with gr.Group(elem_id="prompt-background"):
|
| 54 |
-
|
| 55 |
instruction = gr.Textbox(label="Instruction")
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
with gr.
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
generate_button = gr.Button("Generate Prompt")
|
| 77 |
|
|
@@ -214,4 +216,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 214 |
)
|
| 215 |
|
| 216 |
if __name__ == '__main__':
|
| 217 |
-
demo.launch(share=True)
|
|
|
|
| 41 |
with gr.Row():
|
| 42 |
task = gr.Dropdown(label="Task", choices=list(tasks_datasets.keys()), value=QA)
|
| 43 |
language = gr.Dropdown(label="Source Language", choices=languages, value="English")
|
| 44 |
+
model_type = gr.Dropdown(label="Model Type", choices=["Multilingual", "Standard"], value='Multilingual')
|
| 45 |
config_recommendation = gr.Button("Recommend Configuration")
|
| 46 |
with gr.Row():
|
| 47 |
config_prompt = gr.Textbox(label="Recommended Configuration", interactive=False,
|
| 48 |
placeholder="Recommended Configuration for this scenerio")
|
| 49 |
with gr.Row():
|
| 50 |
+
# examples_selection = gr.Dropdown(["English", "Source"], label="examples", value='English')
|
| 51 |
+
# output_selection = gr.Dropdown(["English", "Source"], label="output", value='English')
|
| 52 |
+
with gr.Column(scale=2):
|
| 53 |
+
gr.Markdown("### Prompt Template", elem_id="section-title") # Adding a small title
|
| 54 |
# Set the same background style across all components
|
| 55 |
with gr.Group(elem_id="prompt-background"):
|
|
|
|
| 56 |
instruction = gr.Textbox(label="Instruction")
|
| 57 |
+
with gr.Row(variant="panel"):
|
| 58 |
+
zero_shot = gr.Checkbox(label="Zero Shot Setting", value=False)
|
| 59 |
+
with gr.Accordion("Few Shot - Select Type of Examples ", open=False, visible=True) as few_shot:
|
| 60 |
+
dataset = gr.Dropdown(label="Dataset", choices=tasks_datasets[QA], value="XlSum")
|
| 61 |
+
num_examples = gr.Slider(label="Number of examples in context", minimum=1, maximum=10, step=1,
|
| 62 |
+
value=3)
|
| 63 |
+
with gr.Row(equal_height=True, variant="panel"):
|
| 64 |
+
with gr.Accordion(label="Language Component Selection", open=False):
|
| 65 |
+
prefix_selection = gr.Dropdown(["English", "Source"], label="prefix", value='English')
|
| 66 |
+
context_selection = gr.Dropdown(["English", "Source"], label="context", value='English')
|
| 67 |
+
examples_selection = gr.Dropdown(["English", "Source"], label="examples", value='English')
|
| 68 |
+
output_selection = gr.Dropdown(["English", "Source"], label="output", value='English')
|
| 69 |
+
# Accordion for Few Shot example selection
|
| 70 |
+
with gr.Accordion(label="Prompt Input Data", open=False):
|
| 71 |
+
question = gr.Textbox(label="Question", visible=True)
|
| 72 |
+
context = gr.Textbox(label="Context", visible=True)
|
| 73 |
+
text = gr.Textbox(label="Text", visible=False)
|
| 74 |
+
sentence = gr.Textbox(label="Sentence", visible=False)
|
| 75 |
+
hypothesis = gr.Textbox(label="Hypothesis", visible=False)
|
| 76 |
+
premise = gr.Textbox(label="Premise", visible=False)
|
| 77 |
|
| 78 |
generate_button = gr.Button("Generate Prompt")
|
| 79 |
|
|
|
|
| 216 |
)
|
| 217 |
|
| 218 |
if __name__ == '__main__':
|
| 219 |
+
demo.launch(share=True)
|
generate_prompt.py
CHANGED
|
@@ -608,7 +608,7 @@ class Config:
|
|
| 608 |
|
| 609 |
def to_dict(self):
|
| 610 |
return {
|
| 611 |
-
'
|
| 612 |
'context': self.context,
|
| 613 |
'examples': self.examples,
|
| 614 |
'output': self.output
|
|
@@ -616,12 +616,8 @@ class Config:
|
|
| 616 |
|
| 617 |
|
| 618 |
def recommend_config(task, lang, model_type):
|
| 619 |
-
print(task)
|
| 620 |
-
print(model_type)
|
| 621 |
-
print(lang)
|
| 622 |
language_type = _get_language_type(lang)
|
| 623 |
config = Config(lang, lang, lang, lang)
|
| 624 |
-
print(language_type)
|
| 625 |
if task == QA:
|
| 626 |
if model_type == ModelType.English.value:
|
| 627 |
config.set(prefix=lang, context=lang, examples=lang, output=lang)
|
|
@@ -643,5 +639,5 @@ def recommend_config(task, lang, model_type):
|
|
| 643 |
config.set(prefix='English', context='English', examples='English')
|
| 644 |
if task == SUMMARIZATION:
|
| 645 |
config.set(context='English')
|
| 646 |
-
|
| 647 |
return config.to_dict()
|
|
|
|
| 608 |
|
| 609 |
def to_dict(self):
|
| 610 |
return {
|
| 611 |
+
'instruction': self.prefix,
|
| 612 |
'context': self.context,
|
| 613 |
'examples': self.examples,
|
| 614 |
'output': self.output
|
|
|
|
| 616 |
|
| 617 |
|
| 618 |
def recommend_config(task, lang, model_type):
|
|
|
|
|
|
|
|
|
|
| 619 |
language_type = _get_language_type(lang)
|
| 620 |
config = Config(lang, lang, lang, lang)
|
|
|
|
| 621 |
if task == QA:
|
| 622 |
if model_type == ModelType.English.value:
|
| 623 |
config.set(prefix=lang, context=lang, examples=lang, output=lang)
|
|
|
|
| 639 |
config.set(prefix='English', context='English', examples='English')
|
| 640 |
if task == SUMMARIZATION:
|
| 641 |
config.set(context='English')
|
| 642 |
+
print(config.to_dict())
|
| 643 |
return config.to_dict()
|