Any-to-Any
Transformers
Safetensors
English
qwen2
text-generation
qwen
lora
router
multi-agent
orchestration
gradio
multimodal
text
image
video
audio
Eval Results (legacy)
text-generation-inference
Instructions to use Questionmarkboy/frankenstein-3-0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Questionmarkboy/frankenstein-3-0 with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Questionmarkboy/frankenstein-3-0") model = AutoModelForCausalLM.from_pretrained("Questionmarkboy/frankenstein-3-0", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 10,182 Bytes
3a6020f 76aa8a3 b8fc548 76aa8a3 1e15990 d552d29 1e15990 b8fc548 1e15990 3a6020f b8fc548 3a6020f 1e15990 3a6020f 76aa8a3 1e15990 76aa8a3 3a6020f 76aa8a3 1e15990 3a6020f e399bb1 1e15990 3a6020f e399bb1 3a6020f e399bb1 3a6020f e399bb1 3a6020f 1e15990 e399bb1 1e15990 3a6020f 1e15990 76aa8a3 1e15990 | 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 | ---
license: apache-2.0
library_name: transformers
pipeline_tag: any-to-any
base_model: Qwen/Qwen2.5-1.5B-Instruct
language:
- en
metrics:
- accuracy
tags:
- safetensors
- qwen
- lora
- router
- multi-agent
- orchestration
- gradio
- multimodal
- text
- image
- video
- audio
model-index:
- name: RouterBrain
results:
- task:
type: text-classification
name: Intent Routing
dataset:
name: Synthetic Routing Dataset
type: synthetic
args: routing
metrics:
- type: accuracy
value: 60.0
name: Routing Accuracy
verified: false
---
# ๐ง Frankenstein-3.0: The Unified AI Entity
A production-grade **multi-modal** AI orchestration system with a **trained routing brain**, featuring 4 specialist models, 5 integrated tools, and triple-layer fault tolerance.
> **Modality:** Text โ Text โข Image โข Video โข Audio (orchestrated across specialists)
> **Repo weights:** RouterBrain (text router, QLoRA-fine-tuned Qwen2.5-1.5B)
## Architecture Overview
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ USER REQUEST โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LAYER 1: Pre-Flight Regex (100% accurate, hard patterns) โ
โ โข "uploaded file" โ RAG โข "then" โ multi-step chain โ
โ โข "explain how to" โ chat โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ (pass-through)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LAYER 2: RouterBrain (0.3s instant routing) โ
โ โข Qwen2.5-1.5B fine-tuned with QLoRA, merged to fp16 โ
โ โข Outputs JSON routing decisions โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ (if brain fails)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LAYER 3: Qwen3.5-4B Resident (smart fallback) โ
โ โข Understands complex/novel requests โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SPECIALISTS: ๐ง Chat ๐ป Code ๐จ Image ๐ฌ Video โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
## The RouterBrain (This Repo's Weights)
The root weights are the **RouterBrain**: a distilled routing model that reads user requests and outputs JSON routing decisions in ~0.3 seconds.
### Load the RouterBrain
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Questionmarkboy/frankenstein-3.0")
model = AutoModelForCausalLM.from_pretrained(
"Questionmarkboy/frankenstein-3.0",
torch_dtype="float16",
device_map="auto"
)
prompt = "Route to the correct specialist (chat/code/image/video/search/calc/execute/rag). USER: Draw a robot then animate it dancing. Respond ONLY with JSON."
text = tokenizer.apply_chat_template(
[{"role": "user", "content": prompt}],
tokenize=False,
add_generation_prompt=True
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=120, do_sample=False, repetition_penalty=1.05)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```
### Expected Output
```json
{"specialist": "multi", "confidence": 0.95, "reasoning": "Chained multi-step task", "steps": [{"specialist": "image", "prompt": "Draw a robot"}, {"specialist": "video", "prompt": "animate it dancing"}]}
```
## The Full System (app.py)
### Specialists
| Specialist | Model | Use Case |
|------------|-------|----------|
| **Chat** | Qwen3.5-4B | Conversation, reasoning, explanations |
| **Code** | Qwen2.5-Coder-14B | Programming, debugging, code generation |
| **Image** | SDXL | Photorealistic image generation |
| **Video** | MiniMax-H3 NF4 | Video + audio generation |
### Tools
- ๐ **Web Search** โ DuckDuckGo real-time search
- ๐งฎ **Calculator** โ SymPy safe mathematical evaluation
- โก **Code Execution** โ Sandboxed Python execution (5s timeout)
- ๐ **RAG** โ Document upload + keyword search
- ๐ง **Memory** โ SQLite persistent conversation history
## Installation
### Prerequisites
| Requirement | Minimum | Notes |
|-------------|---------|-------|
| Python | 3.10+ | 3.11 recommended |
| pip | latest | upgraded in Step 3 |
| Git + Git-LFS | any | LFS needed for the ~3GB weights |
| RAM | 16 GB | 32 GB recommended |
| GPU (optional) | 8 GB VRAM | 16-24 GB VRAM for image/video specialists |
| CUDA (optional) | 12.1+ | only required for GPU features |
### Step 1 โ Clone the repository
```bash
git lfs install
git clone https://huggingface.co/Questionmarkboy/frankenstein-3.0
cd frankenstein-3.0
```
### Step 2 โ Create a virtual environment (recommended)
```bash
python -m venv venv
source venv/bin/activate # Linux / macOS
venv\Scripts\activate # Windows
```
### Step 3 โ Install dependencies
```bash
pip install --upgrade pip
pip install -r requirements.txt
```
### Step 4 โ Launch the app
```bash
python app.py
```
Then open **http://localhost:7860** in your browser.
### CPU-only machines
Installation is identical. The app auto-detects the absence of CUDA and runs the RouterBrain, chat and code specialists on CPU. Image and video specialists respond with a friendly "GPU required" message instead of crashing.
### Troubleshooting
- **bitsandbytes warnings on CPU** โ expected and safely ignored by the app.
- **Slow clone** โ the RouterBrain weights are ~3 GB; make sure Git-LFS is installed (Step 1).
- **Port 7860 already in use** โ change server_port at the bottom of app.py.
- **Out of memory on GPU** โ the app loads specialists on demand and unloads them after use; close other GPU processes or reduce image resolution in app.py.
## Hardware Requirements
| Mode | Minimum | Recommended |
|------|---------|-------------|
| RouterBrain only | 2GB VRAM | CPU works fine |
| Chat + Code (CPU) | 16GB RAM | 32GB RAM |
| Full GPU stack | 16GB VRAM | 24GB+ VRAM |
The app auto-detects CUDA. On CPU-only machines, chat/code work and image/video return a friendly "GPU required" message.
## Training Details
### RouterBrain Training
- **Base Model**: Qwen2.5-1.5B-Instruct
- **Fine-tuning**: QLoRA (r=32, ฮฑ=64, dropout=0.05)
- **Dataset**: ~10k synthetic routing examples (combinatorial diversity, noise injection, 30+ edge-case patterns)
- **Training**: 2-3 epochs on T4 GPU
- **Merge**: Clean fp16 merge (no quantization rounding)
### Performance Metrics
- **Pre-flight layer**: 100% accuracy on hard patterns
- **RouterBrain**: 60% standalone accuracy on diverse test set
- **Effective routing**: 90%+ via triple-layer fault tolerance
## Multi-Step Task Chaining
```
User: "Draw a robot then animate it dancing"
โ
Pre-flight: detects "then" โ routes to multi specialist
โ
Execution: image specialist โ video specialist (sequential)
โ
Output: generated image + animated video with audio
```
## Architecture Decisions
### Why Triple-Layer Routing?
1. **Speed**: Pre-flight regex is instant (0.001s)
2. **Efficiency**: RouterBrain is fast (0.3s) vs prompt-based (4-6s)
3. **Robustness**: 4B fallback catches edge cases
4. **Production-ready**: Graceful degradation under all conditions
### Why Distill A Routing Brain?
- **20x faster** than prompt-based routing
- **50% less VRAM** than using the 4B resident for routing
- **Perfect JSON** output (trained to only output JSON)
- **Cheaper** to deploy at scale
## Companion Models
- **[Frankenstein-2.0](https://huggingface.co/Questionmarkboy/frankenstein-2.0)** โ Merged Mistral-7B checkpoint
## Technical Stack
- **Framework**: HuggingFace Transformers + Diffusers
- **Quantization**: BitsAndBytes (NF4, 4-bit)
- **UI**: Gradio 4.44
- **Memory**: SQLite
- **Training**: PEFT + LoRA
## Known Limitations
- Image/video generation requires 16GB+ VRAM
- RAG only supports .txt files (no PDF/DOCX yet)
- Web search is basic (DuckDuckGo HTML scraping)
- Code execution has 5s timeout for safety
## Citation
```bibtex
@misc{frankenstein3,
author = {Questionmarkboy},
title = {Frankenstein-3.0: Multi-Modal AI Orchestration System},
year = {2024},
publisher = {HuggingFace},
journal = {HuggingFace Repository},
howpublished = {\url{https://huggingface.co/Questionmarkboy/frankenstein-3.0}}
}
```
## License
Apache 2.0
## Acknowledgments
- Base models: Qwen, Stability AI, MiniMax
- Frameworks: HuggingFace, Gradio, BitsAndBytes
- Training infrastructure: Kaggle T4 GPUs
---
**Built with โค๏ธ for the AI community**
|