YAML in.
Fine-tuned model out.
ForgeLM is the config-driven LLM fine-tuning toolkit for teams that ship into regulated environments.
Your first run
A starter config and sample data. Yours to inspect, edit, and train.
$ python3 -m pip install forgelm
$ forgelm quickstart customer-support \ --output configs/support.yaml --dry-run
Review configs/support.yaml and replace the sample data with your own. Training downloads the selected model and needs suitable hardware.
$ forgelm --config configs/support.yaml
Steps 1–2 need no GPU and do not start training.
Six post-training paradigms behind one declarative interface.
Supervised fine-tuning on instruction pairs
Direct Preference Optimization on chosen/rejected pairs
Reference-free preference learning, lower memory
Kahneman-Tversky on binary feedback signals
Odds Ratio Preference Optimization, single pass
Group Relative Policy Optimization for reasoning RL
Three things separate ForgeLM from notebook-first frameworks.
Your run is a YAML file under version control.
Every run emits an Annex IV artifact.
When a benchmark drops below the floor, ForgeLM discards the trained artefacts and exits non-zero so CI gates fail loudly.
From data ingestion through evaluation to deployment artifacts.
PDF, DOCX, EPUB, TXT, Markdown → SFT-ready JSONL.
PII, secrets, leakage, language detect, near-duplicates.
4-bit NF4 quantization with PEFT adapters.
Llama Guard verdicts across S1–S14 harm categories.
Plug-in lm-evaluation-harness tasks.
DeepSpeed ZeRO-2 / ZeRO-3 (bring your own JSON; the preset names need a source checkout), FSDP, multi-GPU configs. MoE support (Qwen3, Mixtral, DeepSeek).
Pre-flight memory estimator.
Streaming REPL with /reset, /save, /temperature, /system commands. Per-response Llama Guard routing is planned for an upcoming Pro CLI release.
GGUF export (f16 and q8_0 in one step; K-quants need llama.cpp's llama-quantize) with a SHA-256 sidecar. Generate Ollama / vLLM / TGI / HF-Endpoints deployment configs in one command.
Use from forgelm import … to embed ForgeTrainer, audit_dataset, verify_audit_log, and verify_annex_iv_artifact calls inside your own Python pipelines.
Audit-trail, change-management, data-lineage, and supply-chain evidence the deployer's auditor asks for. Software is aligned, not certified.
forgelm reverse-pii finds the lines that contain an identifier you supply (an input to an Article 15 response); forgelm purge deletes rows by id from training corpora (one step of an Article 17 erasure; trained weights are not changed). Both are recorded in the audit log.
A SFT → DPO run with safety eval, benchmark gate, and Annex IV export.
model: name_or_path: "Qwen/Qwen2.5-7B-Instruct" load_in_4bit: true max_length: 4096 lora: r: 16 alpha: 32 method: "dora" # lora / DoRA / PiSSA / rsLoRA data: dataset_name_or_path: "data/policies.jsonl" training: trainer_type: "sft" # sft / dpo / simpo / kto / orpo / grpo num_train_epochs: 3 per_device_train_batch_size: 2 learning_rate: 2.0e-5 output_dir: "./checkpoints/policy-bot" evaluation: benchmark: enabled: true tasks: ["hellaswag", "arc_easy", "truthfulqa"] min_score: 0.65 # aggregate floor; with evaluation.auto_revert: true, below this the run exits 3 safety: enabled: true classifier: "meta-llama/Llama-Guard-3-8B" severity_thresholds: { critical: 0.0, high: 0.01 } require_human_approval: true # Article 14 oversight gate compliance: provider_name: "Acme Inc." risk_classification: "limited-risk" webhook: url: "${SLACK_WEBHOOK}"
$ forgelm --config configs/policy-bot.yaml --dry-run # validate $ forgelm --config configs/policy-bot.yaml --fit-check # VRAM check $ forgelm --config configs/policy-bot.yaml # run
Drop your regulatory corpus into forgelm ingest, audit it, and SFT a model that answers in your domain's voice — with common PII formats masked at ingest (opt in with --pii-mask), before training.
SFT on past tickets, DPO on agent feedback.
forgelm quickstart customer-supportMulti-dataset mix (your repo + open code) with SFT (ORPO is a follow-up step you can chain), GGUF export for local inference. Synthetic data pipeline distils a teacher into your student.
forgelm quickstart code-assistantBuilt-in shaping rewards or your own reward function.
forgelm quickstart grpo-mathStart with the first pull request guide and an unassigned good first issue. Documentation, translations, tests, and small fixes all help.
Pick a template, point it at your data, watch the audit report go green.