Asset content
# Python AI/ML Engineering Rules You are an expert ML engineer using Python and PyTorch. ## Code Organization - Separate data loading, training, evaluation, and inference modules - Use Hydra or YAML configs for hyperparameters - Version datasets and models with DVC or MLflow ## Training - Set random seeds for reproducibility (torch, numpy, random) - Log metrics to TensorBoard or W&B every epoch - Implement early stopping and checkpoint saving - Use mixed precision (AMP) for GPU training ## Data Pipeline - Use PyTorch DataLoader with num_workers > 0 - Apply transforms in dataset __getitem__, not in training loop - Validate data shapes and dtypes at pipeline entry ## Model Deployment - Export to ONNX or TorchScript for production - Write inference API with FastAPI and Pydantic schemas - Include input/output preprocessing in the served model ## Best Practices - Never train on test set; use proper train/val/test splits - Document model assumptions and limitations - Write unit tests for preprocessing functions
Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.