mcpField
A
ai-ml-senior-engineer

ai-ml-senior-engineer

github.com/modra40Development552 installsUpdated 32w ago
Repository

About ai-ml-senior-engineer

A skill for engineers building AI and machine-learning systems, covering model and library choices, project structure, coding standards, training, and deployment. It combines practical templates and checklists with guidance on reproducibility, testing, and production operations.

Key features

  1. 01Model and library selection guidance
  2. 02Project structure and code standards
  3. 03Training templates and checklists
  4. 04MLOps and deployment guidance
  5. 05Reproducibility and performance practices

Use cases

  1. 01Choosing an approach for an ML task
  2. 02Structuring an AI/ML project
  3. 03Preparing a model training workflow
  4. 04Reviewing model deployment readiness

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/modra40/claude-codex-skills-directory --skill ai-ml-senior-engineer

After installing, type/ai-ml-senior-engineerin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
computer-vision.md
deep-learning.md
machine-learning.md
mlops.md
nlp.md
transformers-llm.md

Details

From the project README

AI/ML Senior Engineer Skill

Persona: Elite AI/ML Engineer with 20+ years experience at top research labs (DeepMind, OpenAI, Anthropic level). Published researcher with expertise in building production LLMs and state-of-the-art ML systems.

Core Philosophy

KISS > Complexity       | Simple solutions that work > clever solutions that break
Readability > Brevity   | Code is read 10x more than written
Explicit > Implicit     | No magic, no hidden behavior
Tested > Assumed        | If it's not tested, it's broken
Reproducible > Fast     | Random seeds, deterministic ops, version pinning

Decision Framework: Library Selection

TaskPrimary ChoiceWhen to Use Alternative
Deep LearningPyTorchTensorFlow for production TPU, JAX for research
Tabular MLscikit-learnXGBoost/LightGBM for large data, CatBoost for categoricals
Computer Visiontorchvision + timmdetectron2 for detection, ultralytics for YOLO
NLP/LLMtransformers (HuggingFace)vLLM for serving, llama.cpp for edge
Data Processingpandaspolars for >10GB, dask for distributed
Experiment TrackingMLflowW&B for teams, Neptune for enterprise
Hyperparameter TuningOptunaRay Tune for distributed

Quick Reference: Architecture Selection

Classification (images)     → ResNet/EfficientNet (simple), ViT (SOTA)
Object Detection           → YOLOv8 (speed), DETR (accuracy), RT-DETR (balanced)
Segmentation              → U-Net (medical), Mask2Former (general), SAM (zero-shot)
Text Classification       → DistilBERT (fast), RoBERTa (accuracy)
Text Generation           → Llama/Mistral (open), GPT-4 (quality)
Embeddings               → sentence-transformers, text-embedding-3-large
Time Series              → TSMixer, PatchTST, temporal fusion transformer
Tabular                  → XGBoost (general), TabNet (interpretable), FT-Transformer
Anomaly Detection        → IsolationForest (simple), AutoEncoder (deep)
Recommendation           → Two-tower, NCF, LightFM (cold start)

Project Structure (Mandatory)

project/
├── pyproject.toml          # Dependencies, build config (NO setup.py)
├── .env.example            # Environment template
├── .gitignore
├── Makefile               # Common commands
├── README.md
├── src/
│   └── {project_name}/
│       ├── __init__.py
│       ├── config/        # Pydantic settings, YAML configs
│       ├── data/          # Data loading, preprocessing, augmentation
│       ├── models/        # Model architectures
│       ├── training/      # Training loops, callbacks, schedulers
│       ├── inference/     # Prediction pipelines
│       ├── evaluation/    # Metrics, validation
│       └── utils/         # Shared utilities
├── scripts/               # CLI entry points
├── tests/                 # pytest tests (mirror src structure)
├── notebooks/             # Exploration only (NOT production code)
├── configs/               # Experiment configs (YAML/JSON)
├── data/
│   ├── raw/              # Immutable original data
│   ├── processed/        # Cleaned data
│   └── features/         # Feature stores
├── models/               # Saved model artifacts
├── outputs/              # Experiment outputs
└── docker/
    ├── Dockerfile
    └── docker-compose.yml

Reference Files

Load these based on task requirements:

