MainProtein design has recently achieved major advances, particularly in de novo creation of proteins tailored to specific functions or structures4,5,6,7,8. Yet, evolution demonstrates an alternative strategy: building upon existing proteins—an approach that we call template-guided design (Fig. 1a–c). Like renovating a building rather than constructing from scratch, this strategy enables protein miniaturization, re-engineering of sensors and reporters while preserving function, and adaptation of gene payloads for viral delivery constraints. Current template-based methods rely mainly on substitutions, and become ineffective as changes become extensive: 25 substitution sites alone yield 1032 possibilities, rendering computational prediction impractical. More fundamentally, natural evolution generates new proteins not only through substitutions but also via insertions and deletions (indels). Modifying proteins without indels is akin to renovating a building without the ability to add or remove entire rooms, yet no existing method can leverage such changes at scale while preserving the core structure of a protein. A design approach that could manage both combinatorial substitutions and large-scale insertions and deletions would vastly expand the universe of proteins derivable from a single template.Fig. 1: Description of the Raygun model.a, Unlike de novo models, which design entirely new proteins conditioned on structural or functional constraints, Raygun uses existing proteins as a template and introduces appropriate substitutions and indels in a template-guided design. b, Raygun takes three inputs: the template sequence, a noise parameter and target length. c, Raygun has direct and wide-ranging applications in biological research, from protein sensor design to protein miniaturization for gene therapy. Illustration created in BioRender; Singh, R. https://BioRender.com/mjecsx1 (2026). d, Raygun is designed as an auto-encoder model. The encoder converts sequence input with variable length to a fixed-dimensional representation, and this space approximates a multivariate normal distribution. Del, deletion; ins, insertion; seq, sequencing; sub, substitution. e, Unlike diffusion-based models, single-shot sampling can be done through this distribution. f, Raygun parameters provide fine-grained control over insertions, deletions and substitutions. g, It is trained in a self-supervised way. For inference, we recommend using a fine-tuned version in which only the decoder block is updated. h, Generation and filtering pipeline. Raygun is fast (0.3 s per generation) and can be paired with downstream filtering steps to generate high-quality candidates efficiently.Protein language models (PLMs) encode proteins as rich, per-residue representations learned from evolutionary data1,2,9,10,11. These embeddings capture local and global context at each residue, and have powered predictions of protein interactions, structures, and functional properties12,13,14. From a design standpoint, PLM embeddings provide high-fidelity, computationally tractable representations: for point substitutions, sampling near a residue’s embedding already generates function-preserving variants15. Bidirectional conversions between sequence and embedding spaces are now accurate enough that design operations can be performed entirely in the structurally aware embedding space. Here we use PLMs for template-guided design by reducing sequence-space design to embedding-space operations. However, PLM embeddings scale with sequence length, making representations of differently sized proteins incompatible. Our key insight is to represent each protein as a probability distribution in fixed dimensions, rather than a sequence of points in high-dimensional space. This renders proteins of any length directly comparable, enabling single-shot generation of diverse candidates without iterative refinement.We introduce Raygun, a generative framework that implements this approach (Fig. 1). An encoder–decoder architecture, Raygun takes three inputs: a template sequence, a noise parameter controlling substitution rate and a target length controlling indels. We show that Raygun preserves predicted structure while generating miniaturized, modified and enlarged protein variants, enabling design possibilities that are inaccessible to existing methods. Applied to fluorescent proteins, we generated candidates with shorter sequences than 96% of known fluorescent proteins, with 6 out of 8 exhibiting fluorescence. Designed miniaturized variants of TurboID, a synthetic biotin ligase, showed ligase activity; enlarged variants of EGF achieved higher EGFR-binding affinity than wild type. These results demonstrate that protein function can be faithfully represented independent of sequence length, suggesting that the evolutionary capacity for coordinated insertions, deletions and substitutions can be computationally recapitulated from learned sequence representations.Proteins as probability distributionsPLMs encode proteins as variable-length embeddings derived from evolutionary data. We use ESM-2 (Evolutionary Scale Modeling 2), with 650 million parameters, for sequence-to-embedding transformation. For the reverse mapping, from embeddings to sequences, we trained a neural network, achieving over 99% validation accuracy; others report similarly high performance16,17. These bidirectional transformations enable design in embedding space while maintaining a clear path back to realizable sequences.The critical challenge is that PLM embeddings have variable dimensionality: a protein of n residues maps to n high-dimensional vectors. This incompatibility prevents direct comparison across proteins of different lengths, rendering indel-based design intractable. However, PLM embeddings are statistically redundant: nearby residues encode overlapping contextual information, so contiguous stretches of the embedding can be summarized without significant information loss. We exploit this redundancy by representing each protein not as a set of points in embedding space but as a probability distribution in fixed dimensions, making proteins of any length directly comparable and enabling generation at arbitrary target lengths.Specifically, we partition each protein’s embedding into K = 50 contiguous stretches of residues (blocks), where the size of each block scales with the protein length (for example, 10 residues per block for a 500-residue template). By the central limit theorem, averaging the embedding vectors within each block yields values that approximate a multivariate Gaussian distribution18,19 (Extended Data Fig. 1). We chose K = 50 after comparison with K = 25 (Extended Data Fig. 2). These block-level distributions collectively represent the full protein in a fixed 64,000-dimensional space (50 × 1,280), regardless of the original length. Crucially, the resulting Gaussian can be sampled directly, making the representation tractable for generation: by resampling from the template’s distribution at different target lengths, we generate candidates of any length while preserving the structural principles encoded in the template.Unlike diffusion-based methods4,20,21,22, which require iterative denoising, our fixed-length representation enables single-shot generation: the decoder acts as a one-shot denoiser, mapping a single noisy sample from the template’s distribution directly to a candidate sequence. The user specifies noise (controlling substitution rate) and target length (controlling indels). Generation takes 0.3 s per iteration on an NVIDIA A100 graphics processing unit, approximately 100-fold faster than diffusion-based de novo approaches, while simultaneously controlling substitutions and indels. Ablation experiments probing the encoder and decoder contributions show that the decoder contributes more to reconstruction accuracy in the current model, although when training is scaled up with increased model capacity and dataset sizes, the relative importance of the encoder increases (Extended Data Fig. 3 and Supplementary Note 1).The Raygun architectureRaygun implements this representation within an auto-encoder operating on ESM-2 embeddings (Extended Data Fig. 4 and Supplementary Methods). Although PLM embeddings provide a rich starting point, they must be refined to maximize information retention during condensation and to support generative sampling. The architecture separates these two tasks—length transformation and feature refinement—using two length-transforming layers (‘Reduction’ and ‘Repetition’) and multiple length-preserving ‘T-Block’ layers. Reduction layers perform within-block averaging, generating fixed-length outputs describing the Gaussian distribution; Repetition layers accept a target length and fixed-length representation, producing variable-length embeddings at the desired size. T-Block layers combine transformer modules for global context with 1D-convolution blocks for local relationships; present in both encoder and decoder stages, they account for most of Raygun’s 701 million trainable parameters.Training is self-supervised: the model learns to compress and decompress sequences while maintaining fidelity in both embedding and sequence spaces. The training objective enforces consistency across three complementary axes: (1) a reconstruction loss in embedding space, penalizing deviations in the reconstructed embeddings; (2) a cross-entropy loss in sequence space, penalizing deviations after decoding through a pre-trained ESM-2 decoder; and (3) a size-invariance loss in the Raygun latent space, critical for stable generation across varying output lengths, which decodes the fixed-length representation to a shorter sequence, re-encodes it, and penalizes divergence between the two fixed-length representations (Supplementary Methods). We present here results from a model trained on around 80,000 proteins from UniRef50 (Supplementary Methods); scaling to larger models and datasets further improves performance (Extended Data Fig. 3c and Supplementary Note 1).The architecture can be customized at inference time to improve generation quality. Although Raygun performs single-shot generation, a one-step recycling iteration (passing a generated candidate back through the model as a new template) further improves quality and diversity (Supplementary Methods). The encoder governs diversity and the decoder governs fidelity (Extended Data Fig. 3c,e and Supplementary Note 2); accordingly, fine-tuning the decoder on target protein families improves reconstruction fidelity (BLOSUM score >0.99; Supplementary Methods). Fine-tuning does not diminish diversity: we verified this by generating candidates from 100 sequence-diverse human and mouse proteins using both baseline and fine-tuned models, and across varying noise levels, both versions produced comparable sequence diversity.After generation, we apply a PLM-based pseudo log-likelihood metric (pLL) to rank candidates by predicted evolutionary fitness, retaining high-quality variants (see Supplementary Methods for filtering guidelines). Because pLL scores scale with sequence length, we devised a length-adjusted version that enables fair comparison across candidates of different sizes, a necessary step for any design method that generates proteins of variable length (Supplementary Methods). As is common in protein design, we recommend that task-agnostic generation by Raygun is combined with downstream task-specific algorithmic filters. We assessed whether function preservation arises from Raygun’s generative process itself, or whether that load falls on downstream filtering. We compared unfiltered Raygun candidates against a greedy PLM-based baseline that iteratively shortens proteins by removing the least evolutionarily important residues. On eGFP, mCherry and RAS, unfiltered Raygun candidates retained functional sites (chromophore residues23 and P-loop motifs24) at substantially higher rates than the greedy baseline, while showing lower overall sequence identity to the template, indicating higher diversity with better functional preservation (Extended Data Fig. 3a and Supplementary Methods).Structure preservation across sizesTo understand Raygun’s generative capabilities, we applied it to 4 proteins spanning a 17-fold size range: haemoglobin (147 amino acids), CCR1 (355 amino acids), lacZ (1,024 amino acids) and mTOR (2,549 amino acids), generating 2,000 candidates per protein at multiple target lengths with moderate noise (0.5) and retaining the top 5% by length-adjusted pLL (Supplementary Methods). Figure 2 shows AlphaFold325 predicted structures of representative candidates for each protein, along with pLDDT26, LDDT27 and TM-scores28 against the template. Structural preservation holds across the entire size range, with graceful degradation at larger modifications: The TM-score of CCR1 decreased to 0.68 when shortened by 17%, whereas mTOR accommodated a 25% reduction with a similar TM-score of 0.69. mTOR could be miniaturized by more than 500 residues (over 20%) while maintaining a TM-score of approximately 0.7, demonstrating that the fixed-length representation captures sufficient structural information even for multi-domain complexes that are far larger than typical design targets. Beyond moderate modifications, Raygun can generate large deviation—halving or doubling protein length, or substituting more than 50% of residues—while broadly preserving the predicted structure.Fig. 2: Protein editing using Raygun for proteins of different sequence lengths.a,c–e, The following proteins were chosen for a demonstration of Raygun’s miniaturization and magnification capabilities: haemoglobin (a), CCR1 (c), lacZ (d) and mTOR (e). Template structures are shown in grey. For haemoglobin, CCR1 and lacZ, we present proteins that are reduced, as well as some that are increased in size. For mTOR, however, owing to its large size, we only show selected candidates that are reduced in size. b, Multiple sequence alignment of the Raygun candidates and template for haemoglobin.We next investigated where Raygun places its insertions and deletions. The haemoglobin candidates (Fig. 2b) illustrate that gaps are distributed across the sequence rather than concentrated in a single region. More systematically, Raygun shows only a modest bias towards removing loop regions at small length changes, and this preference diminishes at greater reductions (Extended Data Fig. 5a and Supplementary Methods). The relative propensity to remove α-helices versus β-sheets remains broadly unchanged, a notable property given that maintaining balance across secondary structure types remains challenging in de novo protein design. Raygun also preferentially conserves functionally important regions: across proteins with annotated active and binding sites, the ratio of preserved functional sites to overall sequence conservation exceeded 1.0 at all deletion rates (5%, 10% and 25%), indicating selective retention without explicit annotation (Extended Data Fig. 5b and Supplementary Methods). We also assessed Raygun-generated magnified sequences, finding that they too were well-balanced in insertions across the three secondary structure categories (Extended Data Fig. 3b and Supplementary Methods).Raygun’s two parameters—noise and target length—offer independent, fine-grained control over protein generation. The noise parameter scales the covariance matrix of the Gaussian distribution, controlling sequence variability: as noise increases, sequence identity gradually decreases until an inflection point around 2.2, after which they decline more rapidly; structural metrics such as TM-score, pLDDT and LDDT, obtained from OmegaFold29-generated structures, follow similar trends. The length parameter determines indel extent, with structural similarity largely maintained within ±10% of template length (median TM-score approximately 0.78). Across the tested range (0.01 to 6), noise values near 0 enable minor edits while values approaching 2 produce greater sequence variability, with predictable trade-offs between diversity and structural preservation (Extended Data Figs. 5d,e and 6a and Supplementary Methods). We also evaluated structural preservation using Boltz-230, a diffusion-based folding method, observing concordant results (Extended Data Fig. 7). Additionally, to emphasize template preservation rather than exploration, the noise can be set to zero. Raygun then retains high sequence identity during miniaturization, averaging around 93% of the maximum achievable identity even at 20% length reduction (Extended Data Fig. 3f and Supplementary Methods).We performed additional systematic assessments of functional preservation across protein families. Across Pfam31 domains spanning all four major SCOP structural classes (α, β, α/β and α + β), 50.65% of candidates retained their annotated domains across broad length ranges (50–200% of median family length), with retention from 37% (α + β) to 63% (α/β). Raygun preserved Pfam domains 15% better than a random-sequence baseline with matched substitution and indel rates (Extended Data Figs. 3d and 8). ProTrek-based functional annotation further confirmed that for 14 out of 19 templates, all candidates within ±10% of template length exceeded the recommended threshold for functional similarity (Extended Data Fig. 9a and Supplementary Methods). We also tested specific preservation under aggressive miniaturization: protein tyrosine kinases miniaturized to 60–70% of original length retained enzyme commission (EC) classification substantially better than a random baseline (Extended Data Fig. 9c and Supplementary Methods), and AlphaFold3 predicted that Raygun-generated spCas9 variants (miniaturized to 65–75% of original length) maintained superior structural stability and preserved nucleic acid-binding interfaces relative to baseline sequences (Extended Data Fig. 10).Discrete diffusion methods such as EvoDiff and Diffusion Protein Language Model (DPLM) offer an alternative paradigm, generating protein sequences through iterative denoising rather than template-guided design. We benchmarked Raygun against both in same-length comparisons using 60 enzymatic proteins (Supplementary Methods). Matching sequence identity distributions across methods, Raygun achieved comparable structural preservation and functional retention, as assessed by CLEAN-based32 EC number prediction and OmegaFold-computed metrics (Extended Data Figs. 5f and 9b). Unlike in-painting methods that require pre-specified modification sites, Raygun autonomously determines where to modify and natively handles both substitutions and indels. Raygun’s fixed-length representations also outperformed ESM-2 average-pooled embeddings in clustering proteins by CATH structural hierarchy (class, architecture, topology, homologous superfamily and sequence family), with the gap particularly pronounced at the higher architecture level, suggesting improved capture of global structural organization (Extended Data Fig. 5c).Miniaturized fluorescent proteinsFluorescent proteins33 enable direct visualization of protein dynamics in living cells, but their size can disrupt the function of smaller proteins they are fused to34,35,36. Extensive engineering has produced fluorescent protein variants with distinct chromatic properties, monomeric forms and maturation times37,38, but there has been less attention on reducing their size, a critical consideration when tagging small proteins. We tested the ability of Raygun to generate shorter fluorescent proteins while preserving fluorescence.We applied Raygun to eGFP (238 amino acids) and mCherry (236 amino acids), generating 70,000 candidates per template at lengths of 195–235 amino acids. Filtering combined pLL scoring (removing 90%), hmmscan to retain sequences with the correct Pfam domain, and a custom brightness predictor trained on the GFP brightness dataset39,40, yielding 8 candidates: XFP01–04 (eGFP) and XFP05–08 (mCherry) (Fig. 3 and Supplementary Methods).Fig. 3: Eight Raygun-generated fluorescent protein candidates.Four miniaturized candidates each were generated from eGFP and mCherry templates. Top row, AlphaFold3 predicted structures and metrics (pLDDT and TM-score against the template) for each candidate. Fluorescent images (bottom row) and corresponding signal intensities for the selected candidates (middle row). We observed that XFP01, XFP02, XFP04, XFP05, XFP06 and XFP08 showed substantial fluorescence compared with negative controls (NC), whereas XFP03 and XFP07 were confirmed to lack activity. Data are mean ± s.e.m. Scale bars, 10 μm.Our pipeline did not explicitly enforce the chromophore sequence motif (XYG, typically at positions 65–67 in GFP41), nor did we scaffold chromophore-forming residues as in recent de novo approaches2. We specified only noise and target length and allowed Raygun to generate miniaturized candidates. This contrasts with the de novo GFP design by Hayes et al.2, which preserved the template length (229 amino acids), specified sequence and structure of 6 residues that are critical for chromophore formation, and constrained residues 58–71, which were deemed crucial for chromophore energetics. We imposed none of these constraints, yet most of our candidates preserved the chromophore spontaneously.Codon-optimized cDNAs were cloned into expression vectors and transfected into HEK293 cells. Four days later, images were inspected for fluorescence over background, followed by quantitative image analysis. Six out of eight variants (XFP01, XFP02, XFP04, XFP05, XFP06 and XFP08) showed substantial fluorescence compared with negative controls; XFP03 and XFP07 lacked activity. The successful candidates fluoresced with the expected spectrum of their respective templates, although at lower intensity, consistent with the narrow fitness landscape of fluorescent proteins39. Raygun generated functional fluorescent proteins from evolutionarily distant sources: eGFP from jellyfish (Aequorea victoria) and mCherry from coral (Discosoma) diverged around 600 million years ago and have distinct fluorescence spectra. Despite this evolutionary distance, Raygun shortened eGFP by up to 25 amino acids (10.5%) and mCherry by 37 amino acids (15.6%), producing proteins with 199 and 206 amino acids, respectively, that are shorter than 96% of fluorescent proteins in FPbase40. In choosing candidates for experimental validation, we deliberately included several with non-canonical chromophores to test whether alternative chromophore sequences could also produce fluorescence. One candidate (199 amino acids) had a glycine deleted and a serine substitution in the chromophore, demonstrating the capacity of Raygun to explore designs beyond canonical constraints.Miniaturized TurboID proteinsBioID proximity-dependent assays using biotin ligases have become essential tools for studying protein-protein interactions, localization and cellular dynamics42,43. Originally accomplished using slow-acting bacterial BirA, engineering efforts have produced improved variants including BioID2 and TurboID. However, TurboID (approximately 335 amino acids) is large enough to complicate fusion tagging: about 36% of human proteins are smaller. A shorter sequence may produce a less intrusive sensor. UltraID (172 amino acids) was created by manually removing the DNA-binding domain of TurboID44. We explored whether Raygun could both moderately and dramatically miniaturize TurboID while preserving its enzymatic activity.We generated 500,000 TurboID variants targeting moderate miniaturization (195–235 amino acids) and extreme miniaturization (150–180 amino acids). Screening combined sequence-level filters (pLL and hmmscan) and thermostability via TemStaPro45 with structure-based metrics (pLDDT, TM-score), yielding 11 candidates: TurboID-1 through TurboID-10 for the moderate objective and TurboID-11 (165 amino acids) for the extreme objective (Supplementary Methods). Notably, Raygun autonomously removed the DNA-binding domain—the same domain that was removed to create UltraID—to reduce the protein to 165 amino acids. No domain annotation was provided to the model, and UltraID was not in its training data.Experimental validation of these 11 candidates involved cloning their codon-optimized sequences into expression vectors containing a haemagglutinin (HA) epitope tag for detection. Our screening confirmed that 6 out of 11 variants were successfully expressed in HEK cells, including the TurboID-11 sequence, which was reduced in size by approximately half. To assess enzymatic activity, we incubated transfected cells with biotin (overnight, 50 µM) and pulled down biotinylated proteins using streptavidin magnetic beads. Western blotting with an anti-biotin antibody revealed significant biotinylation activity for two variants: TurboID-1 (317 amino acids, 1% reduction) and TurboID-5 (304 amino acids, 6% reduction) (Fig. 4a–c). TurboID-11 was successfully expressed, but its ligase activity was not significant, indicating that although Raygun can perform large length modifications and autonomously identify redundant domains, maintaining catalytic efficiency for multi-domain proteins with highly specialized enzymatic functions may require additional optimization, potentially through directed evolution of the miniaturized candidates.Fig. 4: TurboID and EGF binding results.a, Raygun-generated candidate TurboID variants that were screened for experimental validation. b, Whole-cell lysate shows expression of 6 out of 11 HA-tagged TurboID candidates in HEK cells. Western blots with anti-HA. Ctrl, control. c, Western blot of streptavidin-enriched eluates with biotin antibody (left) and corresponding quantification (right), showing two candidates (TurboID-1 and TurboID-5) with significant biotin ligation activity. *P = 0.0229, **P = 0.0099, Welch’s t-test for unpaired samples. d, Binding assays (right) and AlphaFold3-inferred structures in complex with EGFR (pink) for the two EGF candidates generated by Raygun (lilac) (left) that showed binding affinities greater than that of wild-type EGF. The variant EGF sequence is shown below each structure.EGFR binders via magnificationTo evaluate Raygun as a general-purpose design tool, we participated in a protein design competition benchmarking computational approaches for EGFR binder design46. Inspired by the CASP (Critical Assessment of protein Structure Prediction) competitions, the goal was to benchmark computational protein binder design against EGFR, a target of many cancer therapies. All candidates had to be single-chain proteins, no longer than 250 amino acids, with a difference of at least 10 amino acids from any published sequence. The first round tested 201 submissions, with only 5 (2.5%) showing significant binding, establishing a demanding baseline. We participated in the second round, which was organized following these disappointing results.We selected EGF (53 amino acids), the endogenous ligand of EGFR, as the template. Since the length of EGF was close to the minimum 50-amino-acid threshold of Raygun, we applied magnification (rather than miniaturization) to generate candidates with 55–57 amino acids. We fine-tuned Raygun on 5 EGF-like sequences (Supplementary Methods) and generated 10,000 candidates without explicit constraints to preserve wild-type binding sites, instead relying on Raygun’s generative process to implicitly maintain critical interactions.To estimate binding potential, we used ProTrek47, a tri-modal PLM trained on sequence, structure and function, to rank candidates by predicted EGFR-binding potential directly from sequence rather than structural metrics. Our choice to predict function directly from a PLM, rather than relying on predicted structural metrics such as iPTM (interface predicted template modelling) and iPAE (interface prediction score from aligned errors), also distinguished our approach from other competition entries.Out of ten submitted candidates, four were selected for biological evaluation (Supplementary Methods). All four were expressed successfully. Two demonstrated strong EGFR binding: EGF-Raygun-1 (dissociation constant (Kd) = 0.274 µM) and EGF-Raygun-2 (Kd = 0.561 µM), both stronger than wild-type EGF (Kd = 0.759 µM; Fig. 4d). Among all EGF-based approaches in the competition, our designs yielded the best binding affinities. Even methods based on the same baseline PLM as Raygun (ESM-2) did not perform as well.Raygun identified candidates with improved function and lower sequence identity from a vast combinatorial space, suggesting that it captures functional attributes beyond sequence conservation. The more successful candidates had lower sequence identities to wild type: EGF-Raygun-1 (70.7% identity) and EGF-Raygun-2 (76.8% identity) versus EGF-Raygun-3 (80.4% identity) and EGF-Raygun-4 (78.6% identity). The key modifications occurred at peripheral positions, presumably distant from the binding interface, yet substantially influenced binding affinity, indicating that function depends on global sequence context beyond direct binding-site residues.DiscussionEven though proteins evolve primarily residue by residue, natural selection does not evaluate them as such—it acts on holistic properties such as fold stability, binding affinity and catalytic activity, that emerge only at the level of the whole molecule. Raygun bridges this dichotomy by taking residue-level PLM embeddings and condensing them into a fixed-dimensional probabilistic space that allows reasoning across proteins of any size. Our representation of each protein as a Gaussian distribution, rooted in the central limit theorem rather than diffusion-based denoising, makes direct, single-shot sampling tractable, with generation roughly 100-fold faster than diffusion-based methods. More broadly, this principle of representing biological sequences of variable length in fixed-dimensional probabilistic spaces may extend to RNA families and genomic regulatory elements.In protein design, the central challenge is staying on the manifold of feasible proteins while searching as broadly as possible across it. De novo methods4,5,48,49 start far from this manifold and attempt to reach it. Since they fix protein length at generation time, post-generation modifications are tractable only for substitutions, limiting the accessible design space. Raygun complements these approaches by starting on the manifold and exploring outwards from it, making indel-based exploration as tractable as substitutions and expanding the search radius available to the designer. The two strategies can be combined: when a de novo design requires structural optimization (shortening a loop, removing a redundant domain), Raygun enables targeted length modifications while preserving favourable features. This becomes critical when a design has the correct properties but the wrong length, such as a candidate that exceeds adeno-associated virus (AAV) packaging limits for gene therapy.Our experimental results suggest that template-guided approaches can enable greater design novelty than de novo methods. Raygun shortened eGFP and mCherry to as little as 199 and 206 amino acids, shorter than 96% of fluorescent proteins in FPbase40, and 6 out of 8 tested variants exhibited fluorescence above background. The de novo GFP design by Hayes et al.2, using ESM-3, preserved the template length (229 amino acids), specified sequence and structure of 6 residues critical for chromophore formation, and constrained residues 58–71 for chromophore energetics. We imposed none of these constraints, yet most candidates preserved the chromophore spontaneously, and one carried a non-canonical chromophore sequence (Supplementary Note 3). Our designs and the ESM-3 GFP showed dim fluorescence and will require directed evolution to reach high fluorescence. Beyond the size reduction, the more notable finding was that a functional fluorescent protein could be obtained at all despite more than 40 coordinated indels and substitutions, given the well-known narrow fitness landscape of fluorescent proteins39. This suggests that Raygun’s edits respect the functional grammar of the protein, and that compact Raygun-generated fluorescent proteins could serve as scaffolds for new, more powerful biosensors.For naturally evolved proteins, the relationship between sequence and function is also less straightforward than direct conservation suggests. Hie et al.50 have hypothesized that PLM-generated mutations, which follow evolutionary rules, should generally improve fitness, demonstrating this for specific antibodies. Our EGF results both support and complicate this view: using a sequence-focused approach without explicit structural optimization, we generated EGF variants with stronger EGFR binding than the native ligand, yet the key modifications occurred at peripheral positions that are presumably distant from the binding interface, indicating that function depends on global sequence context beyond direct binding-site residues.A complementary lesson comes from the biotin ligase experiments. Moderate miniaturization preserved biotinylation activity, demonstrating Raygun-based optimization in a multi-domain setting. By contrast, extreme miniaturization—where Raygun autonomously identified and removed the DNA-binding domain to produce TurboID-11 (165 amino acids, approximately 50% reduction)—yielded a variant that was structurally stable and expressed in cells, but with weak biotinylation activity. Biotin ligation itself is a natural function that is well represented in PLM training data, but the high-strength activity of TurboID is an engineered, supra-evolutionary trait achieved through directed mutagenesis of BirA, and such supra-evolutionary functions may not be fully captured by evolutionary sequence statistics. Recovering them in aggressively miniaturized variants will likely require closing the loop with experimental feedback, such as directed evolution from Raygun candidates or function-specific assays to supplement PLM-based filters.Future enhancements to Raygun could address scaling, multi-domain handling and directed domain manipulation. To assess the core conceptual contributions, we present results from a Raygun model trained on only 80,000 proteins from UniRef50, a data-efficient setup. Although this is already powerful, longer proteins challenged zero-shot reconstruction, suggesting limits to the expressiveness of a fixed-length representation; in such cases (for example, mTOR, with 2,549 amino acids) we recommend fine-tuning, and future work could explicitly account for multi-domain organization. Scaling to larger models and datasets continues to improve performance (Supplementary Note 1), and integrating more powerful or structure-infused PLMs such as ESM-32 and SaProt3 could further enhance Raygun. Directed manipulation of protein domains, including both removal and addition, offers another frontier whereby computational approaches can be guided by functional constraints.Finally, Raygun, like other generative protein design tools, raises important biosafety considerations. We are signatories to the Responsible AI for Biodesign principles (https://responsiblebiodesign.ai/) and believe that computational tools must be developed and deployed with appropriate safeguards, including for concerns such as immunogenicity in therapeutic applications. Our validation results with computational functional prediction tools (such as, Pfam, ProTrek and CLEAN) suggest that they can serve as effective filters for identifying potentially concerning Raygun-generated sequences.Reporting summaryFurther information on research design is available in the Nature Portfolio Reporting Summary linked to this article.
Miniaturizing and modifying natural proteins with Raygun - Nature
Probabilistic sequence encoding from language model embeddings within a generative AI framework enables protein miniaturization, modification and augmentation while maintaining native architecture and functional integrity.








