Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 5 min read How-to mediumAdept

How to train your model dynamically using adversarial data

Dynamic adversarial data collection (DADC) has humans craft inputs that fool a trained model, then retrains the model on those examples over repeated rounds, countering the saturation and blind spots of static benchmarks. A walkthrough applies it to MNIST: a small PyTorch CNN (89% test accuracy after 20 epochs) is deployed in a Hugging Face Space where users draw digits, and a custom flag function saves misclassified samples and retrains once a threshold is reached. Cited work on natural language inference suggests standard data collection wins in the short term while DADC yields higher accuracy over many rounds.

Assumes: PyTorch basicsconvolutional neural networks

Related posts

  • Tuning Image Classifiers using Human-In-The-Loop

    Zalando Engineering hardMaster

    AutoThreshold is an Expectation-Maximization procedure that re-tunes an image classifier's class-confidence threshold when product photos drift out of distribution and no labelled validation set exists. Predictions are sorted by confidence. Each iteration, human annotators label a window of m images centred on the current threshold estimate, starting from 1. The threshold is then re-estimated by maximizing a metric such as f-beta on those annotations, repeating until it converges. For a leopard-print classifier, the estimated threshold lands just before negatives start appearing among positives, as confirmed by cumulative-annotation slope plots. Only a small number of labels is needed, and those labels also seed a new training set.

  • PRX Part 3 — Training a Text-to-Image Model in 24h!

    Hugging Face hardMaster

    A 24-hour, ~$1500 speedrun on 32 H200s combines the most effective diffusion training tricks into a single text-to-image recipe. The recipe uses x-prediction in pixel space with patch size 32 and no VAE, LPIPS and DINOv2 perceptual losses applied to pooled full images at all noise levels, TREAD token routing with dense-vs-routed self-guidance, REPA alignment to DINOv3 at block 8 on non-routed tokens only, and Muon for 2D parameters with Adam for everything else. Training ran 100k steps at 512px followed by 20k steps at 1024px on about 8.7M synthetic images. The resulting model follows prompts well, and its remaining artifacts look like undertraining rather than flaws in the recipe. Code and configs are open-sourced in the PRX repository.

  • CinePile 2.0 - making stronger datasets with adversarial refinement

    Hugging Face hardMaster

    CinePile 2.0 improves a long-video QA benchmark with adversarial refinement. A text-only "Deaf-Blind" LLM (LLaMA 3.1 70B) answers each question without video or dialogue and explains its choice, and GPT-4 uses that rationale to rewrite the question or distractors, repeating up to five times until accuracy falls to chance. Degeneracy is checked across five answer-order permutations, with a question flagged if three or more are correct. The method fixed about 90% of degenerate pairs in both the test and training sets. Re-evaluation shows Gemini 1.5 Pro leading commercial models and LLaVA-OneVision reaching 49.34% among open models, while nearly all models lose 15-20% accuracy on the hard split.

  • Training Design for Text-to-Image Models: Lessons from Ablations

    Hugging Face hardMaster

    Photoroom's ablations on its PRX-1.2B text-to-image model compare recent training-efficiency techniques against a plain Flow Matching baseline: 100k steps at 256×256 on 1M MidJourney images, scored with FID, CMMD, DINO-MMD and throughput. REPA with a frozen DINOv3 teacher cut FID from 18.2 to 14.64 at the cost of throughput (3.95 to 3.46 batches/s), and DINOv2 offered a cheaper middle ground. iREPA's spatial tweaks helped with DINOv2 but hurt with DINOv3, and alignment works best as a temporary scaffold: dropping REPA after about 200K steps sharpened fine detail. The post also covers latent-space alignment (REPA-E, the FLUX.2 AE), training objectives, token routing and sparsification, and data choices.

  • Preference Optimization for Vision Language Models

    Hugging Face hardMaster

    TRL now supports direct preference optimization (DPO) for vision language models, trained on chosen/rejected answer pairs rather than fixed labels. A walkthrough fine-tunes Idefics2-8b on the RLAIF-V dataset, formatting image-plus-question prompts with the processor's chat template. Full float32 DPO training would need about 160 GB (policy, reference model, gradients, AdamW states), but bfloat16 plus LoRA cuts trainable parameters to 55M and memory to roughly 32 GB. Batch size 2 with 32 gradient accumulation steps and gradient checkpointing fits activations, and training is judged by rising accuracy and reward margin.

The quest for software engineering knowledge.

Look:
Layout: