ForgeLLM
ForgeLLM is a comprehensive platform for continued pre-training and instruction fine-tuning of large language models using MLX on Apple Silicon.
What ForgeLLM Does
- 🚀 Train: Continued pre-training (CPT) via web interface (IFT coming soon - see Development Perspectives)
- 📊 Monitor: Real-time training dashboards and checkpoint management
- 🆚 Compare: Enable comparison of multiple training sessions with validation loss, perplexity, stability and generalization gap
- 🔗 Fuse: Merge LoRA/DoRA adapters with base models for deployment
- ⚡ Quantize: Convert models to 8-bit or 4-bit precision for efficient deployment
- 💬 Chat & Test: Interactive chat with models and adapters via CLI or web
- 📦 Publish: Convert and publish trained models with comprehensive documentation
Screenshots
Training:
Monitoring:
Compare:
Testing:
Quick Start
1. Installation
Option A: Install from PyPI (Recommended)
# Install latest version
pip install forgellm
# Install specific version
pip install forgellm==0.4.7
# Upgrade existing installation
pip install --upgrade forgellm
Option B: Install from Source (Development)
git clone https://github.com/lpalbou/forgellm.git
cd forgellm
pip install -e .
Requirements: Python 3.9+ and Apple Silicon Mac (M1/M2/M3/M4). All dependencies including MLX are installed automatically.
2. Download Models
# Install HuggingFace CLI
pip install huggingface_hub
# Download a model (examples)
huggingface-cli download mlx-community/gemma-3-1b-it-bf16 # Small model
huggingface-cli download mlx-community/Qwen3-4B-bf16 # Medium model
3. Start ForgeLLM
# Start both servers (recommended)
forgellm start
# Opens web interface at http://localhost:5002
# Model server runs at http://localhost:5001
That's it! 🎉
Usage
Web Interface (Recommended)
The web interface provides everything you need:
forgellm start # Start both servers
# or
forgellm web --port 5002 # Web interface only
forgellm server --port 5001 # Model server only (separate terminal)
Web Interface Features:
- Training Tab: Configure and start CPT training (IFT support coming soon)
- Monitoring Tab: View training progress and dashboards
- Testing Tab: Chat with models and test different prompts
Command Line Interface
The CLI is perfect for quick model testing and interactive chat:
# Interactive chat with a model (REPL mode)
forgellm cli generate --model mlx-community/gemma-3-1b-it-bf16
# Single prompt test
forgellm cli generate --model mlx-community/gemma-3-1b-it-bf16 --prompt "Hello, how are you?"
# Get model architecture info
forgellm cli info --model mlx-community/gemma-3-1b-it-bf16
# Test with an adapter (your trained model)
forgellm cli generate --model mlx-community/Qwen3-4B-bf16 --adapter-path models/cpt/my_trained_model
REPL Mode Commands:
- Type normally to chat
/help- Show available commands/qor/exit- Quit/stats- Show session statistics/system [prompt]- Set/show system prompt
Model Downloads
ForgeLLM works with MLX-compatible models from HuggingFace. All models are cached locally in ~/.cache/huggingface/hub/.
Recommended Models
Small Models (1-2B) - Good for testing:
huggingface-cli download mlx-community/gemma-3-1b-it-bf16
huggingface-cli download mlx-community/gemma-3-1b-pt-bf16
Medium Models (3-4B) - Good balance:
huggingface-cli download mlx-community/Qwen3-4B-bf16
huggingface-cli download mlx-community/gemma-3-4b-it-bf16
Large Models (7-8B) - Best quality:
huggingface-cli download mlx-community/Qwen3-8B-bf16
huggingface-cli download mlx-community/Meta-Llama-3.1-8B-Instruct-bf16
Model Types
- Base Models (
-bf16,-pt-): Ideal for continued pre-training, clean slate for domain adaptation - Instruct Models (
-it-,-Instruct-): Can also be used for continued pre-training with careful data mixing - Quantized Models (
-4bit,-8bit): Smaller memory usage, slightly lower quality
Continued Pre-training: Base vs Instruct Models
Base Models (Recommended for CPT):
- ✅ No instruction-following capabilities to preserve
- ✅ Clean foundation for domain-specific knowledge
- ✅ Higher learning rates and longer training possible
Instruct Models (Advanced CPT):
- ✅ Better at learning from complex documents (recent research)
- ⚠️ Requires careful data mixing (1-5% original pretraining data)
- ⚠️ Lower learning rates to prevent catastrophic forgetting
- ⚠️ Shorter training to avoid losing instruction-following abilities
Choose base models for straightforward domain adaptation, instruct models when you need better knowledge absorption from complex documents.
📖 For detailed CPT best practices and latest research findings, see docs/cpt.md
Training Your Own Models
Continued Pre-Training (CPT) - Available Now
- Prepare Data: Place text files in
dataset/directory - Start Web Interface:
forgellm start - Training Tab: Configure model, data, and parameters
- Monitor: Watch progress in real-time
- Publish: Convert best checkpoints to full models
Training is currently only available through the web interface.
Instruction Fine-Tuning (IFT) - Coming Soon
IFT capabilities are currently in development. For technical details and implementation roadmap, see Development Perspectives.
Directory Structure
forgellm/
├── dataset/ # Your training data (text files)
├── models/ # Trained model outputs
│ ├── cpt/ # Continued pre-training models
│ └── ift/ # Instruction fine-tuning models (coming soon)
└── data/ # Processed training data
Commands Reference
Main Commands
forgellm start # Start both servers (recommended)
forgellm web [--port 5002] # Web interface only
forgellm server [--port 5001] # Model server only
forgellm cli <command> # Command-line operations
CLI Commands
# Interactive chat (REPL mode)
forgellm cli generate --model <model>
# Single prompt
forgellm cli generate --model <model> --prompt "Your question"
# Model information
forgellm cli info --model <model>
# Test with adapter
forgellm cli generate --model <model> --adapter-path <path>
Requirements
- Hardware: Apple Silicon Mac (M1/M2/M3/M4)
- Memory: 16GB+ RAM recommended
- Storage: 5-20GB per model
- Python: 3.9+
- MLX: Automatically installed
Architecture
ForgeLLM uses a clean separation:
- Model Server (
forgellm server): Handles model loading and inference - Web Server (
forgellm web): Provides UI and training coordination - CLI (
forgellm cli): Direct model interaction and testing
This allows you to use just the CLI for testing, or the full web interface for training.
Documentation
📚 Comprehensive Guides
- Getting Started: Complete setup and first training session
- Architecture: System design and component overview
- Data Flow: How data moves through the system
- API Reference: Complete REST API and CLI documentation
- CPT Best Practices: Advanced continued pre-training techniques
- Development Perspectives: Current capabilities and IFT roadmap
🔧 Technical Documentation
- Architecture: Multi-process design with model server separation
- Training Pipeline: Real-time monitoring with automatic checkpoint management
- Model Publishing: LoRA to full model conversion with comprehensive documentation
- Error Recovery: Robust error handling and automatic recovery mechanisms
Contributing
Contributions welcome! Please submit pull requests.
License
MIT License - see LICENSE file.
Acknowledgments
Metadata
Release files for forgellm 0.4.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| forgellm-0.4.7.tar.gz | 288.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| forgellm-0.4.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 568.5 kB
Release files / forgellm-0.4.7.tar.gz
| Download URL | forgellm-0.4.7.tar.gz |
|---|---|
| Size | 288.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19dd46fbfb1106fc8cea5f1e71e57911d6390f9ba33cd209c45ca498686d07d9
|
|
BLAKE2b-256 checksum How to use checksums |
ec36822cbe549bcce4d987d2fef31fe07c8281cd0cb54c93c90ee266d07507e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / forgellm-0.4.7-py3-none-any.whl
| Download URL | forgellm-0.4.7-py3-none-any.whl |
|---|---|
| Size | 280.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c04398fb1827b5bb927baf1dd0b7745617d840324c096791877d8a4c0dfcac2
|
|
BLAKE2b-256 checksum How to use checksums |
1615b494d164c4f81d54187fe9191a20118ca02634e2a4d8768db27f730f7cbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|