| import gradio as gr |
|
|
| |
| techniques = { |
| "Full Fine-Tuning": { |
| "description": "Retrain the entire model on your specific data. Best for when you have a lot of data and compute.", |
| "example_input": "Translate 'How are you?' into Kannada.", |
| "output": "ನೀವು ಹೇಗಿದ್ದೀರಾ?" |
| }, |
| "Feature Extraction (Freeze Layers)": { |
| "description": "Use the model’s existing features and only train the final layers on your data.", |
| "example_input": "Classify: 'This movie was thrilling and well-acted.'", |
| "output": "Positive sentiment" |
| }, |
| "Adapter Layers": { |
| "description": "Insert small trainable blocks inside a frozen model. Very efficient.", |
| "example_input": "Generate a reply to: 'I want to cancel my flight.'", |
| "output": "Sure, I can help you cancel your flight. Can I know the booking ID?" |
| }, |
| "LoRA (Low-Rank Adaptation)": { |
| "description": "Train only low-rank matrices while keeping the original weights frozen. Saves a lot of memory.", |
| "example_input": "Explain: 'Photosynthesis' to a 5-year-old.", |
| "output": "Plants make their food using sunlight and air, like magic!" |
| }, |
| "Prompt Tuning": { |
| "description": "Only tune how the prompt is phrased. Model weights stay unchanged.", |
| "example_input": "Summarize: 'Today was a rainy day and we stayed indoors.'", |
| "output": "Summary: It rained and we stayed inside." |
| } |
| } |
|
|
| def show_details(selected_technique): |
| data = techniques[selected_technique] |
| return data["description"], data["example_input"], data["output"] |
|
|
| with gr.Blocks() as demo: |
| gr.Markdown("## 🧠 Model Fine-Tuning Techniques (Simulated Examples)") |
| gr.Markdown("Select a technique to learn how it works and what it can do:") |
|
|
| technique_dropdown = gr.Dropdown(choices=list(techniques.keys()), label="Choose a Fine-Tuning Technique") |
| desc = gr.Textbox(label="Description", lines=3) |
| example = gr.Textbox(label="Example Input") |
| output = gr.Textbox(label="Simulated Output") |
|
|
| technique_dropdown.change(fn=show_details, inputs=technique_dropdown, outputs=[desc, example, output]) |
|
|
| demo.launch() |
|
|