Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Simulated responses to show effects of fine-tuning
|
| 4 |
+
techniques = {
|
| 5 |
+
"Full Fine-Tuning": {
|
| 6 |
+
"description": "Retrain the entire model on your specific data. Best for when you have a lot of data and compute.",
|
| 7 |
+
"example_input": "Translate 'How are you?' into Kannada.",
|
| 8 |
+
"output": "ನೀವು ಹೇಗಿದ್ದೀರಾ?"
|
| 9 |
+
},
|
| 10 |
+
"Feature Extraction (Freeze Layers)": {
|
| 11 |
+
"description": "Use the model’s existing features and only train the final layers on your data.",
|
| 12 |
+
"example_input": "Classify: 'This movie was thrilling and well-acted.'",
|
| 13 |
+
"output": "Positive sentiment"
|
| 14 |
+
},
|
| 15 |
+
"Adapter Layers": {
|
| 16 |
+
"description": "Insert small trainable blocks inside a frozen model. Very efficient.",
|
| 17 |
+
"example_input": "Generate a reply to: 'I want to cancel my flight.'",
|
| 18 |
+
"output": "Sure, I can help you cancel your flight. Can I know the booking ID?"
|
| 19 |
+
},
|
| 20 |
+
"LoRA (Low-Rank Adaptation)": {
|
| 21 |
+
"description": "Train only low-rank matrices while keeping the original weights frozen. Saves a lot of memory.",
|
| 22 |
+
"example_input": "Explain: 'Photosynthesis' to a 5-year-old.",
|
| 23 |
+
"output": "Plants make their food using sunlight and air, like magic!"
|
| 24 |
+
},
|
| 25 |
+
"Prompt Tuning": {
|
| 26 |
+
"description": "Only tune how the prompt is phrased. Model weights stay unchanged.",
|
| 27 |
+
"example_input": "Summarize: 'Today was a rainy day and we stayed indoors.'",
|
| 28 |
+
"output": "Summary: It rained and we stayed inside."
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
def show_details(selected_technique):
|
| 33 |
+
data = techniques[selected_technique]
|
| 34 |
+
return data["description"], data["example_input"], data["output"]
|
| 35 |
+
|
| 36 |
+
with gr.Blocks() as demo:
|
| 37 |
+
gr.Markdown("## 🧠 Model Fine-Tuning Techniques (Simulated Examples)")
|
| 38 |
+
gr.Markdown("Select a technique to learn how it works and what it can do:")
|
| 39 |
+
|
| 40 |
+
technique_dropdown = gr.Dropdown(choices=list(techniques.keys()), label="Choose a Fine-Tuning Technique")
|
| 41 |
+
desc = gr.Textbox(label="Description", lines=3)
|
| 42 |
+
example = gr.Textbox(label="Example Input")
|
| 43 |
+
output = gr.Textbox(label="Simulated Output")
|
| 44 |
+
|
| 45 |
+
technique_dropdown.change(fn=show_details, inputs=technique_dropdown, outputs=[desc, example, output])
|
| 46 |
+
|
| 47 |
+
demo.launch()
|