Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,43 +29,60 @@ def greet(model_name, inject_prompt, dataset):
|
|
29 |
return f"Hello!! Using model: {model_name} with template: {inject_prompt}"
|
30 |
|
31 |
##################################### App UI #######################################
|
32 |
-
with gr.Blocks() as demo:
|
33 |
|
34 |
-
|
35 |
-
gr.
|
36 |
-
|
37 |
-
##### Model Inputs #####
|
38 |
-
|
39 |
-
# Select Model
|
40 |
-
modelnames = conf['model']['choices']
|
41 |
-
model_name = gr.Dropdown(label="Supported Models",
|
42 |
-
choices=modelnames,
|
43 |
-
value=modelnames[0])
|
44 |
-
# Prompt template
|
45 |
-
inject_prompt = gr.Textbox(label="Prompt Template",
|
46 |
-
value=prompt_template())
|
47 |
-
# Dataset choice
|
48 |
-
dataset_choice = gr.Radio(label="Choose Dataset", choices=["Hugging Face Hub Dataset", "Upload Your Own"], value="Hugging Face Hub Dataset")
|
49 |
-
dataset_predefined = gr.Textbox(label="Hugging Face Hub Dataset", value='yahma/alpaca-cleaned', visible=True)
|
50 |
-
dataset_upload = gr.UploadButton(label="Upload Dataset (csv, jsonl, or txt)", file_types=[".csv",".jsonl", ".txt"], visible=False)
|
51 |
-
dataset_choice.change(textbox_visibility, dataset_choice, dataset_predefined)
|
52 |
-
dataset_choice.change(upload_visibility, dataset_choice, dataset_upload)
|
53 |
-
|
54 |
-
##### Model Outputs #####
|
55 |
-
|
56 |
-
# Text output
|
57 |
-
output = gr.Textbox(label="Output")
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
##################################### Launch #######################################
|
69 |
|
70 |
if __name__ == "__main__":
|
71 |
-
|
|
|
29 |
return f"Hello!! Using model: {model_name} with template: {inject_prompt}"
|
30 |
|
31 |
##################################### App UI #######################################
|
|
|
32 |
|
33 |
+
def main():
|
34 |
+
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
##### Title Block #####
|
37 |
+
gr.Markdown("# Instruction Tuning with Unsloth")
|
38 |
+
|
39 |
+
##### Model Inputs #####
|
40 |
+
|
41 |
+
# Select Model
|
42 |
+
modelnames = conf['model']['choices']
|
43 |
+
model_name = gr.Dropdown(label="Supported Models",
|
44 |
+
choices=modelnames,
|
45 |
+
value=modelnames[0])
|
46 |
+
# Prompt template
|
47 |
+
inject_prompt = gr.Textbox(label="Prompt Template",
|
48 |
+
value=prompt_template())
|
49 |
+
# Dataset choice
|
50 |
+
dataset_choice = gr.Radio(label="Choose Dataset",
|
51 |
+
choices=["Hugging Face Hub Dataset", "Upload Your Own"],
|
52 |
+
value="Hugging Face Hub Dataset")
|
53 |
+
dataset_predefined = gr.Textbox(label="Hugging Face Hub Dataset",
|
54 |
+
value='yahma/alpaca-cleaned',
|
55 |
+
visible=True)
|
56 |
+
dataset_upload = gr.UploadButton(label="Upload Dataset (csv, jsonl, or txt)",
|
57 |
+
file_types=[".csv",".jsonl", ".txt"],
|
58 |
+
visible=False)
|
59 |
+
dataset_choice.change(textbox_visibility,
|
60 |
+
dataset_choice,
|
61 |
+
dataset_predefined)
|
62 |
+
dataset_choice.change(upload_visibility,
|
63 |
+
dataset_choice,
|
64 |
+
dataset_upload)
|
65 |
+
# Hyperparameters (allow selection, but hide in accordion.)
|
66 |
+
# gr.Accordion('label')
|
67 |
+
|
68 |
+
|
69 |
+
##### Model Outputs #####
|
70 |
+
|
71 |
+
# Text output
|
72 |
+
output = gr.Textbox(label="Output")
|
73 |
+
|
74 |
+
##### Execution #####
|
75 |
+
|
76 |
+
# Setup button
|
77 |
+
tune_btn = gr.Button("Start Fine Tuning")
|
78 |
+
# Execute button
|
79 |
+
tune_btn.click(fn=greet,
|
80 |
+
inputs=[model_name, inject_prompt, dataset_predefined],
|
81 |
+
outputs=output)
|
82 |
+
# Launch baby
|
83 |
+
demo.launch()
|
84 |
|
85 |
##################################### Launch #######################################
|
86 |
|
87 |
if __name__ == "__main__":
|
88 |
+
main()
|