Skip to main content

A comprehensive toolkit for end-to-end continued pre-training, fine-tuning, monitoring, testing and publishing of language models with MLX-LM

Project description

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: Training

Monitoring: Monitoring

Compare: Compare

Testing: 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
  • /q or /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

  1. Prepare Data: Place text files in dataset/ directory
  2. Start Web Interface: forgellm start
  3. Training Tab: Configure model, data, and parameters
  4. Monitor: Watch progress in real-time
  5. 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

🔧 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

  • ForgeLLM Team: Continued pre-training platform
  • MLX-LM: Apple's MLX framework for LLMs
  • MLX: Apple's machine learning framework

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forgellm-0.4.7.tar.gz (288.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forgellm-0.4.7-py3-none-any.whl (280.5 kB view details)

Uploaded Python 3

File details

Details for the file forgellm-0.4.7.tar.gz.

File metadata

  • Download URL: forgellm-0.4.7.tar.gz
  • Upload date:
  • Size: 288.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for forgellm-0.4.7.tar.gz
Algorithm Hash digest
SHA256 19dd46fbfb1106fc8cea5f1e71e57911d6390f9ba33cd209c45ca498686d07d9
MD5 12f790a99f3d48c748f94202da74dc5f
BLAKE2b-256 ec36822cbe549bcce4d987d2fef31fe07c8281cd0cb54c93c90ee266d07507e5

See more details on using hashes here.

File details

Details for the file forgellm-0.4.7-py3-none-any.whl.

File metadata

  • Download URL: forgellm-0.4.7-py3-none-any.whl
  • Upload date:
  • Size: 280.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for forgellm-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6c04398fb1827b5bb927baf1dd0b7745617d840324c096791877d8a4c0dfcac2
MD5 dc8f24591bd14cf35cb76859dcf27188
BLAKE2b-256 1615b494d164c4f81d54187fe9191a20118ca02634e2a4d8768db27f730f7cbc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page