|
|
|
|
|
import gradio as gr |
|
|
|
|
|
from utilities.setup import get_json_cfg |
|
|
|
|
|
|
|
conf = get_json_cfg() |
|
|
|
def dropdown_visibility(radio): |
|
value = radio |
|
if value == "Predefined Dataset": |
|
return gr.Dropdown(visible=bool(1)) |
|
else: |
|
return gr.Dropdown(visible=bool(0)) |
|
|
|
def upload_visibility(radio): |
|
value = radio |
|
if value == "Upload Your Own": |
|
return gr.UploadButton(visible=bool(1)) |
|
else: |
|
return gr.UploadButton(visible=bool(0)) |
|
|
|
def greet(model_name, prompt_template, name, dataset): |
|
"""The model call""" |
|
return f"Hello {name}!! Using model: {model_name} with template: {prompt_template}" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
|
|
|
gr.Markdown("# Instruction Tuning with Unsloth") |
|
|
|
|
|
|
|
|
|
model_name = gr.Dropdown(label="Model", choices=conf['model']['choices'], value="gpt2") |
|
|
|
prompt_template = gr.Textbox(label="Prompt Template", value="Instruction: {0}\nOutput: {1}") |
|
|
|
name_input = gr.Textbox(label="Your Name") |
|
|
|
dataset_choice = gr.Radio(label="Choose Dataset", choices=["Predefined Dataset", "Upload Your Own"], value="Predefined Dataset") |
|
dataset_predefined = gr.Dropdown(label="Predefined Dataset", choices=['1', '2', '3'], value='1', visible=True) |
|
dataset_upload = gr.UploadButton(label="Upload Dataset", file_types=[".pdf",".csv",".jsonl"], visible=False) |
|
dataset_choice.change(dropdown_visibility, dataset_choice, dataset_predefined) |
|
dataset_choice.change(upload_visibility, dataset_choice, dataset_upload) |
|
|
|
|
|
|
|
|
|
output = gr.Textbox(label="Output") |
|
|
|
|
|
|
|
|
|
tune_btn = gr.Button("Start Fine Tuning") |
|
|
|
tune_btn.click(fn=greet, |
|
inputs=[model_name, prompt_template, name_input, dataset_predefined], |
|
outputs=output) |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|