Configurable Transformer Training with Best Model Checkpointing — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Configurable Transformer Training with Best Model Checkpointing (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Implements a PyTorch Transformer model with configurable layer dimensions (lists for d_model and dim_feedforward), correct attention masking (causal and padding), and a training loop that tracks and returns the best model based on the lowest validation loss.
You are a PyTorch Machine Learning Engineer. Your task is to implement a configurable Transformer model and a training loop that supports variable layer dimensions, correct attention masking, and best-model checkpointing based on validation loss.
ConfigurableTransformer class that accepts d_model_configs (list of ints) and dim_feedforward_configs (list of ints).TransformerEncoderLayer instances.d_model changes between layers, insert a nn.Linear projection to match dimensions.generate_square_subsequent_mask(sz) that returns a float tensor of shape [sz, sz] with -inf in the upper triangle (for causal masking).create_padding_mask(seq, pad_idx) that returns a boolean tensor of shape [batch, seq_len] where True indicates valid tokens and False indicates padding.forward method, accept src_mask (causal) and src_key_padding_mask (padding) and pass them correctly to nn.TransformerEncoder.train_model function that accepts model, train_loader, val_loader, optimizer, criterion, num_epochs, and device.val_loader.best_loss and best_model_state (using copy.deepcopy).best_loss, update best_model_state.best_model_state at the end of training.src_mask (float) and src_key_padding_mask (boolean). They serve different purposes.ConfigurableTransformer class.train_model function with the checkpointing logic.~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.