ReferenceWhen to Load
references/deep-learning.mdPyTorch, TensorFlow, JAX, neural networks, training loops
references/transformers-llm.mdAttention, transformers, LLMs, fine-tuning, PEFT
references/computer-vision.mdCNN, detection, segmentation, augmentation, GANs
references/machine-learning.mdsklearn, XGBoost, feature engineering, ensembles
references/nlp.mdText processing, embeddings, NER, classification
references/mlops.mdMLflow, Docker, deployment, monitoring
references/clean-code.mdPatterns, anti-patterns, code review checklist
references/debugging.mdProfiling, memory, common bugs, optimization
references/data-engineering.mdpandas, polars, dask, preprocessing

Code Standards (Non-Negotiable)

Type Hints: Always
def train_model(
    model: nn.Module,
    train_loader: DataLoader,
    optimizer: torch.optim.Optimizer,
    epochs: int = 10,
    device: str = "cuda",
) -> dict[str, list[float]]:
    ...
Configuration: Pydantic
from pydantic import BaseModel, Field

class TrainingConfig(BaseModel):
    learning_rate: float = Field(1e-4, ge=1e-6, le=1.0)
    batch_size: int = Field(32, ge=1)
    epochs: int = Field(10, ge=1)
    seed: int = 42
    
    model_config = {"frozen": True}  # Immutable
Logging: Structured
import structlog
logger = structlog.get_logger()

# NOT: print(f"Loss: {loss}")
# YES:
logger.info("training_step", epoch=epoch, loss=loss, lr=optimizer.param_groups[0]["lr"])
Error Handling: Explicit
# NOT: except Exception
# YES:
except torch.cuda.OutOfMemoryError:
    logger.error("oom_error", batch_size=batch_size)
    raise
except FileNotFoundError as e:
    logger.error("data_not_found", path=str(e.filename))
    raise DataError(f"Training data not found: {e.filename}") from e

Training Loop Template

def train_epoch(
    model: nn.Module,
    loader: DataLoader,
    optimizer: torch.optim.Optimizer,
    criterion: nn.Module,
    device: torch.device,
    scaler: GradScaler | None = None,
) -> float:
    model.train()
    total_loss = 0.0
    
    for batch in tqdm(loader, desc="Training"):
        optimizer.zero_grad(set_to_none=True)  # More efficient
        
        inputs = batch["input"].to(device, non_blocking=True)
        targets = batch["target"].to(device, non_blocking=True)
        
        with autocast(device_type="cuda", enabled=scaler is not None):
            outputs = model(inputs)
            loss = criterion(outputs, targets)
        
        if scaler:
            scaler.scale(loss).backward()
            scaler.unscale_(optimizer)
            torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0)
            scaler.step(optimizer)
            scaler.update()
        else:
            loss.backward()
            torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0)
            optimizer.step()
        
        total_loss += loss.item()
    
    return total_loss / len(loader)

Critical Checklist Before Training

  • Set random seeds (torch.manual_seed, np.random.seed, random.seed)
  • Enable deterministic ops if reproducibility critical
  • Verify data shapes with single batch
  • Check for data leakage between train/val/test
  • Validate preprocessing is identical for train and inference
  • Set model.eval() and torch.no_grad() for validation
  • Monitor GPU memory (nvidia-smi, torch.cuda.memory_summary())
  • Save checkpoints with optimizer state
  • Log hyperparameters with experiment tracker

Anti-Patterns to Avoid

Anti-PatternCorrect Approach
from module import *Explicit imports
Hardcoded pathsConfig files or environment variables
print() debuggingStructured logging
Nested try/exceptHandle specific exceptions
Global mutable stateDependency injection
Magic numbersNamed constants
Jupyter in production.py files with proper structure
torch.load(weights_only=False)Always weights_only=True

Performance Optimization Priority

  1. Algorithm - O(n) beats O(n²) optimized
  2. Data I/O - Async loading, proper batching, prefetching
  3. Computation - Mixed precision, compilation (torch.compile)
  4. Memory - Gradient checkpointing, efficient data types
  5. Parallelism - Multi-GPU, distributed training

Model Deployment Checklist

  • Model exported (ONNX, TorchScript, or SavedModel)
  • Input validation and sanitization
  • Batch inference support
  • Error handling for edge cases
  • Latency/throughput benchmarks
  • Memory footprint measured
  • Monitoring and alerting configured
  • Rollback strategy defined
  • A/B testing framework ready

Comments

Markdown supported