Spaces:
Running
Running
File size: 11,878 Bytes
bc7ca83 3ac5035 bc7ca83 3fbc5ed bc7ca83 31defff bc7ca83 1b9d989 31defff 3fbc5ed a2f12be bc7ca83 31defff 94f9d08 31defff 7330493 94f9d08 7330493 31defff 94f9d08 31defff 536f160 31defff 7330493 31defff 7330493 31defff 7330493 31defff 7330493 31defff 7330493 31defff 7330493 0a565db 7330493 0a565db 7330493 0a565db 7330493 0a565db 31defff 7330493 31defff 7330493 31defff 7330493 31defff 7330493 31defff 0a565db 31defff 7330493 31defff 7330493 31defff 7330493 31defff 7330493 31defff 94f9d08 31defff 94f9d08 31defff 7330493 31defff 7330493 31defff 94f9d08 31defff 7330493 31defff |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
---
title: Fistal AI
emoji: ๐
colorFrom: indigo
colorTo: pink
sdk: gradio
sdk_version: 6.0.1
app_file: app.py
pinned: false
license: apache-2.0
short_description: Finetuning Studio
python_version: 3.11
tags:
- mcp-in-action-track-enterprise
- mcp-in-action-track-consumer
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
<div align= "center">
<h1>๐ Fistal AI - Autonomous Fine-Tuning Platform </h1>
</div>
<div align="center">
[](https://huggingface.co/spaces/your-username/fistal-ai)









**Agentic AI that seamlessly finetunes LLM's with Unsloth and Modal**
[๐ฎ Try Demo](https://drive.google.com/file/d/1-Uf2-k-gJsIozg-YX0oo_qWjeS31sq98/view?usp=sharing) โข [๐ฑ LinkedIn Post](https://www.linkedin.com/posts/mahreen-fathima-anis-5238ba36b_fistal-ai-a-hugging-face-space-by-mcp-1st-birthday-activity-7400939406448074752-SKAV?utm_source=share&utm_medium=member_desktop&rcm=ACoAAFvK0WsBW7LU9mIHS4nf2zGkEQ85Wi322Sg)
</div>
---
## ๐ฏ What is Fistal AI?
Fistal AI is an **autonomous fine-tuning platform** that transforms the complex process of training custom language models into a single-click experience. Simply specify your topic, and Fistal handles everything:
- ๐ค **Synthetic Dataset Generation** - Creates high-quality training data using LLMs
- ๐ **Automatic Data Formatting** - Converts to chat/instruction format
- ๐๏ธ **Serverless Training** - Fine-tunes models on Modal's GPU infrastructure
- ๐ **LLM-as-Judge Evaluation** - Validates model performance
- ๐ค **Hugging Face Deployment** - Publishes your model automatically
**No ML expertise required. No infrastructure setup. Just results.**
---
## โจ Features
### ๐จ **Intuitive Interface**
- Clean Gradio-based web UI hosted on Hugging Face Spaces
- Real-time training progress with educational insights
- Automatic Hugging Face integration with one-click model access
- Direct model upload in native HF format (ready to use immediately)
### โก **Blazing Fast Training**
- **3x faster dataset generation** with parallel API calls (Gemini)
- **2x faster training** with Unsloth optimization and Modal GPU's
- **70% less memory** usage via 4-bit quantization
- Training completes in **10-20 minutes** for 500 samples
### ๐ง **Smart Defaults**
- 4-bit quantization for optimal quality/size balance
- LoRA fine-tuning (updates only 0.1% of parameters)
- Supports 1B-3B parameter models (Qwen, Llama, Gemma, Phi)
- Automatic hyperparameter optimization
- Native HF format upload (no conversion needed)
### ๐ฌ **Quality Assurance**
- LLM-as-judge evaluation system
- Coherence, relevance, and accuracy testing
- Comprehensive evaluation reports
- Real-time monitoring of training metrics
### ๐ **MCP-Powered Workflow**
- Agentic orchestration using Model Context Protocol (MCP)
- 4 specialized MCP tools for end-to-end automation
- Intelligent decision-making throughout the pipeline
- Seamless tool coordination for optimal results
---
## โจ Sponsors:
- **Modal Labs** : Seamless T4 GPU access
- **Gemini API** : Handles majority of LLM tasks including data generation and agentic control
---
## Watch Demo:
*Note: The demo runs only 5 samples for speed, but you can scale it to 2000+ in real use.*
[**Demo Fistal**](https://drive.google.com/file/d/1wXxGDKUfQXmntW3ldhy-rov8Kjs_K3dj/view?usp=sharing)
---
### **How Fistal AI Works Behind the Scenes**
* Fistal AI runs on an **agentic workflow** powered by LangGraph.
* Instead of a fixed script, an **AI agent** decides what step to run next.
* All the actual work (dataset generation, formatting, training, evaluation) is done by **MCP tools**.
* The agent just thinks โ MCP tools do the work โ agent continues automatically.
---
### **The MCP Server**
* Hosts four tools:
* `generate_json_data` โ creates synthetic training data
* `format_json` โ converts it to ChatML format
* `finetune_model` โ runs Unsloth training on Modal
* `llm_as_judge` โ evaluates the trained model
* Each tool is isolated and safe.
* Returns clean, structured results that the agent uses.
---
### **Pipeline Flow (Step-by-Step)**
* **1. Dataset Generation**
Agent calls the tool โ LLMs generate 20โ500 examples in parallel.
* **2. Dataset Formatting**
Agent calls next tool โ raw dataset becomes ChatML/instruction format.
* **3. Fine-Tuning**
Agent launches training on Modal using Unsloth + 4-bit QLoRA.
* **4. Evaluation**
Agent runs LLM-as-judge โ gets coherence/relevance/accuracy/ROUGE/BLEU scores with evaluate library.
* **5. Final Output**
The model and adapters are automatically uploaded to the user's(mahreenfathima) Hugging Face account (based on the HF token provided).
Automatic Evaluation Report generated.
---
#### ๐ ๏ธ **The 4 MCP Tools**
1. **`generate_json_data`**
- **Purpose**: Synthetic dataset generation
- **Input**: Topic, sample count, task type
- **Process**: Parallel API calls to Gemini + Groq with intelligent prompt engineering
- **Output**: JSON dataset with diverse, high-quality examples
- **MCP Role**: Agent invokes this tool first, receives confirmation, then proceeds
2. **`format_json`**
- **Purpose**: Convert raw data to training(ChatML) format
- **Input**: Raw JSON dataset path
- **Process**: Transforms to chat/instruction format optimized for fine-tuning
- **Output**: Formatted dataset ready for training
- **MCP Role**: Agent receives dataset path from previous tool, formats it automatically
3. **`finetune_model`**
- **Purpose**: Execute serverless training
- **Input**: Formatted dataset, model name, hyperparameters
- **Process**: Deploys training job to Modal with Unsloth optimization
- **Output**: Fine-tuned model weights + training metrics
- **MCP Role**: Agent monitors training progress, handles failures, manages GPU resources
- **Internal Functions** (executed within Modal):
- `train_with_modal`: Runs finetuning process with Unsloth and saves model in Volume
- `upload_to_hf_from_volume`: Pushes the trained model weights to Hugging Face Hub repository
4. **`llm_as_judge`**
- **Purpose**: Quality evaluation
- **Input**: Fine-tuned model path, test cases
- **Process**: Generates test prompts, evaluates responses, scores quality
- **Output**: Comprehensive evaluation report with metrics
- **MCP Role**: Final validation step, agent parses results and presents to user
- **Internal Functions** (executed within Modal):
- `evaluate_model`: Runs validation metrics on the fine-tuned model during/after training
#### ๐ง **Fistal's Agentic Approach**
```python
# Agent makes decisions based on context
agent decides: "User wants Python dataset"
โ invokes generate_json_data with optimal parameters
agent observes: "Dataset generated successfully"
โ invokes format_json with received path
agent monitors: "Training at 50%, loss decreasing"
โ continues monitoring, adjusts if needed
agent validates: "Model trained, run evaluation"
โ invokes llm_as_judge for quality check
```
**Benefits**:
- ๐ฏ **Intelligent Decision Making**: Agent chooses best parameters and strategies
- ๐ **Error Recovery**: Automatically retries failed steps with adjusted parameters
- ๐ **Context Awareness**: Each tool receives relevant context from previous steps
- ๐ **Security**: MCP provides secure tool execution
- ๐ง **Modularity**: Tools can be updated independently without breaking the workflow
- ๐ **Scalability**: Easy to add new tools (e.g., hyperparameter tuning, multi-GPU training)
---
## ๐ ๏ธ Tech Stack
<table>
<tr>
<td width="50%">
### Core Technologies
- **[Unsloth](https://github.com/unslothai/unsloth)** - 2x faster training, 70% less VRAM
- **[Modal](https://modal.com)** - Serverless GPU infrastructure
- **[Gradio](https://gradio.app)** - Web interface on HF Spaces
- **[LangGraph](https://github.com/langchain-ai/langgraph)** - Agentic workflow orchestration
- **[MCP](https://modelcontextprotocol.io)** - Tool integration protocol
- **[HUGGING FACE](https://huggingface.co/)** - Uploads model into repository with hf tokens
</td>
<td width="50%">
### AI Models & APIs
- **Gemini Flash 2.0** - Fast dataset generation
- **Groq (Llama 3.1 70B)** - LLM evaluation
- **Hugging Face** - Model hosting & deployment
- **4-bit Quantization** - Optimal quality/size balance
- **Native HF Upload** - No format conversion needed
</td>
</tr>
</table>
---
## ๐ Performance Metrics
| Metric | Value | Details |
|--------|-------|---------|
| **Dataset Generation** | 3x faster | Parallel processing with API keys |
| **Training Speed** | 2x faster | Unsloth optimization |
| **Memory Usage** | -70% | 4-bit quantization |
| **Training Time** | 10-20 min | For 500 samples on T4 GPU |
| **Model Size** | ~1-2 GB | Native HF format (safetensors) |
| **Parameters Updated** | 0.1% | LoRA efficiency |
| **MCP Tools** | 4 | Autonomous workflow management |
---
## ๐ง Supported Models & Tasks
### Prominent Models (1B-3B Parameters)
- `Qwen/Qwen2.5-1.5B-Instruct`
- `Qwen/Qwen2.5-3B-Instruct`
- `meta-llama/Llama-3.2-1B-Instruct`
- `meta-llama/Llama-3.2-3B-Instruct`
- `google/gemma-2-2b-it`
- `microsoft/Phi-3.5-mini-instruct`
### Popular Task Types
- **text-generation**: General text completion and content creation
- **question-answering**: Q&A pairs and knowledge retrieval
### Output Format
- **Native Hugging Face format** (safetensors + adapter weights)
- Immediately usable with transformers library
- Compatible with HF Inference API
---
## ๐ฎ Try It Now
<div align="center">
### ๐ **[Launch Fistal AI Demo](https://drive.google.com/file/d/1-Uf2-k-gJsIozg-YX0oo_qWjeS31sq98/view?usp=sharing)**
### ๐ฑ **[Read LinkedIn Post](https://www.linkedin.com/posts/mahreen-fathima-anis-5238ba36b_fistal-ai-a-hugging-face-space-by-mcp-1st-birthday-activity-7400939406448074752-SKAV?utm_source=share&utm_medium=member_desktop&rcm=ACoAAFvK0WsBW7LU9mIHS4nf2zGkEQ85Wi322Sg)**
**Hosted on Hugging Face Spaces - No installation required!**
</div>
---
## ๐ License
This project is licensed under the APACHE License - see the [LICENSE](LICENSE) file for details.
---
## ๐ Acknowledgments
- **[Anthropic MCP](https://modelcontextprotocol.io)** - For the powerful tool integration protocol
- **[Unsloth](https://github.com/unslothai/unsloth)** - For making fine-tuning accessible and fast
- **[Modal](https://modal.com)** - For serverless GPU infrastructure
- **[Hugging Face](https://huggingface.co)** - For model hosting and Spaces platform
- **[Google Gemini](https://ai.google.dev/)** - For powerful API access
- **[LangGraph](https://github.com/langchain-ai/langgraph)** - For agentic orchestration framework
- **[Gradio](https://gradio.app)** - For building the interactive UI effortlessly
---
<div align="center">
**Powered by MCP โข Unsloth โข Modal โข Hugging Face โข Gemini API**
โค๏ธ Like our space our HuggingFace โข ๐ Try the demo โข ๐ฑ Share on LinkedIn
</div>
|