{"componentChunkName":"component---src-templates-blog-post-js","path":"/encoders-vs-decoders-ai-text-detection/","result":{"data":{"site":{"siteMetadata":{"title":"tech-blog","author":"Alamgir Qazi"}},"markdownRemark":{"id":"009c174e-a351-5eaa-8c8e-7cedd041bc19","excerpt":"Pangram recently published EditLens (ICLR 2026). Instead of just saying whether a piece of text is human or AI, it gives an estimate of how…","html":"<p>Pangram recently published <a href=\"https://arxiv.org/abs/2510.03154\">EditLens</a> (ICLR 2026). Instead of just saying whether a piece of text is human or AI, it gives an estimate of how much of it an AI has edited. They <a href=\"https://www.pangram.com/blog/introducing-open-pangram\">open sourced two versions</a>, one built on RoBERTa-large (an encoder model) and one on Llama-3.2-3B (a decoder).</p>\n<p>The interesting part of their results is on text model didnt saw during training. The Llama model barely drops (0.895 to 0.863 accuracy). The RoBERTa model falls off a cliff (0.881 to 0.695). It gives the reading that decoders generalize better.</p>\n<p>Those two models differ in a lot more than encoder vs decoder. Llama model is about 8 times bigger, reads twice as much text at once [bigger context window] (1024 vs 512 tokens), was trained on much newer data, uses a different tokenizer and was fine-tuned in a different way.</p>\n<h2>The setup</h2>\n<p><a href=\"https://arxiv.org/abs/2507.11412\">Ettin</a> is a family of models where every encoder has a decoder equivalent. Same training data, same recipe, same tokenizer, same number of parameters. The only real difference is the architecture.</p>\n<p>I fine-tuned encoder and decoder pairs at 17M, 32M, 68M, 150M and 400M parameters on the EditLens training set (available on hf), using the EditLens code and settings for everything. A run takes anywhere from a few minutes to half an hour on a single RTX 4090 GPU. I scored the same three test sets that Pangram used: text like the training data, Enron emails, and text written by Llama-3.3-70B.</p>\n<h2>What I found</h2>\n<p>\n  <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/tech-blog/static/6563401797c69b6369a3b84f74b8fabf/6b95e/scaling.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n  \n  <span\n    class=\"gatsby-resp-image-wrapper\"\n    style=\"position: relative; display: block;  max-width: 590px; margin-left: auto; margin-right: auto;\"\n  >\n    <span\n      class=\"gatsby-resp-image-background-image\"\n      style=\"padding-bottom: 52.02702702702703%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAACHVAAAh1QEEnLSdAAABc0lEQVQoz31SbdOjIAz0///H+/JgqYAvCBZUxL0ktr125u4ykwkmm2UlacZxhPczjHXo+wHOWoo9OmPhXA+tO0xU3/cdxhg4wigz4peyaLV945S6YZo8mp8fhRAi2M7zxGOr6JcK51e8bCMyKiJRMNOK2UdMxsHczbuvHIecG6015jlwGnE9YUNBCSPi0DOHgNkOCs4M2EcLZBJQNqn98QvbKKWEsFLCuIjqHWqKYJpKyUogjmet5Ic0Va6dz/obUy/CrusQY8C4FARPSo9dGl6/8nL5fubwmfubQjdMmEKWm7a9yG3ruqGUIgp2ige9EQ+mlAPbtkv+C0N9Qvh4PJBSxrIsyHmVSTFxP4xIOYuqKLULk1KiqXtpZkxer+Exhi9t8A/jRl4nbmafQ6CnifDzjP9Z8/1O19rEJVHzIgT8i6wi0JlV8AB5L3nVjueqfHI0nwm2TApsZ3DTd7StlmcYpxntTcuSc161N9zv3Rfhy34DifAKCWUvaWYAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n    >\n      <img\n        class=\"gatsby-resp-image-image\"\n        style=\"width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;\"\n        alt=\"Encoder vs decoder at each model size\"\n        title=\"\"\n        src=\"/tech-blog/static/6563401797c69b6369a3b84f74b8fabf/fcda8/scaling.png\"\n        srcset=\"/tech-blog/static/6563401797c69b6369a3b84f74b8fabf/12f09/scaling.png 148w,\n/tech-blog/static/6563401797c69b6369a3b84f74b8fabf/e4a3f/scaling.png 295w,\n/tech-blog/static/6563401797c69b6369a3b84f74b8fabf/fcda8/scaling.png 590w,\n/tech-blog/static/6563401797c69b6369a3b84f74b8fabf/efc66/scaling.png 885w,\n/tech-blog/static/6563401797c69b6369a3b84f74b8fabf/c83ae/scaling.png 1180w,\n/tech-blog/static/6563401797c69b6369a3b84f74b8fabf/6b95e/scaling.png 1458w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n      />\n    </span>\n  </span>\n  \n  </a>\n    </p>\n<p>The chart shows how well each model separates AI-edited text from fully AI-generated text (AUROC, where 1.0 is perfect). That’s the hard part of this task. Telling human from AI is basically solved by every model here.</p>\n<p>On text like the training data, the encoder and decoder lines sit on top of each other at every size, so I left that panel out. The difference only shows up on unseen text. There the encoder is never behind by more than a rounding error, and from 68M upwards it’s clearly ahead. The gap is widest around 68M to 150M and gets smaller by 400M.</p>\n<p>A few things surprised me.</p>\n<p>A 68M encoder does as well as a 400M decoder. Every AUROC I measured is within 0.006 of each other. The 150M encoder beats the 400M decoder outright, with less than half the parameters and less than half the training time.</p>\n<p>Pangram’s RoBERTa-large (the grey square) lands close to my decoder line, not my encoder line. On Enron my 400M encoder gets 0.819 macro F1 against RoBERTa’s 0.673, and nearly all of that difference comes from recognising fully AI-generated emails (0.823 vs 0.515 F1). Whatever made RoBERTa collapse, it wasn’t being an encoder. My best guess is its older pretraining. It isn’t the 512 token limit either, since most Enron emails are well under that length.</p>\n<p>Here’s the Enron table in the same format as Pangram’s. Their rows are their published numbers.</p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th align=\"right\">Macro F1</th>\n<th align=\"right\">Human F1</th>\n<th align=\"right\">AI F1</th>\n<th align=\"right\">AI-edited F1</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Pangram Llama-3.2-3B</td>\n<td align=\"right\">0.868</td>\n<td align=\"right\">0.855</td>\n<td align=\"right\">0.936</td>\n<td align=\"right\">0.812</td>\n</tr>\n<tr>\n<td>Ettin encoder 400M</td>\n<td align=\"right\">0.819</td>\n<td align=\"right\">0.867</td>\n<td align=\"right\">0.823</td>\n<td align=\"right\">0.766</td>\n</tr>\n<tr>\n<td>Ettin encoder 150M</td>\n<td align=\"right\">0.746</td>\n<td align=\"right\">0.843</td>\n<td align=\"right\">0.703</td>\n<td align=\"right\">0.691</td>\n</tr>\n<tr>\n<td>Ettin decoder 400M</td>\n<td align=\"right\">0.695</td>\n<td align=\"right\">0.844</td>\n<td align=\"right\">0.576</td>\n<td align=\"right\">0.665</td>\n</tr>\n<tr>\n<td>Ettin encoder 68M</td>\n<td align=\"right\">0.692</td>\n<td align=\"right\">0.844</td>\n<td align=\"right\">0.575</td>\n<td align=\"right\">0.658</td>\n</tr>\n<tr>\n<td>Pangram RoBERTa-large</td>\n<td align=\"right\">0.673</td>\n<td align=\"right\">0.847</td>\n<td align=\"right\">0.515</td>\n<td align=\"right\">0.657</td>\n</tr>\n<tr>\n<td>Ettin decoder 150M</td>\n<td align=\"right\">0.639</td>\n<td align=\"right\">0.832</td>\n<td align=\"right\">0.455</td>\n<td align=\"right\">0.631</td>\n</tr>\n<tr>\n<td>TF-IDF + logistic regression</td>\n<td align=\"right\">0.604</td>\n<td align=\"right\">0.739</td>\n<td align=\"right\">0.505</td>\n<td align=\"right\">0.568</td>\n</tr>\n</tbody>\n</table>\n<p>Pangram’s 3B Llama is still the best model in the table. But it’s 8 times bigger than anything I trained, so it doesn’t say much about architecture on its own.</p>\n<h2>caveats</h2>\n<p>These are one training run per model. Results on unseen data can move a lot between runs, so I want a couple more seeds before calling the 68M result solid.</p>\n<p>The decoders might be at a disadvantage in how they classify. The encoder averages over every word and starts with part of a pretrained classification head. The decoder only looks at the last word and its head starts from scratch. That’s the standard way to do it, and it’s the same setup Pangram’s Llama uses, but it could hurt small decoders more than big ones. Trying averaging for the decoders is next on my list.</p>\n<h2>so</h2>\n<p>With everything else held equal, decoders don’t generalize better at this task, at least up to 400M. If anything encoders do, especially at smaller sizes, and the gap closes as the models get bigger. The big difference in the EditLens results looks like it comes from comparing an older, smaller encoder with a newer, bigger decoder.</p>\n<h2>What about JEV</h2>\n<p>Jev is a very interesting model and architecture. This is worth reviewing and will tak a look at it as an option in this encoder/decoder architecture world.</p>","frontmatter":{"title":"Do Decoders Really Generalize Better at Spotting AI-Edited Text?","date":"September 21, 2026"}}},"pageContext":{"slug":"/encoders-vs-decoders-ai-text-detection/","previous":{"fields":{"slug":"/install-hortonworks-data-platform-hdp-3.1.5/"},"frontmatter":{"title":"Install Multi-node Hadoop using Hortonworks Data Platform (HDP) 3.1.5 on Ubuntu 18 LTS"}},"next":null}},"staticQueryHashes":[]}