tykiww commited on
Commit
17dfda2
1 Parent(s): 7850469

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -34
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
- ##### Title Block #####
35
- gr.Markdown("# Instruction Tuning with Unsloth")
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
- ##### Execution #####
60
-
61
- # Setup button
62
- tune_btn = gr.Button("Start Fine Tuning")
63
- # Execute button
64
- tune_btn.click(fn=greet,
65
- inputs=[model_name, inject_prompt, dataset_predefined],
66
- outputs=output)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  ##################################### Launch #######################################
69
 
70
  if __name__ == "__main__":
71
- demo.launch()
 
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()