cd /news/machine-learning/trainsafe-behavioral-health-checks-f… · home topics machine-learning article
[ARTICLE · art-27101] src=discuss.huggingface.co ↗ pub= topic=machine-learning verified=true sentiment=↑ positive

Trainsafe — behavioral health checks for HuggingFace/TRL fine-tuning

Developer Ammar Hassona released Trainsafe, a TrainerCallback for HuggingFace/TRL that runs behavioral health checks during fine-tuning, catching failures like language drift and output collapse that loss metrics miss. The tool integrates with SFTTrainer, DPOTrainer, GRPOTrainer, and base Trainer, and is available via pip install trainsafe.

read1 min publishedJun 14, 2026

I was fine-tuning an Arabic model using DPO. Loss looked perfect the

entire run. Training finished. It spoke Chinese.

So I built trainsafe — a TrainerCallback that runs behavioral checks

at every eval checkpoint and catches failures that loss never surfaces:

language drift, output collapse, repetition loops, prompt echoing,

format drift.

Two lines to add to any existing training script:

from trainsafe import TrainSafeCallback
trainer = SFTTrainer(..., callbacks=[TrainSafeCallback()])

Works with SFTTrainer, DPOTrainer, GRPOTrainer, and base Trainer.

pip install trainsafe

GitHub: GitHub - AmmarHassona/trainsafe: Behavioral health checks for HuggingFace / TRL fine-tuning. Monitors outputs at each checkpoint and stops training if something goes wrong. · GitHub

Happy to answer questions or if anyone has any comments, it’s still early and feedback is welcome

── more in #machine-learning 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/trainsafe-behavioral…] indexed:0 read:1min 2026-06-14 ·