skills/nlp/dynamic-batch-padding/SKILL.md
Pads each batch to its actual max sequence length instead of the global max_len, reducing wasted computation.
npx skillsauth add wenmin-wu/ds-skills nlp-dynamic-batch-paddingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Standard padding pads all sequences to max_len (e.g., 512 or 1024). Dynamic batch padding pads only to the longest sequence in each batch, saving significant GPU memory and computation — especially when most sequences are much shorter than the limit.
def collate_fn(batch):
"""Custom collator that trims padding to batch max length."""
inputs = default_collate(batch)
max_len = int(inputs["attention_mask"].sum(dim=1).max())
for key in ["input_ids", "attention_mask", "token_type_ids"]:
if key in inputs:
inputs[key] = inputs[key][:, :max_len]
return inputs
max_length (covers longest possible input)data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF