ml-hyperparameter-tuning
This skill should be used when the user asks to tune hyperparameters, run sweeps, optimize search spaces, or use AutoML. PROACTIVELY activate for: (1) Optuna, Ray Tune, FLAML, AutoGluon, Hyperopt, Nevergrad, KerasTuner, W&B sweeps, (2) grid search, random search, Bayesian optimization, TPE, Gaussian processes, evolutionary search, (3) ASHA, Hyperband, successive halving, multi-fidelity optimization, population-based training, (4) learning-rate finder, batch-size search, early stopping, pruning, (5) reproducible sweep design and experiment analysis. Provides: budget-aware hyperparameter search strategy.
What this skill does
# ML Hyperparameter Tuning
## Overview
Use this skill for designing and running hyperparameter searches. Tuning should improve a valid baseline under a fixed evaluation protocol. Do not tune before data validation, leakage-safe splits, metric selection, reproducible training, and a simple baseline are in place.
## Search Strategy Selection
| Strategy | Use when | Notes |
|---|---|---|
| Manual informed search | Early debugging or very small budgets | Best when guided by learning curves and domain knowledge |
| Grid search | Few categorical/discrete parameters | Wasteful in high dimensions |
| Random search | Strong default for broad spaces | Often beats grid when only some parameters matter |
| Bayesian/TPE | Moderate budgets and expensive trials | Good for structured continuous/discrete spaces |
| Hyperband/ASHA | Many deep-learning trials with early signal | Requires comparable learning curves and sensible early-stopping metric |
| Population-based training | Schedules and nonstationary hyperparameters | More complex; useful for RL and large training budgets |
| AutoML | Need strong baseline or tabular productivity | Validate leakage, explainability, and deployment constraints |
Optuna is a flexible default for Python search. Ray Tune is strong for distributed sweeps, schedulers, and Ray Train integration. FLAML emphasizes cost-effective AutoML. AutoGluon is productive for tabular, multimodal, and time-series baselines. W&B sweeps integrate well with experiment tracking.
## Optuna Objective with Pruning (Python Blueprint)
Optuna allows pruning unpromising trials early in the training loop based on intermediate validation scores.
```python
import optuna
import torch
import torch.nn as nn
import torch.optim as optim
def train_and_validate(config, trial, model, train_loader, val_loader, device):
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=config["lr"])
for epoch in range(10): # 10 Epochs max
model.train()
for inputs, targets in train_loader:
inputs, targets = inputs.to(device), targets.to(device)
optimizer.zero_grad()
outputs = model(inputs)
loss = criterion(outputs, targets)
loss.backward()
optimizer.step()
# Validation epoch
model.eval()
val_loss = 0.0
with torch.no_grad():
for inputs, targets in val_loader:
inputs, targets = inputs.to(device), targets.to(device)
outputs = model(inputs)
val_loss += criterion(outputs, targets).item()
val_loss /= len(val_loader)
# Report intermediate value to Optuna for pruning check
trial.report(val_loss, epoch)
# Handle pruning (stop execution of this trial if criteria are met)
if trial.should_prune():
raise optuna.exceptions.TrialPruned()
return val_loss
def objective(trial: optuna.Trial, model_class, train_loader, val_loader, device):
# Search Space Configuration
config = {
"lr": trial.suggest_float("lr", 1e-5, 1e-2, log=True),
"optimizer": trial.suggest_categorical("optimizer", ["Adam", "SGD", "RMSprop"]),
"batch_size": trial.suggest_categorical("batch_size", [16, 32, 64]),
"dropout_rate": trial.suggest_float("dropout_rate", 0.1, 0.5)
}
model = model_class(dropout_rate=config["dropout_rate"]).to(device)
return train_and_validate(config, trial, model, train_loader, val_loader, device)
# Running the study
# study = optuna.create_study(direction="minimize", pruner=optuna.pruners.MedianPruner())
# study.optimize(lambda t: objective(t, MyModel, train_loader, val_loader, device), n_trials=50)
```
## Search Space Design
Use distributions that reflect scale. Learning rate, weight decay, regularization strength, and tree min child weights usually need log-uniform or categorical log grids. Depth, layers, hidden sizes, batch size, and number of estimators are discrete. Optimizer, scheduler, augmentation policy, model family, and feature set are categorical.
Avoid searching invalid combinations. Encode conditional spaces: `max_depth` only for tree models, LoRA rank only for PEFT, warmup ratio only for scheduled optimizers. Keep the first search broad and shallow; narrow around promising regions.
## Weights & Biases (W&B) Sweep YAML Blueprint (`sweep.yaml`)
W&B Sweeps run hyperparameter searches across multiple distributed agents.
```yaml
program: train.py
method: bayes # Search algorithm: bayes, random, grid
metric:
name: val_loss
goal: minimize
parameters:
learning_rate:
distribution: log_uniform_values
min: 1e-5
max: 1e-2
batch_size:
values: [16, 32, 64]
epochs:
value: 20
dropout:
distribution: uniform
min: 0.1
max: 0.5
optimizer:
values: ["adam", "adamw", "sgd"]
early_terminate:
type: hyperband
min_iter: 3
eta: 2
```
## Ray Tune Distributed Sweeps with ASHA Scheduler
Ray Tune easily distributes sweeps across a cluster, managing hyperparameter tuning at scale.
```python
from ray import tune
from ray.tune.schedulers import ASHAScheduler
def train_fn(config):
# Training routine pulling from config e.g., config["lr"]
for epoch in range(100):
# ... training step ...
val_loss = run_validation()
# Report intermediate score back to Ray
tune.report(loss=val_loss, epoch=epoch)
# Define Async Successive Halving (ASHA) scheduler
asha_scheduler = ASHAScheduler(
time_attr="epoch",
metric="loss",
mode="min",
max_t=100,
grace_period=5,
reduction_factor=2
)
# Run distributed sweep
# analysis = tune.run(
# train_fn,
# resources_per_trial={"cpu": 2, "gpu": 0.5}, # Run two trials per GPU
# config={
# "lr": tune.loguniform(1e-5, 1e-2),
# "batch_size": tune.choice([16, 32, 64])
# },
# num_samples=30,
# scheduler=asha_scheduler
# )
```
## Parameters Worth Tuning
Deep learning:
- Learning rate, warmup, scheduler, optimizer, weight decay.
- Batch size or effective batch size, gradient accumulation.
- Dropout, label smoothing, augmentation strength.
- Architecture width/depth, sequence length, image resolution.
- Loss parameters, class weights, focal loss gamma.
- PEFT rank/alpha/dropout and target modules for fine-tuning.
Tree/tabular models:
- Learning rate, number of estimators/iterations, max depth/leaves.
- Subsample, column sample, min child samples/weight.
- L1/L2 regularization, min split gain.
- Categorical handling and monotonic constraints where supported.
RAG and embedding systems:
- Chunk size/overlap, embedding model, top-k, hybrid weights, reranker, prompt template, context budget, score thresholds.
## Early Stopping and Pruning
Early stopping prevents wasted compute but can bias toward fast-starting configurations. Use patience and minimum resource thresholds. ASHA and Hyperband need a monotonically meaningful metric and comparable training curves. For noisy metrics, smooth or require multiple evaluations. Always run promising configurations to full budget before final selection.
## Learning-Rate Finder
A learning-rate range test can quickly find a useful LR interval for neural networks. Increase LR over a short run, plot loss, choose a value below divergence and often below the steepest descent point. Re-run proper training afterward; LR finder output is a guide, not a final experiment.
## Reproducibility
Log every trial's parameters, random seed, code version, data version, hardware, dependencies, metric, artifacts, and failure reason. Use deterministic trial IDs. Save top-k configs, not only the best. For distributed sweeps, make sure failed or preempted trials are marked correctly and that resumed trials do not duplicate results.
## Analyzing Results
After a sweep, inspect parameter importance, parallel coordinate plots, metric distributions, and learniRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.