Using agents to train AI: curated and simulated data
Part 5: Scaling up
Introduction to agentic AI
About this lecture
Deep learning needs many labelled examples. In research, labels are the scarce part: a pathologist’s afternoon, a rare disease, a 3D volume that takes hours to outline. Agents cannot label for you, but they can attack this bottleneck from two sides.
Curate: the agent writes scripts that audit the labelled data you have, and builds a gallery for a human expert to check.
Simulate: the agent writes a simulator that makes images with exact labels for free, to train a network on.
Test on real data: a small, hand-labelled real test set decides whether any of it works.
A case study: the course author’s ongoing project, where synthetic scores looked good and the real predictions were rejected.
A concept unit with a light exercise. It builds on How LLMs and agents work, and how they fail and Privacy, ethics and safety.
Ten thousand images are easy to get; labelling them is not
Labels in research are rare, expensive, slow, inconsistent and sensitive
A network learns from labelled examples and is judged on new ones
Before you label or simulate anything, try a pretrained model
Pretrained, as is: does an existing model already do the job on 20 of your images? For nuclei and cells: Cellpose (now Cellpose-SAM) or StarDist.
Fine-tune with few labels: start from a model trained on many images (a domain model, or a general ImageNet-trained network) and adjust it with tens of your labels.
Only then curate or simulate to get more training data.
Check each model’s licence: Cellpose’s models are trained on data licensed CC BY-NC.
If you only need positions, a detector is cheaper than outlines
Boxes are much faster to label, and detectors such as YOLO* are fast to train and run. A simulator gives boxes as easily as outlines.
* The common YOLO software (Ultralytics) is AGPL-3.0: the licence matters for commercial or closed-source use.
Agents help in two ways: curate what you have, simulate what you lack
Most labelled datasets have problems nobody has looked for
Duplicates and near-duplicates: the same image twice, or mirrored, re-saved or cropped.
Leakage: the same patient, animal or slide in both training and test data.
Wrong labels: even famous benchmarks average about 3% wrong test labels (Northcutt et al. 2021).
Outliers and broken files: a blank image, a truncated file, a different stain.
Metadata: a pixel size in nanometres in a micrometre column; “Intact” and “intact”.
Imbalance: 95% of one class, so “always say normal” scores 95%.
Leakage makes a model look better than it is
The agent writes the audit; it reports and changes nothing
Audit dataset/ before anyone trains on it. Report only; change nothing.
A review gallery lets an expert check a hundred images in minutes
Flag, do not delete: the expert decides and every decision is logged
A simulator gives perfect labels for free
Randomise everything that should not change the answer
The network learns your simulator, not the world
Randomisation aims to make real images one more variation
Label a small real test set first, and lock it away
Case study: putting cut tissue pieces back together
The course author’s ongoing project (unpublished; human tissue, so only schematics here).
The agent built a 3D tissue simulator and audited its labels
Synthetic scores rose; the author looked at real predictions and said no
Finding the gap: what the simulator got wrong
Lessons from the case
Synthetic metrics measure the simulator. Careful reports and good scores did not predict real usefulness.
A human looking at real outputs was the decisive test. Plan it; do not wait for it.
Lock a small real test set early, even for 3D data where labelling is slow.
Measure the gap: compare simple statistics of real and simulated data, and ask a classifier to tell them apart.
Design reviews so that the expert is not led: random choice set in advance, model answers hidden, “uncertain” allowed.
Keep failures as baselines. The negative result is part of the record.
You learn what you simulated
Where this goes wrong
Circularity: simulated tests confirm your own assumptions.
Cleaning removes hard cases: label-noise tools flag rare, correct examples too.
Hidden bias: a simulator of “typical” cells ignores the atypical patients.
Compute: training needs time and sometimes a GPU; start small.
Licences: real data used for fine-tuning must allow it; record the licence.
Privacy: auditing patient data with a cloud agent sends it to the provider.
What the agent does and does not do here
It does well
writes audit scripts and review galleries
writes simulators from your description
trains and evaluates small networks
documents splits, settings and decisions
It does not
know which flagged cases are truly wrong
know whether its simulator looks real
choose a fair real test set for you
see that real predictions are nonsense
The exercise: audit a dataset, then train a counter on simulated nuclei
References
Tobin J et al. (2017). Domain randomization for transferring deep neural networks from simulation to the real world. IROS 2017. arXiv:1703.06907
Northcutt CG, Jiang L, Chuang IL (2021). Confident learning: estimating uncertainty in dataset labels. J Artif Intell Res 70. arXiv:1911.00068
Northcutt CG, Athalye A, Mueller J (2021). Pervasive label errors in test sets destabilize machine learning benchmarks. NeurIPS Datasets and Benchmarks. arXiv:2103.14749
Kapoor S, Narayanan A (2023). Leakage and the reproducibility crisis in machine-learning-based science. Patterns 4:100804. doi:10.1016/j.patter.2023.100804
Lehmussola A et al. (2007). Computational framework for simulating fluorescence microscope images with cell populations. IEEE Trans Med Imaging 26:1010.
Rajaram S et al. (2012). SimuCell: a flexible framework for creating synthetic microscopy images. Nat Methods 9:634. doi:10.1038/nmeth.2096
Nehme E et al. (2018). Deep-STORM: super-resolution single-molecule microscopy by deep learning. Optica 5:458. doi:10.1364/OPTICA.5.000458
Summary
Concept
Key fact
Label bottleneck
labels are rare, expensive, slow, inconsistent and sensitive; images are cheap
Pretrained first
try an existing model (Cellpose, StarDist), then fine-tune; boxes (YOLO) if positions suffice
Curation
the agent writes audit scripts and a review gallery; flag, do not delete: hard cases look like errors
Leakage
split by patient, animal, slide or batch; duplicates must not cross train and test
Simulation
the agent writes a generator; every image comes with exact labels
Summary (continued)
Concept
Key fact
Domain randomisation
vary everything that should not change the answer (Tobin et al. 2017)
Sim-to-real gap
the network learns the simulator; error on real images is larger
Real test set
label a few dozen real images first, lock them away, judge everything on them
Case study
good synthetic scores, careful reports; real predictions rejected on visual review
Circularity
simulated tests confirm your own assumptions; only real data breaks the loop
Next (Choosing a model: families, sizes and benchmarks): which language model to run for which job, how to read model names and benchmark graphs, and why a small test on your own task beats a leaderboard.