Loading repository data…
Loading repository data…
Archimedes1618 / repository
Madlab is an advanced AI development studio designed to streamline the process of dataset management, model training, and evaluation. It combines a robust Node.js/Express backend with a powerful Python-based training engine and a modern React frontend.
Madlab is a self-hosted tool for fine-tuning language models on your own hardware. It handles the annoying parts: dataset formatting, training config, GGUF conversion, and evaluation. Works with any HuggingFace model.
Stack: React frontend + Node.js backend + Python training scripts (PyTorch/Transformers)
# Clone
git clone https://github.com/yourusername/madlab.git
cd madlab
# Backend
cd madlab-backend
npm install
cd trainer && python -m venv venv && venv\Scripts\activate && python setup.py && cd ..
npm run build && npm start
# Frontend (new terminal)
cd madlab-frontend
npm install && npm run dev
Open http://localhost:5173
| Dependency | Version | Notes |
|---|---|---|
| Node.js | 18+ | Backend server |
| Python | 3.10+ | Training scripts |
| CUDA | 11.8+ | Optional, for GPU training |
| LM Studio | Any | Optional, for Magic Import/Judge features |
Hardware:
cd madlab-backend
npm install
Python environment (inside trainer/ folder):
cd trainer
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activate
# For GPU training - first check your CUDA version: nvidia-smi
# Then install PyTorch with matching CUDA in setup.py:
python setup.py
cd ..
Build and run:
npm run build
npm start
Backend runs on http://localhost:8080
cd madlab-frontend
npm install
npm run dev
Frontend runs on http://localhost:5173
Create madlab-backend/.env:
PORT=8080
LM_STUDIO_URL=http://localhost:1234
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
# Optional: Increase timeouts for slower systems (in milliseconds)
# FETCH_TIMEOUT=60000 # Default: 60s - for HuggingFace API calls
# LLM_TIMEOUT=300000 # Default: 5min - for LLM inference calls
Create madlab-frontend/.env:
VITE_API_URL=http://localhost:8080
VITE_WS_URL=ws://localhost:8080/events
TinyLlama/TinyLlama-1.1B-Chat-v1.0) or browse.jsonl filesYour .jsonl files need input and target fields:
{"input": "What is 2+2?", "target": "4"}
{"input": "Capital of France?", "target": "Paris"}
Magic Import tries to auto-convert other formats using an LLM.
If you have LM Studio running locally:
Point LM_STUDIO_URL to your instance (default: http://localhost:1234)
madlab/
├── madlab-backend/
│ ├── src/
│ │ ├── routes/ # API endpoints
│ │ ├── services/ # Training, conversion logic
│ │ ├── utils/ # Security, fetch utilities
│ │ ├── types/ # TypeScript interfaces
│ │ ├── config.ts # Centralized configuration
│ │ └── server.ts # Express server
│ ├── trainer/ # Python scripts
│ │ ├── train.py # Fine-tuning script
│ │ ├── data_tools.py # Dataset utilities
│ │ └── evaluate_gguf.py
│ └── data/ # Datasets stored here
│
├── madlab-frontend/
│ └── src/
│ ├── components/ # React components
│ ├── types.ts # TypeScript interfaces
│ └── App.tsx
Replace the entire content of your madlab-backend/trainer/requirements.txt with this block:
transformers
accelerate
peft
bitsandbytes
scipy
huggingface_hub[hf_xet]
protobuf
sentencepiece
datasets
pandas
mistral-common[image,audio]
matplotlib
# Use custom llama-cpp-python wheel
https://github.com/rookiemann/llama-cpp-python-py314-cuda131-wheel-or-python314-llama-cpp-gpu-wheel/releases/download/v0.3.16-cuda13.1-py3.14/llama_cpp_python-0.3.16-cp314-cp314-win_amd64.whl
# Install gguf directly from llama.cpp repo
https://github.com/ggml-org/llama.cpp/archive/refs/heads/master.zip#subdirectory=gguf-py
nvidia-smi works in terminal - note the CUDA version shownpip uninstall torch torchvision torchaudio -ypip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu130huggingface-cli loginmax_seq_len (default 512).env file (see Configuration section)FETCH_TIMEOUT=120000 for slow HuggingFace API callsLLM_TIMEOUT=600000 for very slow LLM inference.env matches your LM Studio serverPORT in backend .envVITE_API_URL and VITE_WS_URL in frontend .env to match| Endpoint | Method | Description |
|---|---|---|
/health | GET | Server health check |
/datasets | GET | List all datasets |
/datasets/import | POST | Import from HuggingFace |
/datasets/upload | POST | Upload .jsonl file |
/train/start | POST | Start training |
/train/stop | POST | Stop training |
/train/status | GET | Training status |
/train/config | GET/POST | Get/update training config |
/train/artifacts | GET | List model artifacts |
/instillations | GET/POST/PUT/DELETE | Manage instillations |
AGPLv3 - See LICENSE file.
Copyright (C) 2025 David Bentler