Skip to content
HodeTechPublic

About

Config-driven LLM fine-tuning with safety evaluation, EU AI Act compliance, 6 alignment methods, and one-command bundled quickstart templates.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

0 watching

Forks

Latest commit

 

History

811 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ForgeLM logo

ForgeLM

Fine-tune LLMs. Keep the evidence.
YAML-driven training, evaluation gates, and audit artifacts — from your terminal, Python, or CI.

PyPI version CI on development Tested with Python 3.10–3.13 Code license: Apache 2.0

Website · Quick start · Documentation · Contribute · Türkçe

ForgeLM turns a validated YAML configuration into a fine-tuning run, a saved model, and an audit trail. Start with SFT, use preference or reasoning methods when you need them, and opt into safety evaluation, human approval, and EU AI Act documentation. The same configuration works locally and in a CI/CD pipeline.

Here to contribute? Pick an unassigned good first issue and follow your first pull request. Documentation, Turkish translations, examples, and tests are welcome alongside code.

Why ForgeLM

You need to… ForgeLM provides
Keep training reproducible Validated YAML, model revision pins, and a typed Python API.
Move beyond a single SFT run SFT · DPO · SimPO · KTO · ORPO · GRPO, plus sequential pipelines such as SFT → DPO → GRPO.
Check data before training Dataset audits for PII, secrets, duplicates, leakage, and quality; document-to-JSONL ingestion with masking.
Make promotion conditional Opt-in loss, benchmark, safety, and judge gates; human-approval staging and stable CLI exit codes.
Keep reviewable evidence Hash-chained audit logs, model-integrity manifests, model cards, and optional compliance exports.
Use your own infrastructure LoRA/QLoRA, optional Unsloth and distributed backends, plus export and serving configuration generation.

ForgeLM fine-tunes existing Hugging Face models. Serving is handed off to tools such as Ollama, vLLM, TGI, or llama.cpp. See the architecture for how the pieces fit together. ORPO and SimPO may use experimental TRL APIs; see alignment compatibility.

Try it without a GPU

Use Python 3.10–3.13 in a virtual environment. Install the core package, then generate a starter configuration and a tiny customer-support dataset:

python -m pip install forgelm
python -m forgelm quickstart customer-support --output configs/support.yaml --dry-run

This writes configs/support.yaml, configs/customer-support.jsonl, and a quickstart audit record. The generation step downloads no model and starts no training. Use a fresh output directory when repeating it, so your edited dataset is not overwritten. The bundled data is a demonstration seed, not a production corpus.

Validate the generated YAML and audit the seed dataset:

python -m forgelm --config configs/support.yaml --dry-run
python -m forgelm audit ./configs/customer-support.jsonl

List other templates with python -m forgelm quickstart --list, or generate a configuration interactively with python -m forgelm --wizard. For a recorded CPU walkthrough of configuration validation, dataset auditing, and audit-log verification, see the CPU sample and its limitations.

When you are ready to train

Review the generated model, dataset, and output paths first. The bundled templates enable 4-bit loading: on Linux + CUDA, install the QLoRA extra, estimate memory, and start training explicitly:

python -m pip install "forgelm[qlora]"
python -m forgelm --config configs/support.yaml --fit-check
python -m forgelm --config configs/support.yaml

The memory estimate is guidance, not a guarantee that a run will fit. For Apple Silicon or another unquantized setup, set model.load_in_4bit: false and choose a model that fits your hardware. Intel Macs are unsupported by the required PyTorch versions. See installation and platform support for optional backends and extras.

One configuration, a reviewable workflow

The generated YAML is yours to edit. For example, this standalone SFT configuration uses the seed dataset created above and saves to ./checkpoints/customer-support:

model:
  name_or_path: "Qwen/Qwen2.5-7B-Instruct"
  load_in_4bit: true

data:
  dataset_name_or_path: "./configs/customer-support.jsonl"

training:
  trainer_type: "sft"
  output_dir: "./checkpoints/customer-support"
  num_train_epochs: 3

lora:
  r: 8
  alpha: 16

Configuration keys and cross-field constraints are validated before training. Add safety, compliance, or a multi-stage pipeline when your workflow needs them: configuration reference · alignment methods · pipeline guide.

Data → configure → train → evaluate → review → export. Audit your own corpus before committing GPU time. After training, use python -m forgelm chat ./checkpoints/customer-support/final_model to inspect the result, then follow the post-training examples for export and deployment. K-quant GGUF export also requires a separate llama.cpp quantization step; see the CLI reference.

Evidence and gates

Artifact or control What it does
Saved model and model card Records the trained output and its configuration.
Model-integrity manifest Detects changed, missing, or added files with verify-integrity.
Append-only audit log Records decisions in a hash chain, checked with verify-audit.
Optional evaluation gates Apply configured loss, benchmark, safety, or judge thresholds.
Optional human approval Stages a model for review before promotion; the CLI exits 4.
Optional compliance export Produces Annex IV metadata, data-governance reports, and training provenance.

CLI exit codes let your pipeline distinguish configuration errors (1), runtime errors (2), evaluation failures (3), pending approval (4), wizard cancellation (5), and integrity mismatches (6); success is 0. See the CLI contract.

Safety evaluation, compliance export, human approval, and auto-revert are opt-in. With evaluation.auto_revert: true, a failed evaluation can delete the saved model directory; review the gate behavior before enabling it. Evidence artifacts support a review process; they do not certify model safety or legal compliance. For adversarial tamper-evidence, configure FORGELM_AUDIT_SECRET and protect storage — an unkeyed hash alone is insufficient.

Documentation

Start here Go deeper
Quick start Configuration reference
Dataset auditing Safety and compliance
Document ingestion Enterprise deployment
Python API CI/CD integration
Troubleshooting Public roadmap

Türkçe: Hızlı başlangıç · Yapılandırma · Veri denetimi · Güvenlik ve uyumluluk.

Learn in a notebook: SFT fine-tuning in Colab · GRPO reasoning in Colab · all notebooks. Model access, dependencies, and hardware requirements are documented in each notebook.

Contribute

Help make fine-tuning easier to reproduce and review. You can improve a guide, translate an example, reproduce a bug, add a regression test, or work on a planned feature. Start small; you do not need a GPU to run the unit tests or documentation checks.

  1. Find an unassigned good first issue or browse the project plan.
  2. Follow your first pull request to set up the environment and run the relevant checks.
  3. Open a PR against development and link its issue. Keep English/Turkish documentation mirrors together where they exist.

Report a bug · Suggest a feature · Engineering standards. Report vulnerabilities privately using SECURITY.md.

License

Code: Apache 2.0. Bundled seed datasets: CC-BY-SA 4.0, with attribution and share-alike requirements. Models and datasets you bring retain their respective licenses; review them before training or distributing artifacts.

About

Config-driven LLM fine-tuning with safety evaluation, EU AI Act compliance, 6 alignment methods, and one-command bundled quickstart templates.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages