<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Appu K on Medium]]></title>
        <description><![CDATA[Stories by Appu K on Medium]]></description>
        <link>https://medium.com/@appuk45?source=rss-d0079c98fa43------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cdUzI6qMTbX3_ELXKOsVZw.jpeg</url>
            <title>Stories by Appu K on Medium</title>
            <link>https://medium.com/@appuk45?source=rss-d0079c98fa43------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 12:46:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@appuk45/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Transformers Divide by √dk, and Why Not Just dk?]]></title>
            <link>https://medium.com/@appuk45/why-transformers-divide-by-dk-and-why-not-just-dk-006e87925e19?source=rss-d0079c98fa43------2</link>
            <guid isPermaLink="false">https://medium.com/p/006e87925e19</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[attention-mechanism]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Appu K]]></dc:creator>
            <pubDate>Sun, 15 Mar 2026 18:28:51 GMT</pubDate>
            <atom:updated>2026-03-15T18:28:51.597Z</atom:updated>
            <content:encoded><![CDATA[<p>The math behind one division operation that keeps Transformer training stable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nqm4dVleW2HOSAneRnkbCw.png" /></figure><p>If you’ve worked with Transformers, you’ve seen this equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*Q_frJ4T6BTYSZUsLJfR1qA@2x.png" /></figure><p>Every tutorial shows it. Most will tell you “we divide by the square root of dk for stability” and move on. I did too, for a while. Then I actually sat down and asked: why the square root specifically? Why not just dk? Why not log(dk)?</p><p>Turns out the answer falls out of a single variance calculation. This post walks through that calculation, the intuition behind it, and what breaks if you pick a different scaling factor.</p><h3>The setup</h3><p>I’ll assume you’re familiar with self-attention — Q, K, V matrices, the dot product between queries and keys. The one number that matters for this post is dk, the dimension of the key and query vectors. In the original Transformer, dk = 64.</p><p>Without scaling, the attention formula is softmax(QK^T) · V. The actual formula divides QK^T by √dk before the softmax step. That division is what this entire post is about.</p><h3>Dot products grow with dimension</h3><p>When you multiply Q with K^T, each entry in the result is a dot product between a query vector and a key vector:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*TP1DYw-7Mcy5R9qSB4vS0g@2x.png" /></figure><p>This is a sum of dk terms. More terms, larger possible results. You can see this yourself with a few lines of NumPy:</p><pre>import numpy as np<br>for dk in [2, 8, 64, 512]:<br> dots = [np.dot(np.random.randn(dk), np.random.randn(dk)) for _ in range(1000)]<br> print(f&quot;dk={dk:&gt;3d}  variance={np.var(dots):.2f}&quot;)  </pre><pre>dk=2  variance=1.97<br>dk=8  variance=8.15<br>dk=64  variance=63.42<br>dk=512  variance=515.73</pre><p>The variance tracks dk almost exactly. With dk = 64, dot products regularly land in the range of -20 to +20. With dk = 512, they can easily hit -60 to +60. The raw magnitude isn’t the issue by itself. The issue is what these large, high-variance scores do when they hit softmax.</p><h3>Why variance increases with dimension</h3><p>This isn’t just something you observe empirically. There’s a clean proof.</p><p>Let A be an m × N matrix and B an N × p matrix. Their product C = AB has entries:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*81HVGbCUPFyrMSr-RHhpgg@2x.png" /></figure><p>Each entry is a sum of N products of random variables.</p><p>We need three assumptions:</p><ol><li>Entries of A and B are independent random variables.</li><li>Each entry has zero mean: E[A_ik] = 0 and E[B_kj] = 0.</li><li>Entries have identical variances: Var(A_ik) = σ²_A and Var(B_kj) = σ²_B.</li></ol><p>For two independent random variables X and Y with zero mean, the variance of their product simplifies nicely. The general formula is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*RFhYF2sMdJdhsYUuff3Kyw@2x.png" /></figure><p>With zero mean, the first two terms drop out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*aCSxWgbnCP1SalK3j6czXQ@2x.png" /></figure><p>Since C_ij is a sum of N independent such products:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*YbEO0KNOB65X55oy4A1ECw@2x.png" /></figure><p>Now map this to attention: A is Q, B is K^T, N is dk. If Q and K have unit variance (reasonable when inputs are normalized):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*7DVQRGaExN_vCJi_Wdecaw@2x.png" /></figure><p>This is exactly what Vaswani et al. state in the original paper’s footnote:</p><blockquote>“Assume that the components of q and k are independent random variables with mean 0 and variance 1. Then their dot product, q·k = Σ q_i · k_i, has mean 0 and variance dk.”</blockquote><p>So with dk = 64, the variance of the attention scores is 64 times what it would be with dk = 1. The variance scales linearly with dimension.</p><p>You might wonder how realistic the zero-mean, unit-variance assumption is. In practice, the Transformer applies Layer Normalization before the attention step, which re-centers activations to zero mean and normalizes their variance. The assumption roughly holds in a real model.</p><h3>Why high variance breaks training</h3><p>The problem isn’t high variance by itself. The problem is that the next step is softmax, and softmax does not behave well when its inputs have large magnitudes.</p><h4>Softmax amplifies differences</h4><p>Softmax doesn’t just normalize scores into probabilities. It widens the gap between large and small values.</p><p>Pass [7, 3] through softmax and you get roughly [0.98, 0.02]. What was a 70–30 split in raw scores becomes 98–2 after softmax.</p><p>Now think about what happens when the scores have high variance. Something like [150, -80, 3, -120, 200] through softmax produces:</p><p>[0, 0, 0, 0, ~1.0]</p><p>Essentially a one-hot vector. One token gets all the attention weight, everything else is zeroed out.</p><h4>This kills gradient flow</h4><p>Two things go wrong here.</p><p>First, the model is only looking at one token and ignoring everything else. The whole reason attention exists is to weigh information from multiple positions. A one-hot output throws that away.</p><p>Second, and this is the bigger problem: vanishing gradients. Softmax is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*YzIR_H-XBGcW5vaOWRmsXg@2x.png" /></figure><p>Its gradient with respect to its own input is s_i(1 — s_i). Here’s what that gradient looks like across the full range of softmax outputs:</p><figure><img alt="Softmax gradient curve showing gradient vanishes at both extremes and peaks at 0.5." src="https://cdn-images-1.medium.com/max/1024/1*vWrEBx8tpuF4VPzFX6WUQw.png" /></figure><p>The gradient peaks at s_i = 0.5 and drops to zero at both ends. Look at what happens at the extremes:</p><ul><li>If s_i ≈ 1: gradient ≈ 1 × 0 = ~0</li><li>If s_i ≈ 0: gradient ≈ 0 × 1 = ~0</li></ul><p>Either way the gradient vanishes. During backpropagation, the model gets almost no signal about how to adjust the attention weights. The weights that correspond to suppressed attention scores never get updated. Training stalls.</p><p>The original paper says it directly:</p><blockquote>“For large values of dk, the dot products grow large in magnitude, pushing the softmax function into regions where it has extremely small gradients.”</blockquote><p>The model gets stuck attending to whatever positions its random initialization happened to favour.</p><h4>Seeing it in numbers</h4><p>This is easier to grasp with actual values. Take dk = 64, Q and K with mean 0 and unit variance.</p><p><strong>Without scaling:</strong></p><ul><li>Variance of QK^T = 64, standard deviation ≈ 8</li><li>Dot products range roughly from -24 to +24</li><li>softmax([24, -20, 5, -18, 22]) ≈ [0.88, 0.00, 0.00, 0.00, 0.12]</li><li>Nearly one-hot. Gradient at the dominant position: 0.88 × 0.12 = 0.106. At suppressed positions: effectively 0</li></ul><p><strong>With √dk scaling:</strong></p><ul><li>Divide by √64 = 8</li><li>Scores shrink to roughly the [-3, 3] range</li><li>softmax([3.0, -2.5, 0.6, -2.3, 2.75]) ≈ [0.37, 0.02, 0.03, 0.02, 0.29]</li><li>Clear preferences, but no saturation. Gradients are healthy everywhere. The model can actually learn.</li></ul><p>Same dot products, one division. The output goes from near one-hot to a usable distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63Ao9NNtVagRXFWfR5qVsw.png" /></figure><h3>Why √dk specifically</h3><p>We need to shrink the variance of QK^T before softmax sees it. Divide by what, though?</p><p>There’s a property in statistics that gives us the answer directly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*83ON_s5QHjCHHTZW2paiDA@2x.png" /></figure><p>If you scale a random variable by a constant a, the variance scales by a².</p><p>We know Var(QK^T) = dk. We want to find a value a so that Var(QK^T / a) = 1, regardless of dk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*-79pLERikU7wSM9xvbxxUw@2x.png" /></figure><p>Set this equal to 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*MUcNIcP3Mxzh4x_6XQM3dA@2x.png" /></figure><p>That’s the entire derivation. √dk is the value that brings the variance back to 1 no matter how large dk is.</p><h3>Why not divide by dk?</h3><p>This is where most explanations stop, but it’s worth asking: if variance grows proportionally to dk, why not just divide by dk?</p><p>Because of how variance scaling works. If we divide by dk (so a = 1/dk):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*5zhZmVRFUwtXKjD9S-h7vA@2x.png" /></figure><p>With dk = 64, the variance becomes 1/64 ≈ 0.016. Way too small.</p><p>When variance is that low, all the attention scores are nearly identical. Softmax turns that into something close to a uniform distribution, every token attending equally to every other token. The model can’t distinguish which tokens are relevant and which aren’t.</p><p>So you have two failure modes:</p><ul><li>No scaling: variance = dk, softmax saturates, one-hot outputs, vanishing gradients</li><li>Dividing by dk: variance = 1/dk, scores are all similar, uniform attention, no selectivity</li></ul><p>Dividing by √dk gives variance = 1. The scores have enough spread for softmax to produce a meaningful distribution, but not so much spread that it saturates. It’s the value that balances both failure modes, and it’s the only value that does so independently of dk.</p><h3>Why not just use additive attention instead?</h3><p>There’s another way to sidestep the variance problem: don’t use dot products at all.</p><p>Before the Transformer, most attention mechanisms used additive attention (<a href="https://arxiv.org/abs/1409.0473"><em>Bahdanau et al., 2014</em></a>). Instead of a dot product, additive attention passes queries and keys through a small feed-forward network:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*xFbOsUECY2pWaLT5kixQLA@2x.png" /></figure><p>Because the output goes through tanh, the scores are bounded between -1 and 1 regardless of dimension. There’s no variance explosion. No need for any scaling factor.</p><p>The original paper acknowledges this. Vaswani et al. note that additive attention outperforms unscaled dot-product attention for large dk values. Without the 1/√dk fix, dot-product attention is worse.</p><p>So why use dot products at all? Speed. Dot-product attention is just a matrix multiplication, and modern GPUs are built to do matrix multiplications extremely fast. Additive attention requires running a small neural network for every query-key pair, which is much harder to parallelize.</p><p>The 1/√dk scaling closed the quality gap while keeping the entire computation as a single batched matmul. One division operation, no extra parameters, and dot-product attention matches additive in quality. That’s why scaled dot-product attention stuck.</p><h3>What the authors actually said</h3><p>From section 3.2.1 of <a href="https://arxiv.org/abs/1706.03762"><em>Attention Is All You Need (Vaswani et al., 2017)</em></a>:</p><blockquote>“We suspect that for large values of dk, the dot products grow large in magnitude, pushing the softmax function into regions where it has extremely small gradients. To counteract this effect, we scale the dot products by 1/√dk.”</blockquote><p>The footnote:</p><blockquote>“To illustrate why the dot products get large, assume that the components of q and k are independent random variables with mean 0 and variance 1. Then their dot product, q·k = Σ q_i k_i, has mean 0 and variance dk.”</blockquote><p>I find the word “suspect” interesting here. They present it as a hypothesis backed by math, not as a proven optimality result. But the empirical evidence was strong enough, and every major Transformer architecture since has kept this exact scaling.</p><h3>Wrapping up</h3><p>Dot product variance grows linearly with dimension, which saturates softmax, which kills gradients. Dividing by √dk brings variance back to 1 regardless of dimension. Dividing by dk would overcorrect and flatten attention into a uniform distribution. √dk is the exact fix. The math leaves no room for a different answer.</p><p>I was going through the Transformer architecture, hit this equation, and googled it. Every result said some version of “it’s for scaling” or “it stabilizes training.” That’s it. No one explained why it’s the square root and not dk, or what actually happens to the gradients without it. I found the same one-line answer repeated everywhere.</p><p>So I sat down and worked through the math. It’s a variance calculation and a property of softmax. Not complicated once you see it, but most sources don’t bother explaining it end to end. This post is the writeup I wished I’d found when I first searched.</p><p>Credit to <a href="https://www.youtube.com/watch?v=5S_o0bDJdZA">Learn With Jay’s Transformer series</a> for the initial intuition that got me digging into this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=006e87925e19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SEAL : Self-Adapting Language Models That Learn Like Humans]]></title>
            <link>https://medium.com/@appuk45/seal-self-adapting-language-models-that-learn-like-humans-321ff9b8076a?source=rss-d0079c98fa43------2</link>
            <guid isPermaLink="false">https://medium.com/p/321ff9b8076a</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Appu K]]></dc:creator>
            <pubDate>Mon, 10 Nov 2025 18:24:00 GMT</pubDate>
            <atom:updated>2025-11-10T18:24:00.524Z</atom:updated>
            <content:encoded><![CDATA[<h3>SEAL : Self-Adapting Language Models That Learn Like Humans</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*btna9rZC5mJao4MRMQXjQA.png" /></figure><p>Large Language Models (LLMs) have achieved remarkable success across tasks like question answering, summarization, and reasoning. Yet, despite their power, they still fall short in one key area: <strong>learning continuously and adaptively like humans do</strong>.</p><p>A recent research direction, <strong>SEAL</strong>, tackles this challenge by teaching LLMs how to <strong>teach themselves</strong>, closing the gap between static fine-tuning and true self-improvement.</p><h3>What is SEAL?</h3><p><strong>SEAL (Self-Adaptive Language Models)</strong> is a general framework designed to make large language models more <strong>self-improving and adaptive</strong>.</p><p>Instead of depending entirely on <strong>external supervision</strong> or <strong>massive labeled datasets</strong>, SEAL equips models with the ability to:</p><ul><li><strong>Review their own outputs</strong> — looking back at what they generated.</li><li><strong>Edit and refine them (self-edits)</strong> — correcting mistakes or improving clarity.</li><li><strong>Learn from these edits</strong> using <strong>reinforcement learning (RL)</strong>.</li><li><strong>Continuously adapt</strong> across different domains, tasks, and knowledge updates.</li></ul><p>This approach mirrors how humans learn: <strong>we reflect on our actions, make corrections, and improve iteratively</strong>. By embedding this cycle directly into the training process, SEAL allows models to <strong>teach themselves</strong>, reducing dependency on expensive labeled data while improving adaptability and performance.</p><p>In short, SEAL is not just about better outputs — it’s about creating models that can <strong>evolve their own capabilities over time</strong>.</p><h3>Why Current LLMs Still Struggle to Learn Like Humans?</h3><p><strong>Large Language Models (LLMs)</strong> have achieved remarkable success, but their learning process is still far from how humans learn. Unlike us, they don’t naturally reflect, adapt, or update themselves without external intervention. Some of the key limitations include:</p><ul><li><strong>Static fine-tuning</strong> — Once a model is fine-tuned, its knowledge is essentially “locked in.” Any update requires <strong>expensive retraining</strong> on massive datasets, making continuous improvement impractical.</li><li><strong>Catastrophic forgetting</strong> — When exposed to new data during fine-tuning, LLMs often <strong>overwrite older knowledge</strong>, losing previously learned capabilities instead of integrating them smoothly.</li><li><strong>Lack of autonomy</strong> — Current LLMs are <strong>heavily dependent on external supervision</strong>. They cannot generate their own training signals or correct themselves without curated datasets, human feedback, or explicit labels.</li></ul><p>Because of these limitations, today’s LLMs are <strong>less flexible and adaptive</strong> compared to human learners. Humans naturally <strong>reflect on mistakes, self-correct, and build on prior knowledge</strong>. LLMs, however, struggle to evolve in the same way, which restricts their usefulness in dynamic, real-world environments.</p><h3>SEAL: Teaching LLMs How to Teach Themselves</h3><p>SEAL introduces a new paradigm in language model training: instead of waiting for external supervision, the model actively <strong>creates its own learning signals</strong>. This self-adaptive loop allows models to refine themselves over time, much like how humans learn by reflecting, correcting, and iterating.</p><h4>What SEAL Enables LLMs to Generate</h4><ul><li><strong>Synthetic fine-tuning data</strong> — Model-curated training examples that help it practice and improve.</li><li><strong>Training directives</strong> — Instructions or “rules” for improving its own reasoning and responses.</li><li><strong>Test questions</strong> — Self-generated evaluation material to measure progress.</li></ul><h4>How It Works</h4><ol><li><strong>Self-edits</strong> — The model reviews its own outputs and suggests improvements.</li><li><strong>Supervised fine-tuning (e.g., LoRA)</strong> — These self-edits are incorporated into lightweight fine-tuning pipelines.</li><li><strong>Reinforcement learning</strong> — The model optimizes its behavior by rewarding useful edits and penalizing poor ones.</li></ol><p>Through this cycle, SEAL transforms LLMs from <strong>passive learners</strong> — dependent on curated datasets — into <strong>active learners</strong> capable of continuous self-improvement.</p><h3>Self-Edits</h3><p>One of SEAL’s key innovations is the idea of <strong>self-edits</strong>. Instead of relying only on external labels or curated examples, the model reflects on its own output and suggests modifications. These edits can happen at two levels:</p><ol><li><strong>Rewritten Knowledge</strong></li></ol><ul><li>The model takes an input passage and rewrites it into <strong>clearer, distilled implications</strong>.</li><li>Example: If the passage says <em>“Marie Curie discovered radium”</em>, the implication might be <em>“Radium was discovered by Marie Curie.”</em></li><li>This ensures the knowledge is directly usable for fine-tuning.</li></ul><p><strong>2. Optimization Hyperparameters</strong></p><ul><li>Beyond knowledge, the model also proposes <strong>how to train itself</strong> — like setting the learning rate, choosing augmentations, or deciding the number of epochs.</li><li>These are critical knobs in fine-tuning, and SEAL learns to configure them dynamically for each edit.</li></ul><h4>Why This Matters :</h4><p>Self-edits transform LLMs from passive learners into <strong>active learners</strong>.</p><ul><li>They not only decide <em>what</em> to learn (knowledge edits)</li><li>But also <em>how</em> to learn it (hyperparameter edits).</li></ul><p>This dual role of self-editing is what makes SEAL a powerful framework for continuous adaptation.Synthetic Data Generation in SEAL</p><p>Crucially, the generated self-edits are designed to be <strong>directly useful for gradient-based updates</strong> — making them a practical source of high-quality training signals rather than just auxiliary text.</p><p>In other words, <strong>SEAL turns synthetic data from a heuristic patch into a core learning mechanism</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fv2i7UlBy44gdYYtJcCyFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9RnMSc1SsYya_PXJc0y5gw.png" /></figure><h3>Synthetic Data Generation in SEAL</h3><p>One of the major challenges in improving large language models (LLMs) has been the reliance on heuristics or hand-crafted rules for creating synthetic training data. These methods often lack adaptability and may not produce examples that truly enhance the model’s learning.</p><p>SEAL introduces a more intelligent approach: it uses <strong>reinforcement learning (RL)</strong> to train a <strong>generative policy</strong> that produces <em>self-edits</em>. Unlike static synthetic datasets, these edits are <strong>dynamically generated</strong> during training.</p><p>Why is this powerful? Because the synthetic data is not just random augmentation — it is <strong>tailored to maximize downstream performance</strong>. Every edit the model generates is directly evaluated for how useful it is in updating the model’s parameters via gradient descent.</p><p>In short, SEAL turns synthetic data generation into a <strong>closed-loop optimization process</strong>: the model generates examples, tests them, and refines its generative policy to continuously produce higher-quality learning signals.</p><h3>Knowledge Updation in SEAL</h3><p>Keeping large language models up to date with the latest knowledge has always been a challenge. Traditional methods often take one of two paths. The first is to directly update the model weights tied to specific facts. While this may seem straightforward, it tends to be brittle, with poor generalization to related queries. The second path is to generate synthetic fine-tuning data from context. For example, researchers have tried <strong>implication-based fine-tuning</strong>, which already shows improvements over in-context learning, and <strong>QA-style fine-tuning</strong>, which typically performs even better.</p><p>SEAL takes this second approach but pushes it further. Instead of relying on fixed heuristics or human-designed strategies for generating finetuning data, SEAL uses <strong>reinforcement learning</strong> to train a generative policy that produces synthetic data specifically optimized for improving downstream task performance.</p><p>One of SEAL’s most important innovations is its <strong>agnosticism to prompt format</strong>. Rather than being tied to a single data style — such as implications or question-answer pairs — SEAL allows the model to <strong>discover which representation works best</strong> for integrating new knowledge. This flexibility removes the dependency on manual prompt engineering and ensures that the updates are directly useful for gradient-based model learning.</p><p>The result is a knowledge-updating process that is <strong>dynamic, adaptive, and far more robust</strong> in real-world scenarios, where facts change constantly and models must continuously evolve.</p><h3>Test-Time Training in SEAL</h3><p>One of the most innovative aspects of SEAL is how it adapts models on the fly through <strong>test-time training (TTT)</strong>. Unlike traditional training, where updates happen only during offline finetuning, SEAL allows the model to <strong>temporarily adjust its weights in real time</strong> based on the input it receives.</p><p>At the core, SEAL integrates <strong>TTT-like updates into its inner loop</strong>. For every new example, the model applies <strong>LoRA-based finetuning</strong>, effectively personalizing its parameters at the granularity of a single input. Instead of making a single static adjustment, SEAL generates multiple candidate <strong>self-edits</strong>, evaluates them, and selects the one that maximizes performance.</p><p>What’s remarkable is that SEAL carries out this process with <strong>just one example per TTT episode</strong> — yet it still generalizes effectively to larger-scale scenarios. This makes it particularly powerful for:</p><ul><li><strong>Knowledge incorporation</strong> — seamlessly integrating new facts as they appear.</li><li><strong>Continued pretraining</strong> — allowing models to go beyond in-context learning, dynamically improving as new data streams in.</li></ul><p>In essence, SEAL transforms test-time from a passive evaluation stage into an <strong>active learning phase</strong>, enabling LLMs not only to consume knowledge but also to refine themselves on the spot.</p><h3>Reinforcement Learning in SEAL</h3><p>Reinforcement Learning (RL) is a cornerstone of modern LLM training, but SEAL applies it in a <strong>fundamentally different way</strong> than approaches like RLHF (Reinforcement Learning from Human Feedback).</p><p>Traditionally, RLHF is used to align a model’s final outputs with <strong>human preferences</strong> — making the answers sound more natural, polite, or safe. Similarly, task-specific RL is often applied to optimize for <strong>reasoning accuracy</strong> or <strong>trace correctness</strong>, ensuring models stay logically consistent.</p><p>SEAL, however, takes a novel direction. Instead of applying RL to optimize <strong>final answers</strong>, it applies RL to the <strong>process of self-edit generation</strong>. In other words, SEAL uses reinforcement learning to train the model on <em>how to improve itself</em>.</p><p>By treating self-edits as actions and downstream performance as rewards, SEAL learns to generate <strong>higher-quality edits over time</strong>, making its training more adaptive, efficient, and aligned with task performance — without relying solely on human supervision.</p><p>This subtle shift — using RL not to polish answers but to <strong>optimize the model’s ability to refine itself</strong> — is what makes SEAL stand out in the landscape of self-improving AI.</p><h3>Meta Learning in SEAL</h3><p>At its core, <strong>meta learning</strong> is about <em>learning how to learn</em>. Instead of focusing only on solving tasks directly, meta learning equips models with strategies to adapt, improve, and generalize across tasks.</p><p>SEAL incorporates meta learning principles into both <strong>supervised learning</strong> and <strong>reinforcement learning</strong> contexts.</p><ul><li><strong>Outer-loop training</strong>: SEAL’s meta learning framework trains the model not just to output answers, but to generate <strong>self-edits</strong> — structured refinements that improve its reasoning process.</li><li><strong>Knowledge incorporation</strong>: Inspired by recent LLM work on token-wise weight generators, SEAL integrates meta learning techniques to help models absorb and adapt new knowledge efficiently.</li><li><strong>Leveraging generative power</strong>: SEAL doesn’t throw away the strengths of LLMs — it builds on their existing <strong>generative capabilities</strong>, directing them toward self-improvement and dynamic refinement.</li></ul><p>By embedding meta learning, SEAL enables models to move from passive learners (merely consuming labeled data) to <strong>active learners</strong> that continuously refine their own training signals.</p><h3>Self-Improvement in SEAL</h3><p>A growing area in LLM research is <strong>self-learning</strong>, where models improve without relying solely on human feedback. Approaches like <strong>RLAIF (Reinforcement Learning with AI Feedback)</strong> and <strong>self-rewarding language models</strong> push this frontier.</p><p>However, these methods face a critical challenge:</p><ul><li>They <strong>rely on the model’s current judgment</strong> to assess its own outputs.</li><li>If the model is biased or makes systematic mistakes, it risks <strong>reinforcing those errors</strong>, leading to unstable or unreliable learning.</li></ul><p>SEAL takes a different path. Instead of depending only on the model’s self-assessments, it:</p><ul><li><strong>Uses external data</strong> to guide and ground improvements.</li><li>Provides a <strong>more reliable and scalable</strong> framework for self-enhancement.</li><li>Crucially, SEAL teaches models <strong>how to generate and effectively use synthetic data</strong> for iterative self-improvement.</li></ul><p>This makes SEAL’s approach not only more <strong>robust against bias</strong> but also <strong>future-proof</strong>, as it learns to leverage its own data generation capabilities responsibly.</p><h3>General Framework of SEAL</h3><p>At the heart of SEAL lies a <strong>two-loop architecture</strong> that governs how the model learns and improves itself:</p><h4>Outer RL Loop</h4><ul><li>Responsible for <strong>optimizing self-edit generation.</strong></li><li>Ensures the model explores and identifies the best possible edits to improve its own outputs.</li></ul><h4>Inner Update Loop</h4><ul><li>Performs <strong>gradient descent updates</strong> on the model.</li><li>Incorporates the optimized edits from the outer loop, refining the model’s parameters.</li></ul><p>Together, these loops form a <strong>closed learning cycle</strong> where SEAL continuously proposes improvements (outer loop) and internalizes them through direct learning (inner loop).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zS8gaHDnX4M__jOUtGVS3Q.png" /></figure><h3>Understanding SEAL’s Core Equation</h3><p>At the heart of SEAL lies a simple but powerful idea: <strong>teach the model to improve itself through self-edits, guided by reinforcement learning.</strong></p><p>Let’s break this down.</p><ul><li>We start with a language model, denoted as <strong><em>LMθ</em></strong>, where θ represents the model’s parameters.</li><li>SEAL works on <strong>task instances</strong> (C, τ):</li><li><strong>C (Context):</strong> The information the model should learn or adapt from.</li><li><strong>τ (Evaluation):</strong> The downstream task used to check how well the model adapted.</li></ul><p>For example:</p><ul><li>In <strong>knowledge incorporation</strong>, <strong>C</strong> might be a passage of text the model needs to internalize, and <strong>τ</strong> could be a set of questions and answers about that passage.</li><li>In <strong>few-shot learning</strong>, <strong>C</strong> includes a handful of demonstrations for a new task, and <strong>τ</strong> contains the query input with its ground-truth answer.</li></ul><p>Now, given the context <strong>C</strong>, the model generates a <strong>self-edit (SE)</strong> — essentially a structured update describing how it should adapt. Then, it applies <strong>supervised fine-tuning</strong> on this edit:</p><p><strong>θ′ ← SFT(θ, SE)</strong></p><p>This means the model updates itself to a new version <strong>θ′</strong> by applying the edit it just proposed.</p><h4>Where Reinforcement Learning Comes In</h4><p>The process doesn’t stop there. SEAL uses <strong>reinforcement learning (RL)</strong> to optimize the quality of these self-edits. Here’s how:</p><ol><li>The model <strong>generates a self-edit (SE)</strong> — this is its “action.”</li><li>It <strong>evaluates performance</strong> on <strong>τ</strong> using the updated model <strong>LMθ′</strong>.</li><li>It receives a <strong>reward (r)</strong> based on how well it performed.</li><li>The model updates its policy to maximize this reward over time.</li></ol><p>Formally, the RL objective is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGCk-951AK2Q-jyUY0z6AQ.png" /></figure><h3>The SEAL Algorithm: How Self-Adaptive Learning Works</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3wszvOd_G8ptPEpgtIvTGw.png" /></figure><p>Now that we’ve seen the core equation, let’s look at how SEAL actually runs in practice. The algorithm provides a clear picture of the training process:</p><ol><li><strong>Initialize model parameters (θ)</strong></li></ol><ul><li>Start with a pretrained language model <strong>LMθ</strong>.</li></ul><p>2.<strong> Loop over task instances (C, τ)</strong></p><ul><li><strong>C (Context):</strong> task-specific information (like passages or few-shot demonstrations).</li><li><strong>τ (Evaluation):</strong> how performance will be measured (e.g., answering questions or completing tasks).</li></ul><p>3.<strong> Generate a Self-Edit (SE)</strong></p><ul><li>The model samples a self-edit <strong>SE</strong> from its current parameters <strong>θt</strong></li><li><strong><em>SE∼LMθt​​(⋅∣C)</em></strong></li><li>This self-edit is essentially the model’s proposal for how to adapt itself.</li></ul><p>4.<strong> Apply the Self-Edit (Supervised Fine-Tuning)</strong></p><ul><li>Update the parameters using the self-edit:</li><li><strong><em>θ′←SFT(θ,SE)</em></strong></li><li>This creates an updated model <strong>LMθ′</strong>.</li></ul><p>5.<strong> Evaluate the Updated Model</strong></p><ul><li>Test <strong>LMθ′</strong> on the evaluation task <strong>τ</strong>.</li><li>Calculate a <strong>reward r(SE, τ, θ)</strong> that reflects how well the updated model performs.</li></ul><p>6.<strong> Update the Policy (Outer RL Loop)</strong></p><ul><li>Use reinforcement learning to adjust the model so that future self-edits lead to better performance.</li><li>This closes the loop: better edits get reinforced, poor edits are discarded.</li></ul><h3>Overcoming the RL Challenge in SEAL</h3><p>One of the unique challenges in SEAL lies in how rewards are defined.<br> Unlike in standard RL setups — where the environment is fixed — the reward in SEAL depends on the <strong>current model parameters (θ)</strong>. This creates a moving target: once the model updates its parameters (θ → θ′), the reward structure shifts accordingly.</p><p>This dependency means that the underlying RL state must technically be represented as <strong>(C, θ)</strong>, where C is the context. However, incorporating θ directly into the context is infeasible. As a result, any (state, action, reward) triples collected using an older version of the model (<strong>θ_old</strong>) may quickly become misaligned with the current version (<strong>θ_current</strong>).</p><p>To address this issue, SEAL adopts an <strong>on-policy approach</strong>:</p><ul><li>Self-edits are sampled directly from the <strong>current model</strong>.</li><li>Rewards are also calculated on the <strong>current model</strong>, ensuring alignment.</li></ul><p>The team experimented with popular on-policy methods such as <a href="https://arxiv.org/pdf/2402.03300"><strong>Group Relative Policy Optimization (GRPO)</strong></a> and <a href="https://arxiv.org/pdf/1707.06347"><strong>Proximal Policy Optimization (PPO)</strong>.</a> However, these approaches led to unstable training.</p><p>Instead, SEAL leverages <a href="https://openreview.net/forum?id=lNAyUngGFK"><strong>ReSTEM (Rejection Sampling + Supervised Fine-Tuning)</strong> </a>— a simpler yet more stable method. By filtering generated samples and fine-tuning only on the best ones, ReSTEM ensures reliable and efficient learning without the instability of more complex RL algorithms.</p><h3>ReSTᴱᴹ: Making Training More Stable</h3><p>One of the big challenges in fine-tuning language models with reinforcement learning is <strong>instability</strong>. The model may improve for a while, but then suddenly collapse into poor performance because it overfits to noisy feedback or unlucky updates.</p><p>To solve this, ReSTᴱᴹ introduces a simple but powerful idea: <strong>filter training signals using binary rewards</strong>.</p><ul><li>When the model makes an edit, it is <strong>checked against the reference</strong>.</li><li>If the edit makes the output <strong>better</strong> → it gets a reward of <strong>1 (accept)</strong>.</li><li>If it doesn’t improve things → it gets a reward of <strong>0 (reject)</strong>.</li></ul><p>This binary reward system ensures that only <strong>useful edits</strong> are kept for further training, while noisy or harmful updates are ignored.</p><p>By repeating this process, ReSTᴱᴹ builds a dataset of <strong>self-generated positive examples</strong>, which makes fine-tuning much more stable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7mQ5mKCAJev_pYCKyW3Fhw.png" /></figure><h3>The EM-Cycle: Optimizing Self-Edits</h3><p>ReSTᴱᴹ frames the outer training loop as an <strong>Expectation–Maximization (EM)</strong> procedure. That design choice turns a high-variance reinforcement learning problem into a much more stable “sample-and-filter” learning loop. This is a key part of the training process, which provides a principled way to optimize self-edits under the binary reward system.</p><p>The process alternates between two steps:</p><ol><li><strong>E-step (Expectation):</strong></li></ol><ul><li><strong>What happens:</strong> For each context <strong>C</strong> the model samples multiple candidate self-edits <strong>SE</strong> from the <em>current</em> policy <strong>pθ​(SE∣C).</strong></li><li><strong>Evaluation:</strong> Each candidate <strong>SE</strong> is applied (via a lightweight supervised fine-tune / inner update) to produce an updated model <strong>θ′</strong>, which is then evaluated on the downstream task <strong>τ</strong>. A <strong>reward</strong> <strong>r(SE,τ,θ)</strong> is computed — ReSTᴱᴹ uses a simple binary rule (<strong>1</strong> if the adapted model improves on <strong>τ</strong>, <strong>0</strong> otherwise).</li><li><strong>Result:</strong> The E-step produces a <em>filtered</em> set of examples that are judged useful under the current policy. This step effectively estimates which edits are more likely to improve performance under the current model parameters.</li></ul><p>2.<strong> M-step (Maximization):</strong></p><ul><li><strong>What happens:</strong> Using the positive edits identified in the E-step, the M-step updates the policy to increase the likelihood of generating those good edits in the future. Concretely, the model is fine-tuned (SFT) on the subset of self-edits that received reward = 1.</li><li>This ensures that the policy is gradually shifted toward generating edits that align with successful self-improvement.</li></ul><p>This alternating cycle of <strong>evaluating edits (E-step)</strong> and <strong>updating the model (M-step)</strong> helps overcome the instability observed with standard RL methods like PPO or GRPO. Instead of relying on unstable reward-weighted updates, the EM cycle allows a more structured refinement of the policy.</p><p>Together, this EM formulation provides the mathematical backbone for integrating rejection sampling with self-supervised fine-tuning, forming the foundation of the ReSTᴱᴹ approach.</p><h4>Important approximations &amp; limitations</h4><ul><li><strong>Binary reward:</strong> The framework typically uses a binary reward (improved vs not). This is robust but discards fine-grained signal (how much an edit helped).</li><li><strong>Stop-gradient assumption:</strong> When forming the outer gradient, SEAL treats the reward as fixed (non-differentiable) with respect to θ. That avoids backpropagating through the inner SFT update but is an approximation.</li><li><strong>Compute cost:</strong> E-step evaluation requires applying and testing many candidate edits (each requires a small finetune + evaluation), so ReSTᴱᴹ trades compute for stability and cleaner training signals.</li></ul><h3>The Math Behind How SEAL Learns from Its Own Edits</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMvR50teBqKkqVO2vZOBOA.png" /></figure><h4>What problem are these equations solving?</h4><p>SEAL’s goal: teach the model to generate <strong>self-edits</strong> that actually <em>improve performance after the model applies them</em>. Equations (3) and (4) show how to turn that goal into a trainable update — i.e., how to nudge the model so it produces more helpful edits in the future.</p><h4>The simple idea</h4><ul><li>Generate many candidate edits for a given context.</li><li>Apply each edit, update the model, and check whether the updated model performs better.</li><li>If an edit helped → keep it and use it as a training example. If it didn’t → ignore it.</li></ul><p>Equations (3)–(4) convert this sampling-and-filtering process into a concrete gradient that we can apply to the model.</p><h4>Equation (3) — the Monte-Carlo policy gradient (intuition)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FZUmA_ELUYTItqLBiS7Q3A.png" /></figure><ul><li><strong>What’s sampled:</strong> <strong><em>N</em></strong> contexts, and <strong><em>M</em></strong> candidate self-edits per context.</li><li><strong>Reward <em>rij</em>​:</strong> binary (1 if edit improved performance after being applied, else 0).</li><li><strong>Effect:</strong> Only rewarded edits (where <strong><em>rij</em></strong>​=1) contribute to the gradient. Each rewarded edit increases the log-probability of that edit under the model policy.</li></ul><p><strong>Takeaway:</strong> Eq. (3) says “average the gradient signals from <em>only the helpful edits</em>.” It’s a Monte-Carlo (sample-based) approximation of the ideal policy gradient.</p><h4>Equation (4) — token-level expansion for autoregressive models</h4><p>Because language models generate tokens one-by-one, Eq. (4) expands the sequence-level log-probability into token-level terms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1SNa-li-pSa4bXA5bDDBbw.png" /></figure><p><strong>Why this matters:</strong> Practically you perform standard supervised gradients (cross-entropy) on the tokens of <em>rewarded</em> edits — token by token — and skip edits that failed.</p><h4>Why treat the reward as fixed?</h4><p>The reward is measured <strong>after</strong> applying the edit and updating the model, so it’s not a differentiable function of the current parameters. SEAL therefore <strong>stops gradients through the reward</strong> (treats it as a fixed scalar). That simplifies optimization.</p><h4>How this maps to ReSTᴱᴹ (“rejection sampling + SFT”)</h4><p>With binary rewards, the math reduces to a simple procedure:</p><ol><li>Sample many edits.</li><li>Keep only the winners (those with reward = 1).</li><li>Run supervised fine-tuning (SFT) on those winners.</li></ol><p>So ReSTᴱᴹ = <strong>filtered sampling</strong> (E-step) + <strong>SFT on winners</strong> (M-step). Eq. (3)-(4) are the formal gradient version of that process.</p><p>Equations (3) and (4) implement a practical policy update: <em>sample many self-edits, reject the bad ones, and reinforce the good ones by training the model to make them more likely next time.</em></p><h3>Teacher-Student Formulation in SEAL</h3><p>In its original design, <strong>SEAL</strong> uses a <strong>single model</strong> that plays two roles at once:</p><ul><li><strong>Generator</strong>: Produces self-edits (SEs) to adapt to new knowledge or tasks.</li><li><strong>Learner</strong>: Updates its own parameters based on those self-edits using supervised fine-tuning (SFT).</li></ul><p>While this unified setup works, it can sometimes limit flexibility. To address this, researchers propose a <strong>teacher–student formulation</strong> where the roles are split:</p><ul><li><strong>Teacher</strong>: Responsible for generating self-edits, guided by reinforcement learning (RL).</li><li><strong>Student</strong>: Applies those edits to update its knowledge and improve performance through SFT.</li></ul><p>This separation makes the process more structured. The <strong>teacher focuses purely on exploration and generation</strong>, while the <strong>student specializes in learning and adaptation</strong>. By decoupling the two, SEAL becomes more modular and potentially more effective at learning across diverse tasks.</p><h3>Domain Instantiations in SEAL</h3><p>To evaluate SEAL’s ability to learn and adapt, researchers tested it across two key domains: <strong>knowledge incorporation</strong> and <strong>few-shot learning</strong>.</p><h4>Knowledge Incorporation</h4><p>One of the most important challenges in AI is updating a model with <strong>new factual information</strong> and ensuring it can <strong>remember that knowledge without extra context</strong>.</p><p>In SEAL:</p><ul><li>New facts are directly injected into the model’s <strong>weights</strong>.</li><li>The model can then recall this information <strong>without needing the original context passage</strong>.</li><li>To test this, a <em>no-passage-in-context</em> version of <strong>S</strong>tanford <strong>Qu</strong>estion <strong>A</strong>nswering <strong>D</strong>ataset(<strong>SQuAD)</strong> was used, where the model answers factual questions based only on its internalized knowledge.</li></ul><p>This setup shows how SEAL can <strong>truly integrate knowledge</strong>, not just memorize context temporarily.</p><h4>Few-Shot Learning</h4><p>Another test focused on SEAL’s ability to <strong>generalize from only a few examples</strong> — something humans do naturally but most models struggle with.</p><p>In SEAL:</p><ul><li>The model is trained to <strong>learn new tasks from just a handful of samples</strong>.</li><li>This simulates <em>human-like quick learning</em> when facing unseen problems.</li><li>A simplified version of the <a href="https://arxiv.org/abs/2412.04604"><strong>ARC-AGI benchmark</strong></a> was used to measure how well SEAL adapts to brand-new tasks with minimal guidance.</li></ul><p>This experiment highlights SEAL’s potential for <strong>fast adaptation</strong>, making it closer to how humans learn in real-world scenarios.</p><h3>Knowledge Incorporation</h3><p>One of the biggest challenges for language models is <strong>absorbing new information quickly and efficiently</strong>. Instead of retraining from scratch on massive datasets, researchers are exploring smarter ways to “teach” models from small passages of text.</p><p>A recent approach looks promising:</p><ol><li>Start with a passage of information.</li><li>Ask the model itself to <strong>generate related content</strong>, such as logical inferences, restatements, or implications derived from the passage.</li><li>Fine-tune the model on both the original passage and these generated statements.</li></ol><p>For example, given a short context <em>C</em>, the model might be prompted with:</p><blockquote><em>“List several implications derived from the content.”</em></blockquote><p>The results could include inferences, logical consequences, or paraphrased versions of the passage. These self-generated statements are then used for <strong>supervised fine-tuning (SFT)</strong>, where the model’s parameters are updated in a lightweight manner using <strong>LoRA (Low-Rank Adapters)</strong>.</p><h4>Why does this work?</h4><ul><li>By rephrasing or restructuring information, the model gets multiple “views” of the same knowledge.</li><li>This makes it easier for the model to <strong>internalize and retain</strong> the new information.</li><li>Since the fine-tuning updates are small and efficient, this process can be repeated many times without heavy computation.</li></ul><p>Finally, during reinforcement learning (RL) training, the model is evaluated on downstream tasks, and its accuracy becomes the reward signal. Over time, the model learns how to restructure passages in the most effective way for assimilation.</p><p>This method essentially turns <strong>knowledge incorporation</strong> into a process of teaching the model how to <em>teach itself</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnfWzcD4S6y_cNGDV5VEpw.png" /></figure><h3>Few-Shot Learning</h3><p>One of the most exciting tests for SEAL is <strong>Few-Shot Learning</strong>.<br> Here, the challenge is to solve a task using only a handful of examples — something that really pushes a model’s ability to reason and generalize.</p><p>To evaluate this, we use the <strong>Abstraction and Reasoning Corpus (ARC)</strong> benchmark. Each ARC task gives:</p><ul><li>A few input-output pairs (the “demos”)</li><li>A new test input, where the model must predict the correct output</li></ul><p>Normally, researchers use manually designed rules (like picking augmentations or setting hyperparameters) to make the model adapt. Instead, <strong>SEAL learns these decisions automatically.</strong></p><h4>How SEAL Adapts</h4><p>SEAL approaches few-shot learning through <strong>Test-Time Training (TTT)</strong>:</p><ul><li>The few given examples are <strong>augmented</strong> (e.g., rotated, flipped, resized).</li><li>SEAL generates a <strong>self-edit</strong> — basically an instruction for how to adapt.</li><li>This self-edit chooses:</li><li>Which data augmentations to apply</li><li>What optimization settings to use (learning rate, number of epochs, etc.)</li><li>Using these, the model is <strong>fine-tuned on the spot</strong> (via LoRA-based finetuning).</li></ul><p>Finally, the adapted model is tested on the new input. The better it performs, the higher the reward for SEAL’s policy that generates these self-edits.</p><h4>Tools SEAL Can Choose From</h4><p>The toolkit comes from <a href="https://arxiv.org/abs/2411.07279">Akyürek et al.</a> and includes:</p><ul><li><strong>Data Augmentations</strong>: rotations, flips, reflections, resizing, chained transformations</li><li><strong>Optimization Choices</strong>: learning rate, number of epochs, loss function scope</li></ul><p>This allows SEAL to autonomously design its own adaptation pipeline, instead of relying on handcrafted heuristics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7C363qUi8E_k33ColfBbw.png" /></figure><h3>Results : Few-Shot Learning</h3><p>To test the effectiveness of SEAL, the researchers experimented with <strong>Llama-3.2–1B-Instruct</strong>, a small open-source model that had <strong>no prior ARC-specific training</strong>. Since ARC tasks are notoriously hard for models without such pretraining, they carefully curated a smaller subset: <strong>11 tasks from the training set and 8 from the evaluation set</strong>. These were chosen to ensure they could be solved under optimal test-time training (TTT) settings.</p><p>For training, SEAL used the <strong>ReSTᴱᴹ framework</strong> by generating <strong>15 self-edits per training task</strong>. Each self-edit was applied separately, producing 15 adapted versions of the model. Only those edits that led to <strong>correct outputs on held-out test examples</strong> were reinforced, ensuring the model learned edits that actually improved performance.</p><p>During evaluation, the model generated <strong>5 self-edits per unseen task</strong>, each applied independently. The <strong>success rate</strong> — the percentage of edits that produced correct outputs — was then measured, offering a direct reflection of SEAL’s ability to generate useful adaptations.</p><p>To put these results in context, the team compared SEAL against three baselines:</p><ol><li><strong>ICL (In-Context Learning):</strong> The model is given few-shot examples and directly prompted to answer.</li><li><strong>TTT + Self-Edit (no RL):</strong> The model attempts self-editing during test-time training but without reinforcement learning to optimize which edits to apply.</li><li><strong>Oracle TTT:</strong> An upper-bound setup where the model uses <strong>handcrafted optimal configurations</strong> from prior work (<a href="https://arxiv.org/abs/2411.07279">Akyürek et al.</a>).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*aLN0kTxDeFyHZ2eLB38NyA.png" /></figure><p>The findings were striking. <strong>SEAL achieved a 72.5% adaptation success rate</strong>, compared to just <strong>20% with raw self-edits</strong> and <strong>0% without any adaptation</strong>. While it didn’t yet surpass the handcrafted Oracle TTT setup, this leap demonstrates SEAL’s strong ability to learn <strong>self-edit strategies</strong> that generalize across tasks.</p><h3>Results: Knowledge Incorporation</h3><p>One of the key challenges in adapting large language models is helping them <strong>absorb and retain new factual knowledge</strong>. To test this, the researchers experimented with <strong>Qwen2.5–7B</strong> using passages from the <strong>SQuAD dataset</strong>. SQuAD is a relatively simple dataset: while its passages can be fully understood in context, the base model struggles to reliably answer related questions without explicitly seeing them.</p><p>To evaluate knowledge incorporation, they conducted two rounds of <strong>ReSTᴱᴹ training</strong> on 50 contexts and compared their method, <strong>SEAL</strong>, against several baselines:</p><ol><li><strong>Base Model</strong> — Evaluated on QA tasks without adaptation or context.</li><li><strong>Train on Passage Only</strong> — Finetuned on the passage using standard language modeling loss.</li><li><strong>Train on Passage + Synthetic Data (Qwen2.5–7B)</strong> — Trained with passages and synthetic implications generated by the base model.</li><li><strong>Train on Passage + GPT-4.1 Synthetic Data</strong> — Trained with passages and synthetic implications generated by GPT-4.1.</li></ol><h4>Key Results</h4><p>In the <strong>single-passage setting (n = 1)</strong>, simply training on the passage gave only a negligible boost (33.5% vs. 32.7% for the base model). However, when synthetic implications were added:</p><ul><li><strong>GPT-4.1 synthetic data</strong> pushed accuracy to <strong>46.3%</strong> (+12.8 points).</li><li><strong>Qwen2.5–7B synthetic data</strong> improved accuracy to <strong>39.7%</strong> (+6.2 points).</li><li><strong>SEAL outperformed both</strong>, reaching <strong>47.0%</strong>, even surpassing GPT-4.1 despite being a smaller model.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*WZE-g5OSGS2-W6RAaSBy3g.png" /></figure><p>In the <strong>continued pretraining (CPT, n = 200 passages)</strong> setup, SEAL again came out on top with <strong>43.8% accuracy</strong>, showing consistent improvements across a larger dataset. Although absolute performance dropped due to gradient interference, the relative gains remained strong — demonstrating SEAL’s ability to generalize beyond its RL training setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*gqBgdVwSeVtthi-tI6149g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7b0rT9eTStR2taRjHP6xzg.png" /></figure><h3>Limitations of SEAL</h3><h4>Catastrophic Forgetting</h4><p>One of the biggest hurdles in making language models truly adaptive is <strong>catastrophic forgetting</strong> — the tendency of models to overwrite old knowledge when learning something new.</p><p>The broader vision behind SEAL is not just short-term adaptation, but <strong>continual learning</strong>: enabling models to update themselves over time while retaining prior capabilities. For example, an ideal model should be able to integrate new facts, refine reasoning strategies, and adapt to fresh domains, all without losing its ability to solve tasks it had already mastered.</p><p>Our experiments so far focus on how SEAL adapts to <strong>individual self-edits in isolation</strong>. But in real-world scenarios, updates rarely come one at a time. Instead, models would need to <strong>handle a sequence of edits</strong>, much like a person accumulates knowledge across multiple experiences. This is precisely where catastrophic forgetting becomes a challenge.</p><p>To probe this, we simulated a <strong>continual learning setup</strong> in the knowledge incorporation domain. The model received a stream of passages, each prompting a new self-edit. After each update, we re-evaluated the model not just on the new passage, but also on all previously seen tasks.</p><p>The results were telling:</p><ul><li>Performance on earlier tasks <strong>gradually declined</strong> as more edits were introduced.</li><li>However, SEAL did not completely collapse — indicating that it can sustain multiple updates, though imperfectly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*CAB7mzvN1RQV4FjK4lxyKg.png" /></figure><p>This shows that while SEAL demonstrates <strong>initial promise</strong>, it remains vulnerable to forgetting. Moving forward, we see potential in strategies like:</p><ul><li><strong>Reward shaping</strong>, where regressions on earlier tasks are penalized during reinforcement learning.</li><li><strong>Null-space constrained edits</strong>, which confine updates to directions in parameter space that do not interfere with past knowledge.</li><li><strong>Representational superposition</strong>, which allows models to encode new knowledge without overwriting old representations.</li></ul><p>In short, SEAL takes a meaningful step towards <strong>self-adaptive, continually learning models</strong>, but solving catastrophic forgetting will be essential for scaling it into long-term, real-world applications.</p><h4>Computational Overhead</h4><p>One trade-off with SEAL is <strong>computational efficiency</strong>. Unlike other reinforcement learning methods used with large language models, SEAL’s training loop is significantly more expensive.</p><p>Most reward-based approaches rely on lightweight feedback signals:</p><ul><li><strong>Human preference models</strong>: only a single forward pass through a model.</li><li><strong>Verification-based rewards</strong>: often as simple as regex pattern matching.</li></ul><p>By contrast, SEAL uses a <strong>Test-Time Training (TTT) reward loop</strong>, which requires <strong>finetuning and re-evaluating the entire model</strong> to compute the reward. Each self-edit evaluation takes <strong>30–45 seconds</strong>, which adds up quickly when scaling across many edits. This introduces substantial overhead compared to traditional RL loops.</p><p>To make SEAL feasible, the authors leaned heavily on modern GPU infrastructure and optimization libraries:</p><p><strong>Hardware</strong>: All experiments ran on <strong>2× NVIDIA H100 or 2× H200 GPUs</strong>.</p><p><strong>Training optimizations</strong>:</p><ul><li><strong>DeepSpeed ZeRO-3</strong> was used for efficient memory partitioning during supervised fine-tuning.</li><li><strong>vLLM</strong> handled inference efficiently.</li><li><strong>Most expensive step</strong>: The <strong>E-step of ReSTEM training</strong>, where the model generates completions and is graded through an inner loop of finetuning + inference.</li></ul><p>Here’s what one round looks like:</p><ul><li><strong>50 passages × 5 completions × 3 runs per completion = 750 inner-loop iterations</strong></li><li>Time cost: <strong>~6 hours on 2× H100s</strong></li></ul><p>This illustrates the <strong>scale of compute</strong> required to make SEAL work in practice. While the method shows strong potential, its <strong>high computational footprint</strong> may limit accessibility outside well-resourced research labs.</p><p>SEAL demonstrates the power of self-editing LLMs, but its <strong>computational demands are non-trivial</strong>. Future work may focus on reducing this overhead so that continual learning through self-editing becomes more broadly usable.</p><h4>Context-Dependent Evaluation</h4><p>Another limitation of SEAL lies in its reliance on <strong>explicit downstream tasks</strong> tied to every context. Currently, each few-shot demonstration is paired with a held-out query, and each passage is bundled with a reference QA set. While this design makes reward computation straightforward, it also imposes a strong restriction: <strong>SEAL cannot easily scale to unlabeled corpora</strong>, where such reference pairs are unavailable.</p><p>A promising direction forward is to let the model <strong>generate its own evaluation data</strong>. Instead of depending on pre-written queries, SEAL could produce synthetic supervision signals on the fly — such as drafting QA items or designing test cases for each passage while keeping the original context intact. These <strong>model-written queries</strong> would provide immediate supervision for reinforcement learning, potentially enabling SEAL to extend its capabilities beyond curated datasets and into more general training domains.</p><h3>From Limitations to Opportunity</h3><p>SEAL makes clear progress toward self-adapting LLMs, but the limitations we discussed (catastrophic forgetting, compute, and dependence on labeled evaluation) also point directly to the most promising next steps. Rather than seeing these as failures, they are engineering and research opportunities: ways to make SEAL more efficient, more robust, and more broadly useful. Below I outline concrete directions that would unlock the approach at scale.</p><h3>Future directions &amp; vision</h3><h4>1. Scale and efficiency</h4><p>SEAL’s gains come at a computational cost. Reducing that footprint will be essential for real-world adoption. Practical directions include:</p><ul><li><strong>More efficient inner updates</strong> — push further on adapter-based methods (LoRA variants), sparsity, or compressed-update schemes so each self-edit evaluation is cheaper.</li><li><strong>Smarter sampling</strong> — instead of brute-force Monte-Carlo sampling, use learned proposal distributions, active sampling, or a curriculum that focuses compute on promising edits.</li><li><strong>Distributed and asynchronous evaluation</strong> — parallelize inner-loop evaluations or use asynchronous teacher evaluation to amortize cost across many students.</li></ul><h4>2. Continual learning &amp; retention</h4><p>Catastrophic forgetting remains the main barrier to lifelong self-improvement. Promising technical paths:</p><ul><li><strong>Reward shaping for retention</strong> — augment the reward to penalize regressions on prior tasks (e.g., multi-objective rewards that balance new performance with retention).</li><li><strong>Null-space or low-interference updates</strong> — constrain updates to parameter subspaces that minimally disturb previously learned functions (null-space methods, orthogonal gradient updates).</li><li><strong>Representation-based strategies</strong> — explore representational superposition, episodic replay, or modular subnetworks that can store and recall task-specific knowledge without destructive interference.</li></ul><h4>3. Teacher–student and multi-model training</h4><p>Decoupling generation from learning can improve stability and scale:</p><ul><li><strong>Teacher–student pretraining:</strong> train a larger, RL-optimized teacher to produce high-quality synthetic pretraining corpora for many students. This allows expensive RL to be amortized over many cheaper student updates.</li><li><strong>Cross-student generalization:</strong> evaluate how edits generated for one student transfer to different student architectures or sizes. This will be important for production deployment where models vary.</li></ul><h4>4. Scaling to unlabeled, real-world corpora</h4><p>To apply SEAL broadly, we need to move beyond paired (context, task) data:</p><ul><li><strong>Model-generated evaluation data:</strong> let the model draft its own QA items, tests, or verification checks while the passage is still in context. These synthetic evaluations would provide the immediate supervision needed to train on unlabeled corpora.</li><li><strong>Hybrid verification:</strong> combine model-written tests with lightweight automatic validators (heuristics, unit-tests, or external tools) to increase reliability of synthetic rewards.</li></ul><h4>5. Agentic systems &amp; continual autonomy</h4><p>The ultimate vision is agentic models that learn as they act:</p><ul><li><strong>On-the-fly editing during reasoning:</strong> models could choose to perform micro-updates mid-chain-of-thought to steer their current reasoning, or to consolidate insights after completing a reasoning episode.</li><li><strong>Interaction-driven learning loops:</strong> agents that interact with environments could synthesize edits from experience (logs, feedback) and self-update, enabling continual personalization and domain adaptation.</li><li><strong>Safety &amp; governance:</strong> as models self-modify, we must add guardrails — e.g., conservative acceptance thresholds, human-in-the-loop sign-off for persistent edits in production, and logging for auditability.</li></ul><h3>Conclusion &amp; takeaways</h3><p>Reading SEAL feels less like browsing a research paper and more like catching a glimpse of the <strong>next chapter in AI’s story</strong>. This work doesn’t just patch catastrophic forgetting or improve few-shot performance — it hints at a world where models are no longer passive tools, but <strong>active learners that adapt, refine, and grow</strong> over time.</p><p>As an AI Engineer continuously exploring the full spectrum of AI — from machine learning and deep learning to multi-agent systems and LLM orchestration, I see SEAL as a foundational step toward the systems of tomorrow: <strong>agents that not only perform tasks, but self-improve, collaborate, and sustain knowledge without human micromanagement.</strong> That’s not just research — that’s the blueprint for <strong>true intelligence at scale</strong>.</p><p>Here are the crisp takeaways I want you to leave with:</p><ul><li><strong>SEAL bridges memory and learning</strong>: introducing edits without wiping out prior knowledge.</li><li><strong>Context becomes supervision</strong>: the model learns from its own prompts, even without massive labels.</li><li><strong>Future-ready design</strong>: concepts like reward shaping, null-space edits, and teacher–student pretraining position SEAL as a stepping stone to lifelong learning.</li><li><strong>A glimpse into agentic intelligence</strong>: it aligns with the trajectory toward autonomous, multi-agent systems capable of continuous adaptation.</li></ul><blockquote><strong>For readers interested in full experimental setups and hyperparameters, I recommend checking out the </strong><a href="https://jyopari.github.io/posts/seal"><strong>original paper </strong></a><strong>— the details there are gold.</strong></blockquote><blockquote><strong>If this excites you as much as it does me, dive deeper into the paper, explore the repo, and let’s start thinking about how we can turn these ideas into working systems in real-world domains like retail, e-commerce, and beyond.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=321ff9b8076a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>