training_patterns
This guide provides common training patterns and use cases for TRL on Hugging Face Jobs. Automatic distributed training across multiple GPUs. TRL/Accelerate handles distribution automatically:
Install / Use
npx skills add tharsananarul/portfolioInstalls into whichever agent you are using.
Cursor Rules
Cursor IDE rules (v2)
Quality Score
Category
AutomationSupported Platforms
Tags
Our assessment of training_patterns
training_patterns scores 69/100 on our quality scale, 2667th of 2,873 Automation skills we index.
Its Cursor Rules is 6.0 KB long, well organised into 22 sections with 8 code examples: a thorough specification that gives an agent plenty to work with.
It has no GitHub stars yet, so there is no community track record; judge it on its content.
Maintenance, license and trust
- We could not determine when the repository was last updated.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 68/100, with 3 cautions from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
training_patterns compared with similar skills
All 4 of these similar skills score higher than training_patterns; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| training_patterns (this skill)by tharsananarul | 69 | 0 | — | Cursor Rules |
| Agent-Reachby Panniantong | 100 | 108.0k | 1d ago | CLAUDE.md |
| Scraplingby D4Vinci | 100 | 92.8k | today | MCP Server |
| rufloby ruvnet | 100 | 80.6k | today | MCP Server |
| openclawby thedotmack | 100 | 107.6k | 2d ago | SKILL.md |
Frequently asked questions
- How do I install training_patterns?
- Run
npx skills add tharsananarul/portfolio. The install tabs above show the steps for each supported agent. - Which AI agents does training_patterns work with?
- It is written for Cursor, as a Cursor Rules file. Other agents that read the same format can often use it too.
- Is training_patterns safe to use?
- It declares no license and scores 68/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is training_patterns still maintained?
- We could not determine when the repository was last updated.
Skill content
View source on GitHubCommon Training Patterns
This guide provides common training patterns and use cases for TRL on Hugging Face Jobs.
Multi-GPU Training
Automatic distributed training across multiple GPUs. TRL/Accelerate handles distribution automatically:
hf_jobs("uv", {
"script": """
# Your training script here (same as single GPU)
# No changes needed - Accelerate detects multiple GPUs
""",
"flavor": "a10g-largex2", # 2x A10G GPUs
"timeout": "4h",
"secrets": {"HF_TOKEN": "$HF_TOKEN"}
})
Tips for multi-GPU:
- No code changes needed
- Use
per_device_train_batch_size(per GPU, not total) - Effective batch size =
per_device_train_batch_size×num_gpus×gradient_accumulation_steps - Monitor GPU utilization to ensure both GPUs are being used
DPO Training (Preference Learning)
Train with preference data for alignment:
hf_jobs("uv", {
"script": """
# /// script
# dependencies = ["trl>=0.12.0", "trackio"]
# ///
from datasets import load_dataset
from trl import DPOTrainer, DPOConfig
import trackio
dataset = load_dataset("trl-lib/ultrafeedback_binarized", split="train")
# Create train/eval split
dataset_split = dataset.train_test_split(test_size=0.1, seed=42)
config = DPOConfig(
output_dir="dpo-model",
push_to_hub=True,
hub_model_id="username/dpo-model",
num_train_epochs=1,
beta=0.1, # KL penalty coefficient
eval_strategy="steps",
eval_steps=50,
report_to="trackio",
run_name="baseline_run", # use a meaningful run name
# max_length=1024, # Default - only set if you need different sequence length
)
trainer = DPOTrainer(
model="Qwen/Qwen2.5-0.5B-Instruct", # Use instruct model as base
train_dataset=dataset_split["train"],
eval_dataset=dataset_split["test"], # IMPORTANT: Provide eval_dataset when eval_strategy is enabled
args=config,
)
trainer.train()
trainer.push_to_hub()
trackio.finish()
""",
"flavor": "a10g-large",
"timeout": "3h",
"secrets": {"HF_TOKEN": "$HF_TOKEN"}
})
For DPO documentation: Use hf_doc_fetch("https://huggingface.co/docs/trl/dpo_trainer")
GRPO Training (Online RL)
Group Relative Policy Optimization for online reinforcement learning:
hf_jobs("uv", {
"script": "https://raw.githubusercontent.com/huggingface/trl/main/examples/scripts/grpo.py",
"script_args": [
"--model_name_or_path", "Qwen/Qwen2.5-0.5B-Instruct",
"--dataset_name", "trl-lib/math_shepherd",
"--output_dir", "grpo-model",
"--push_to_hub",
"--hub_model_id", "username/grpo-model"
],
"flavor": "a10g-large",
"timeout": "4h",
"secrets": {"HF_TOKEN": "$HF_TOKEN"}
})
For GRPO documentation: Use hf_doc_fetch("https://huggingface.co/docs/trl/grpo_trainer")
Trackio Configuration
Use sensible defaults for trackio setup. See references/trackio_guide.md for complete documentation including grouping runs for experiments.
Basic Pattern
import trackio
trackio.init(
project="my-training",
run_name="baseline-run", # Descriptive name user will recognize
space_id="username/trackio", # Default space: {username}/trackio
config={
# Keep config minimal - hyperparameters and model/dataset info only
"model": "Qwen/Qwen2.5-0.5B",
"dataset": "trl-lib/Capybara",
"learning_rate": 2e-5,
}
)
# Your training code...
trackio.finish()
Grouping for Experiments (Optional)
When user wants to compare related runs, use the group parameter:
# Hyperparameter sweep
trackio.init(project="hyperparam-sweep", run_name="lr-0.001", group="lr_0.001")
trackio.init(project="hyperparam-sweep", run_name="lr-0.01", group="lr_0.01")
Pattern Selection Guide
| Use Case | Pattern | Hardware | Time |
|----------|---------|----------|------|
| SFT training | scripts/train_sft_example.py | a10g-large | 2-6 hours |
| Large dataset (>10K) | Multi-GPU | a10g-largex2 | 4-12 hours |
| Preference learning | DPO Training | a10g-large | 2-4 hours |
| Online RL | GRPO Training | a10g-large | 3-6 hours |
Critical: Evaluation Dataset Requirements
⚠️ IMPORTANT: If you set eval_strategy="steps" or eval_strategy="epoch", you MUST provide an eval_dataset to the trainer, or the training will hang.
✅ CORRECT - With eval dataset:
dataset_split = dataset.train_test_split(test_size=0.1, seed=42)
trainer = SFTTrainer(
model="Qwen/Qwen2.5-0.5B",
train_dataset=dataset_split["train"],
eval_dataset=dataset_split["test"], # ← MUST provide when eval_strategy is enabled
args=SFTConfig(eval_strategy="steps", ...),
)
❌ WRONG - Will hang:
trainer = SFTTrainer(
model="Qwen/Qwen2.5-0.5B",
train_dataset=dataset,
# NO eval_dataset but eval_strategy="steps" ← WILL HANG
args=SFTConfig(eval_strategy="steps", ...),
)
Option: Disable evaluation if no eval dataset
config = SFTConfig(
eval_strategy="no", # ← Explicitly disable evaluation
# ... other config
)
trainer = SFTTrainer(
model="Qwen/Qwen2.5-0.5B",
train_dataset=dataset,
# No eval_dataset needed
args=config,
)
Best Practices
- Use train/eval splits - Create evaluation split for monitoring progress
- Enable Trackio - Monitor progress in real-time
- Add 20-30% buffer to timeout - Account for loading/saving overhead
- Test with TRL official scripts first - Use maintained examples before custom code
- Always provide eval_dataset - When using eval_strategy, or set to "no"
- Use multi-GPU for large models - 7B+ models benefit significantly
See Also
scripts/train_sft_example.py- Complete SFT template with Trackio and eval splitscripts/train_dpo_example.py- Complete DPO templatescripts/train_grpo_example.py- Complete GRPO templatereferences/hardware_guide.md- Detailed hardware specificationsreferences/training_methods.md- Overview of all TRL training methodsreferences/troubleshooting.md- Common issues and solutions
Related Skills
Agent-Reach
108.0kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
Scrapling
92.8k🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
ruflo
80.6k🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
openclaw
107.6kThis guide walks through setting up the claude-mem plugin on an OpenClaw gateway. By the end, your agents will have persistent memory across sessions via system prompt context injection, and optionally a real-time observation feed streaming to a messaging channel.
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
