Config-driven LLM fine-tuning with safety evaluation, EU AI Act compliance, 6 alignment methods, and one-command bundled quickstart templates.
Project description
ForgeLM
ForgeLM is a config-driven, enterprise-ready LLM fine-tuning toolkit. It supports the full modern post-training stack — from supervised fine-tuning to preference alignment to reasoning RL — with integrated safety evaluation, EU AI Act compliance, and CI/CD-native design.
Features
Training
- 6 Trainer Types: SFT, DPO, SimPO, KTO, ORPO, GRPO — the complete alignment stack
- Unsloth & Transformers: 2-5x faster training with
unslothbackend, or standardtransformers - 4-Bit QLoRA & DoRA: NF4 quantization with LoRA, DoRA, PiSSA, and rsLoRA support
- GaLore: Optimizer-level memory optimization — full-parameter training via gradient low-rank projection (alternative to LoRA)
- Long-Context Training: RoPE scaling, NEFTune noise injection, sliding window attention, sample packing
- Multi-Dataset Training: Mix multiple datasets with configurable ratios
- Synthetic Data Pipeline: Teacher-to-student distillation with
--generate-dataCLI flag - DeepSpeed & FSDP: Multi-GPU distributed training with ZeRO-2/3 presets
- MoE Support: Fine-tune Mixture of Experts models (Qwen3, Mixtral, DeepSeek)
- GPU Cost Estimation: Auto-detection for 18 GPU models with per-run cost tracking
Evaluation & Safety
- Automated Benchmarking: Post-training evaluation via
lm-evaluation-harness - Safety Evaluation: Llama Guard classifier with confidence-weighted scoring, S1-S14 harm categories, severity levels, cross-run trend tracking, and auto-revert
- LLM-as-Judge: API-based (OpenAI) or local model scoring for quality assessment
- Auto-Revert: Automatically discard models that fail loss, benchmark, or safety thresholds
Quickstart Layer (v0.4.5)
- One-Command Templates:
forgelm quickstart customer-support— bundled templates for SFT, code, BYOD domain expert, Turkish medical Q&A, and GRPO math reasoning. Auto-downsizes models on small GPUs. - Conservative Defaults: Every template ships QLoRA 4-bit, rank=8, batch=1, gradient checkpointing on — designed to run on a single 12 GB GPU.
- Wizard Integration:
forgelm --wizardopens with "Start from a template?" — same code paths, same YAML schema as a hand-written config.
Post-Training (v0.4.0)
- Interactive Chat:
forgelm chat ./model— streaming REPL with/reset,/save,/temperature,/systemcommands; optional Llama Guard safety routing - GGUF Export:
forgelm export ./model --quant q4_k_m— wrapsllama-cpp-pythonconverter; 6 quant levels; SHA-256 appended to integrity manifest - Deployment Configs:
forgelm deploy ./model --target ollama|vllm|tgi|hf-endpoints— generates ready-to-use config files; does not start the server - VRAM Fit Check:
forgelm --config my.yaml --fit-check— pre-flight memory estimator;FITS / TIGHT / OOM / UNKNOWNverdict with recommendations
Enterprise & MLOps
- Config-Driven: Declarative YAML — built for CI/CD pipelines, not notebooks
- EU AI Act Compliance: Auto-generated audit trails, data provenance (SHA-256), training manifests
- Docker: Official Dockerfile and docker-compose for portable deployment
- Offline / Air-Gapped: Full operation without internet for regulated industries
- JSON Output: Machine-readable results with
--output-format jsonfor pipeline integration - Webhook Notifications: Slack/Teams alerts on training start, success, or failure
- W&B / MLflow / TensorBoard: Flexible experiment tracking via
report_to - Model Card Generation: Auto-generated HF-compatible model cards with metrics and benchmarks
- Model Merging: TIES, DARE, SLERP, linear merge of multiple adapters via
--merge
Quick Start
# Install
pip install -e .
pip install -e ".[export]" # GGUF export (optional, non-Windows)
# Fastest path: pick a bundled template (v0.4.5+)
forgelm quickstart --list
forgelm quickstart customer-support # render config + train + chat
forgelm quickstart code-assistant --dry-run # render config only
forgelm quickstart medical-qa-tr --model your-org/your-model # override
# Or generate config interactively
forgelm --wizard
# Validate without training
forgelm --config my_config.yaml --dry-run
# Check VRAM before a long run
forgelm --config my_config.yaml --fit-check
# Train
forgelm --config my_config.yaml
# After training: chat, export, deploy
forgelm chat ./checkpoints/final_model
forgelm export ./checkpoints/final_model --output model.gguf --quant q4_k_m
forgelm deploy ./checkpoints/final_model --target ollama --output ./Modelfile
See the Quick Start Guide for a complete walkthrough.
Guides
| Guide | Description |
|---|---|
| Quick Start | First fine-tuned model in 5 minutes |
| Alignment (DPO/SimPO/KTO/GRPO) | Complete post-training stack |
| CI/CD Pipeline Integration | GitHub Actions, GitLab CI, Docker |
| Enterprise Deployment | Docker, air-gapped, multi-GPU |
| Safety & Compliance | EU AI Act, safety evaluation |
| Distributed Training | DeepSpeed ZeRO, FSDP, multi-node |
| Troubleshooting & FAQ | Common issues and solutions |
Reference Documentation
- Architecture Overview (Türkçe)
- Configuration Guide (Türkçe)
- Usage & Execution (Türkçe)
- Data Preparation Format (Türkçe)
- Product Strategy (Türkçe)
- Roadmap (Türkçe)
Notebooks
- Quick Start — SFT Fine-Tuning
- DPO Preference Alignment
- KTO Binary Feedback
- GRPO Reasoning RL
- Multi-Dataset Training
Installation
# From PyPI
pip install forgelm
# Or from source
git clone https://github.com/cemililik/ForgeLM.git
cd ForgeLM
pip install -e .
Optional Dependencies
pip install -e ".[qlora]" # 4-bit quantization (Linux)
pip install -e ".[unsloth]" # Unsloth backend (Linux)
pip install -e ".[eval]" # lm-evaluation-harness benchmarks
pip install -e ".[tracking]" # W&B experiment tracking
pip install -e ".[distributed]" # DeepSpeed multi-GPU
pip install -e ".[merging]" # mergekit model merging
pip install -e ".[dev]" # pytest, ruff (development)
Docker
# Build (with benchmarking support)
docker build -t forgelm --build-arg INSTALL_EVAL=true .
# Train
docker run --gpus all \
-v $(pwd)/my_config.yaml:/workspace/config.yaml \
-v $(pwd)/output:/workspace/output \
forgelm --config /workspace/config.yaml
# Multi-GPU
docker run --gpus all --shm-size=16g \
forgelm:latest \
torchrun --nproc_per_node=4 -m forgelm.cli --config /workspace/config.yaml
CLI
forgelm --config job.yaml # Train
forgelm --config job.yaml --dry-run # Validate config
forgelm --config job.yaml --output-format json # JSON output for CI/CD
forgelm --config job.yaml --resume # Resume from checkpoint
forgelm --config job.yaml --offline # Air-gapped mode
forgelm --config job.yaml -q # Quiet mode (warnings only)
forgelm --config job.yaml --benchmark-only /path/to/model # Evaluate only
forgelm --config job.yaml --merge # Merge models
forgelm --config job.yaml --compliance-export ./audit/ # Export audit artifacts
forgelm --wizard # Interactive config generator
forgelm --version # Show version
Project Structure
forgelm/
├── cli.py # CLI with 10+ modes (train, dry-run, merge, benchmark, wizard...)
├── config.py # Pydantic config (19 models: training, evaluation, distributed...)
├── data.py # Dataset loading (SFT, DPO, KTO, GRPO formats + multi-dataset)
├── model.py # Model loading (transformers, unsloth, MoE, PEFT)
├── trainer.py # Training orchestration (6 trainer types via TRL, GaLore, long-context)
├── inference.py # Shared inference primitives (load, generate, stream, adaptive sampling)
├── chat.py # Interactive terminal REPL with streaming and slash commands
├── export.py # GGUF export via llama-cpp-python
├── fit_check.py # Pre-flight VRAM estimator (FITS / TIGHT / OOM / UNKNOWN)
├── deploy.py # Deployment config generator (Ollama, vLLM, TGI, HF Endpoints)
├── results.py # TrainResult dataclass
├── benchmark.py # lm-evaluation-harness integration
├── safety.py # Post-training safety evaluation (Llama Guard)
├── judge.py # LLM-as-Judge evaluation (API + local)
├── compliance.py # EU AI Act compliance export & data provenance
├── model_card.py # Auto-generated HF model cards
├── merging.py # Model merging (TIES, DARE, SLERP, linear)
├── synthetic.py # Synthetic data generation (teacher→student distillation)
├── wizard.py # Interactive configuration wizard
├── webhook.py # Slack/Teams webhook notifications
└── utils.py # Authentication & checkpoint management
configs/deepspeed/ # ZeRO-2, ZeRO-3, ZeRO-3+Offload presets
notebooks/ # Colab-ready Jupyter notebooks
tests/ # 430 passed (+34 skipped) across 30 test files
docs/guides/ # Quickstart, alignment, CI/CD, enterprise, safety guides
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file forgelm-0.4.5.tar.gz.
File metadata
- Download URL: forgelm-0.4.5.tar.gz
- Upload date:
- Size: 232.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3a3b95c76dbb27e6e3071fa65c285d32d905a388dade361d307e6697383312a
|
|
| MD5 |
7ebdb26223a4160883c9f3fc1728f729
|
|
| BLAKE2b-256 |
157cc3b67eb97338bafefe37fe3d9d84672d8b6fc0b004e8b69a6535ac43e264
|
Provenance
The following attestation bundles were made for forgelm-0.4.5.tar.gz:
Publisher:
publish.yml on cemililik/ForgeLM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
forgelm-0.4.5.tar.gz -
Subject digest:
b3a3b95c76dbb27e6e3071fa65c285d32d905a388dade361d307e6697383312a - Sigstore transparency entry: 1391684884
- Sigstore integration time:
-
Permalink:
cemililik/ForgeLM@45713dc83322f074e0731f7a15b6509484f796a6 -
Branch / Tag:
refs/tags/v0.4.5 - Owner: https://github.com/cemililik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@45713dc83322f074e0731f7a15b6509484f796a6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file forgelm-0.4.5-py3-none-any.whl.
File metadata
- Download URL: forgelm-0.4.5-py3-none-any.whl
- Upload date:
- Size: 157.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1c60ef032c7263e26aa1eec611dcd004530b5256632412bf49e63302bce37a0
|
|
| MD5 |
e460cfeb29c85b6acacdb8545c4f1100
|
|
| BLAKE2b-256 |
de5510ad81160f70335659faa044172d29f9b118cbe1c5c1a1e619af74c561eb
|
Provenance
The following attestation bundles were made for forgelm-0.4.5-py3-none-any.whl:
Publisher:
publish.yml on cemililik/ForgeLM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
forgelm-0.4.5-py3-none-any.whl -
Subject digest:
c1c60ef032c7263e26aa1eec611dcd004530b5256632412bf49e63302bce37a0 - Sigstore transparency entry: 1391684885
- Sigstore integration time:
-
Permalink:
cemililik/ForgeLM@45713dc83322f074e0731f7a15b6509484f796a6 -
Branch / Tag:
refs/tags/v0.4.5 - Owner: https://github.com/cemililik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@45713dc83322f074e0731f7a15b6509484f796a6 -
Trigger Event:
release
-
Statement type: