These notes collect the immunology and the literature that a machine learning reader needs before working on T cell receptors. They assume you can read a loss function and have never heard of an HLA allele.
Preliminaries:
- T cell, an immune cell that eliminates infected or abnormal cells, but only once it has recognised a specific molecular signature displayed on their surface.
- T cell receptor (TCR), the recognition apparatus itself, a heterodimer (two different protein chains bound together) composed of an alpha and a beta chain.
- CDR3, i.e., the third complementarity determining region, the loop on each chain that establishes most of the contact. It is hypervariable (it differs almost completely from one receptor to the next), approximately 8 to 25 amino acids long, and it is the sequence on which almost every model operates, written as
CASSLGQAYEQYF. - peptide-MHC (pMHC), what the receptor actually recognises. A cell degrades its internal proteins and displays the resulting fragments in the peptide-binding groove (a walled channel on the molecule’s surface that holds the fragment in place) of a major histocompatibility complex (MHC) molecule, and the receptor reads the pair rather than the peptide alone.

- V(D)J recombination, the process that makes CDR3 so variable, in which gene segments are excised and rejoined with random deletions and insertions at the junctions. The beta chain recombines V, D and J segments, whereas the alpha chain has no D segment, which is the reason CDR3 sequence space is structured rather than uniform.

- HLA, the human MHC genes, among the most polymorphic loci in the genome. Which peptides a person can display depends on which variants they carry, and
HLA-A*02:01is generally the first scope considered, since it is frequent in European populations and consequently the best represented in public data. - repertoire, the population of receptors present in one individual, on the order of 107 to 108 distinct sequences. It is not a dataset, but a sample drawn from a living, selected and expanding system.
- neoantigen, a peptide produced by a tumour mutation and absent from healthy tissue, and therefore the target of choice, since recognising it should in principle spare normal cells.
The clinical ambition behind all of this is to find or design a receptor that recognises a tumour neoantigen, engineer it into the patient’s own T cells, and reinfuse those cells. This is known as TCR-T therapy, and it already works for a small number of targets. The bottleneck is the identification of receptors that bind the intended peptide-MHC pair and nothing else.
Goodhart’s law with a clinical cost
In 2013 two separate trials employed affinity-enhanced receptors directed against the cancer antigen MAGE-A3. Linette et al. (2013) report that one of these receptors cross-reacted with a peptide derived from titin, a protein expressed in contracting cardiac tissue, and that the first two treated patients developed cardiogenic shock and died within days of infusion. Morgan et al. (2013, Journal of Immunotherapy 36(2):133) report that a second and unrelated MAGE-A3 receptor cross-reacted with a family member expressed in brain tissue, with fatal neurotoxicity.
Both receptors had passed their specificity screens, and the cardiac toxicity was, in the authors’ account, not predicted by the preclinical studies. The quantity under optimisation was affinity for the intended peptide, and the dimension left unmeasured was everything else the receptor might encounter. This is not reward hacking in the machine learning sense, and the distinction is worth keeping: no model was optimising against a learned reward, the receptors were engineered by substituting residues, and the cross-reaction was a property of the body’s own proteins rather than a gap discovered in a proxy. What the episode illustrates is the more general claim in the epigraph, together with the question that applies to every specificity screen, which is what the screen actually covered.
Three research lines, frequently conflated
Keeping these apart saved me several weeks, since papers from all three are routinely cited as though they addressed the same question.
Generation models, i.e., how probable is this receptor at all
Before asking whether a receptor binds anything, one may ask how probable it is that V(D)J recombination ever produces it. Sethna et al. (2019) compute precisely this generation probability with OLGA, by summing over the recombination events capable of yielding a given CDR3, building on the recombination model fitted by Marcou et al. (2018) in IGoR. The approach is fast and its assumptions remain legible, which is increasingly rare.
One detail is easily skipped and matters considerably. The generation probability is a pre-selection quantity, and it is deliberately estimated from non-productive sequences, i.e., rearrangements that failed and were therefore never exposed to selection, so that selection effects are excluded. Any model fitted instead on a real, productive and clonally expanded repertoire therefore estimates a different quantity, namely the probability that a sequence is present, which folds in thymic selection, peripheral expansion and the tissue that happened to be sampled. Isacchini et al. (2021) address this gap explicitly in SONIA and soNNia by modelling selection as a factor applied on top of generation. Before interpreting a correlation between a new model and published generation probabilities, it is therefore necessary to establish which of the two quantities is being estimated.
Specificity models, i.e., does this receptor bind that peptide
NetTCR-2.0 (Montemurro et al., 2021), ERGO-II, TITAN and TULIP (Meynard-Piganeau et al., 2024) belong here, together with distance-based approaches such as TCRdist (Dash et al., 2017). These are classifiers rather than generative models, and the distinction matters in practice, since they are candidates for the reward model and not for the generator.
The weakness reported consistently across this family is generalisation to peptides absent from the training data. Garcia Noceda et al. (2026) make the sharper claim in ImmSET, an Immune Synapse Encoding Transformer that models interactions among sets of variable-length sequences: they identify a failure mode in prior sequence-based approaches which inflated previously reported performance on this task, and report that ImmSET remains robust once the evaluation is tightened. Therefore any headline accuracy should be treated as provisional until it is established whether the test split held out peptides, receptors, or merely rows, which is also the most common way in which these results are over-read.
Structure models, i.e., what does the complex look like
AlphaFold2 and AlphaFold3, the ESM family of protein language models, ProteinMPNN (Dauparas et al., 2022) for inverse folding, i.e., choosing a sequence that will fold into a given shape, and Watson et al. (2023) for backbone generation with RFdiffusion. Performance on well-represented folds is remarkable. The TCR-pMHC interface, however, is shallow, flexible and comparatively data-poor, and structural predictions in this specific setting are better treated as a hypothesis-generating prior than as ground truth. The ImmSET authors report, moreover, that a sequence-only model can outperform AlphaFold2 and AlphaFold3-based pipelines once sufficient training data is available, which is a useful corrective to the assumption that structure is always the richer representation.
The pattern that follows
Keeping the three lines apart also makes the obvious way of combining them visible, in which a generator is fitted to unlabelled data and a pretrained classifier is then used to steer sampling. Whatever the arrangement, its weak point is evaluation. A generator steered by one classifier and subsequently scored with that same classifier has measured nothing whatsoever, and holding out the evaluator is ordinary practice in reward modelling without yet being ordinary here.
Terminology that will mislead you
- positive and negative denote binder and non-binder rather than class labels in the abstract. Negatives are moreover frequently synthesised by random pairing, so a classifier may score well simply by detecting that a pair looks randomly assembled.
- affinity and avidity are distinct. Affinity concerns one receptor and one ligand, whereas avidity describes the aggregate effect of many simultaneous contacts, and papers are not uniformly careful about the difference.
- specificity in immunology refers to which targets a receptor recognises. It is not the statistical true-negative rate, and both senses occasionally appear in the same paper.
- public and private clones refer to sequences shared across individuals or restricted to one individual, and have nothing to do with data access.
- paired indicates that the alpha and beta chains were measured from the same single cell. Most large repertoire data is unpaired, and paired data is the scarce and valuable kind.
- clonal expansion means the same receptor is present in many cells. Row counts in a repertoire file therefore report abundance rather than independent samples.
One structural warning concerns the construction of splits. A random split over rows leaks badly on repertoire data, since the same clone recurs across rows and the biases of a single donor span both sides. Grouping by donor is the minimum. It is then necessary to measure how many held-out sequences nevertheless appear verbatim in training, because public clones do recur across individuals and will inflate whatever is subsequently reported.
A short reading path
- OLGA (Sethna et al., Bioinformatics 35(17):2974, 2019), the generation-probability baseline and the clearest example of a model whose assumptions stay legible. To be read together with IGoR (Marcou et al., 2018), which fits the underlying recombination model.
- soNNia (Isacchini et al., PNAS 118(14), 2021), selection modelled as a factor on top of generation, and the reason to remain careful about which quantity a new likelihood is estimating.
- ImmSET (Garcia Noceda et al., arXiv:2603.26994, ML4H 2025), which identifies a failure mode in earlier sequence-based work that inflated reported performance, and reports scaling with data volume.
- TULIP (Meynard-Piganeau et al., PNAS, 2024), an unsupervised transformer built around incomplete data and the bias in negative sampling.
- NetTCR-2.0 (Montemurro et al., 2021) and TCRdist (Dash et al., Nature 547:89, 2017), a convolutional classifier on paired chains and the distance-based alternative.
- RFdiffusion (Watson et al., Nature, 2023) and ProteinMPNN (Dauparas et al., Science, 2022), i.e., the two halves of any structural pipeline.
- Classifier guidance (Dhariwal and Nichol, 2021) and classifier-free guidance (Ho and Salimans, 2022), the mechanics of steering a generative model, which transfer almost unchanged.
- Concrete Problems in AI Safety (Amodei et al., 2016), still the most compact statement of why optimising a proxy objective fails, and worth rereading with a receptor in mind.
What any of this transfers to, coming from machine learning or robotics, is taken up in From Robot Learning to Receptor Design.
1 Comment