{"id":112551,"date":"2026-08-31T12:00:00","date_gmt":"2026-08-31T12:00:00","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=112551"},"modified":"2026-08-25T08:33:25","modified_gmt":"2026-08-25T08:33:25","slug":"is-ai-already-learning-from-our-old-poor-quality-code","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/ai\/is-ai-already-learning-from-our-old-poor-quality-code\/","title":{"rendered":"Is AI already learning from our old, poor-quality code?"},"content":{"rendered":"\n<p><em><strong>In this Simple Talk opinion piece, Greg Low unpacks how AI models actually filter and weigh training data, why the most common answer isn&#8217;t always the best one, and why truth itself can depend on timing and context \u2014 not just quality.<\/strong><\/em><\/p>\n\n\n\n<p id=\"h-\">A while back, <a href=\"https:\/\/blog.greglow.com\/2024\/08\/02\/what-has-chatgpt-got-to-do-with-baseball-umpiring\/\" target=\"_blank\" rel=\"noreferrer noopener\">I wrote about my experiences with trying to see if ChatGPT could answer questions as though it was a baseball umpire<\/a>. It did quite poorly but, curiously, it got hard questions <em>right<\/em> and easy questions <em>wrong<\/em> &#8211; the complete opposite of what I thought it would do. As such, I&#8217;m sure that the problem was <em>what<\/em> it was learning from. <\/p>\n\n\n\n<p id=\"h-\">Furthermore, I realized that the only people who ever discussed the <em>hard<\/em> concepts were people who knew what they were talking about. So many other people had an opinion &#8211; often wrong &#8211; about the <em>easy<\/em> issues. <\/p>\n\n\n\n<p id=\"h-\">Naturally, this left me wondering: where exactly do <a href=\"https:\/\/www.ibm.com\/think\/topics\/large-language-models\" target=\"_blank\" rel=\"noreferrer noopener\">LLMs<\/a> really learn from?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-learning-from-the-wrong-code\">Learning from the wrong code<\/h2>\n\n\n\n<p>I was interviewing a friend for a podcast and he pointed out that the same thing applies to code we write. If I look back at code I wrote years ago, I\u2019d probably cringe. Since then, I\u2019ve learned so much more about what to do right.<\/p>\n\n\n\n<p>If an LLM is trained on all that code, from all those years &#8211; that\u2019s pretty scary! It&#8217;s little wonder that it\u2019s likely to produce sub-standard code.<\/p>\n\n\n\n<p>The challenge is how it would know the difference &#8211; and not just for old code. If an LLM is being trained on code that&#8217;s simply out there on the internet, it can easily come across a mix of excellent, terrible <em>and<\/em> beginner code. Or even simplified code examples for teaching purposes&#8230;or techniques that were once correct but no longer are.<\/p>\n\n\n\n<p>The list goes on: what about old <a href=\"https:\/\/stackoverflow.com\/questions\" target=\"_blank\" rel=\"noreferrer noopener\">Stack Overflow<\/a> answers that have since been superseded, and\/or answers that only work for one production version?<\/p>\n\n\n\n<p>And what about all the code that&#8217;s been written to demonstrate what <em>not<\/em> to do &#8211; and code that happens to work but is architecturally awful?<\/p>\n\n\n\n<p>Superficially, these can all look quite similar in training data. So, perhaps it&#8217;s not <em>\u201cthe LLM has no idea who to learn from.&#8221;<\/em> <\/p>\n\n\n\n<p>Instead, it&#8217;s more a case of, <em>\u201cthe difficult problem isn&#8217;t finding examples. It&#8217;s knowing which examples deserve to be treated as authoritative, under which circumstances, and at what point in time.\u201d<\/em><\/p>\n\n\n\n<p>Another of my friends recently pointed out to me that <em>&#8220;experts don&#8217;t often write down what THEY think is obvious&#8221;.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-learning-without-enough-context\">Learning without enough context<\/h2>\n\n\n\n<p>A related and interesting issue relates to <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_programming_languages\" target=\"_blank\" rel=\"noreferrer noopener\">code dialects<\/a>. With the baseball umpiring questions, I noticed that ChatGPT had mixed softball rules with baseball rules. This led me to be believe that it probably wasn&#8217;t given enough information about the differences between the two sports when it was being trained.<\/p>\n\n\n\n<p>A similar thing applies to code. I recently saw this AI-produced code for SQL Server:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \" >SELECT CONCAT(c.FirstName, ' ', c.LastName) AS CustomerName,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 o.SalesOrderID, o.OrderDate\n\n\u00a0FROM SalesLT.Customer c\n\n\u00a0INNER JOIN dbo.GetCustomerOrders(c.CustomerID) o ON 1 = 1\n\n\u00a0WHERE c.CustomerID = 1;<\/pre><\/div>\n\n\n\n<p>This is <em>not<\/em> valid SQL Server code! I think it would work in <a href=\"https:\/\/www.ibm.com\/products\/db2\" target=\"_blank\" rel=\"noreferrer noopener\">Db2<\/a>, but not most other dialects. In SQL Server, that <code>INNER JOIN<\/code> should be a <code>CROSS APPLY<\/code>.<\/p>\n\n\n\n<p>Initially, I thought the AI must have seen some SQL code and decided to learn from it, and then mistakenly decided it was relevant to me. That wasn&#8217;t the case. When I asked OpenAI what it thought about the code, it told me it should run. <\/p>\n\n\n\n<p>Upon pointing out that it would <em>not<\/em> run &#8211; and asking the bot why it (incorrectly) thought it would &#8211; its answer was fascinating:<\/p>\n\n\n\n<p><em>&#8220;Why I thought it might work: I was pattern-matching from SQL dialects and products where a function call in the right side of a join can behave laterally, and I overgeneralized that to SQL Server. <\/em><br><br><em>In other words, I mentally collapsed these two ideas into one: \u201cSQL Server supports joining to TVFs\u201d \u201ctherefore this correlated <code>INNER JOIN \u2026 ON 1=1<\/code> should work\u201d That second step was wrong. <\/em><br><br><em>So, the real mistake was not checking the correlated versus uncorrelated distinction before answering. You were right to push back.&#8221;<\/em><\/p>\n\n\n\n<p>OK then, I suppose. So, every individual piece of the answer looks plausible, but the combination is invalid.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-popularity-vs-correctness\">Popularity vs correctness<\/h2>\n\n\n\n<p>A common programming pattern might occur millions of times because it&#8217;s easy, familiar, copied from tutorials, or has been around for 20 years. Unfortunately, a better technique may be comparatively rare.<\/p>\n\n\n\n<p>So, an LLM&#8217;s statistical advantage can become a disadvantage. The most common answer is not necessarily the best answer.<\/p>\n\n\n\n<p>I can imagine:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/rbar-row-by-agonizing-row\/\" target=\"_blank\" rel=\"noreferrer noopener\">row-by-row<\/a> database processing versus set-based processing;<br><br><\/li>\n\n\n\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/the-basic-t-sql-select-statement\/\" target=\"_blank\" rel=\"noreferrer noopener\">SELECT *<\/a><br><br><\/li>\n\n\n\n<li>concatenating SQL strings instead of parameterizing them;<br><br><\/li>\n\n\n\n<li>catching an exception and doing nothing;<br><br><\/li>\n\n\n\n<li>unnecessary <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/database-administration-sql-server\/database-branching-and-merging-strategies\/\" target=\"_blank\" rel=\"noreferrer noopener\">abstraction layers<\/a>;<br><br><\/li>\n\n\n\n<li>blindly wrapping columns in functions in <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/quantifier-predicates\/\" target=\"_blank\" rel=\"noreferrer noopener\">predicates<\/a>;<br><br><\/li>\n\n\n\n<li>outdated JavaScript\/Python\/<a href=\"https:\/\/www.red-gate.com\/simple-talk\/development\/dotnet-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">.NET<\/a> idioms;<br><br><\/li>\n\n\n\n<li>old security practices that were once widespread.<\/li>\n<\/ul>\n<\/div>\n\n\n<p>Software development has spent decades accumulating examples of how people <em>did<\/em> things, but not necessarily examples of how we <em>should<\/em> do them.<\/p>\n\n\n\n<section id=\"my-first-block-block_9c3c512526a603696b16928be1feab9c\" class=\"my-first-block alignwide\">\n    <div class=\"bg-brand-600 text-base-white py-5xl px-4xl rounded-sm bg-gradient-to-r from-brand-600 to-brand-500 red\">\n        <div class=\"gap-4xl items-start md:items-center flex flex-col md:flex-row justify-between\">\n            <div class=\"flex-1 col-span-10 lg:col-span-7\">\n                <h3 class=\"mt-0 font-display mb-2 text-display-sm\">Subscribe to the Simple Talk newsletter<\/h3>\n                <div class=\"child:last-of-type:mb-0\">\n                                            Get selected articles, event information, podcasts and other industry content delivered straight to your inbox.                                    <\/div>\n            <\/div>\n                                            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/subscribe\/\" class=\"btn btn--secondary btn--lg\" aria-label=\"Subscribe now: Subscribe to the Simple Talk newsletter\">Subscribe now<\/a>\n                    <\/div>\n    <\/div>\n<\/section>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-are-llms-learning\">How are LLMs learning?<\/h2>\n\n\n\n<p><strong>I&#8217;ve spent some time with people involved in training LLMs. Here&#8217;s a summary of what I&#8217;ve learned about how they do the training.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-basic-statistical-filtering\">Basic statistical filtering<\/h3>\n\n\n\n<p><strong>Clearly, a model is trained on a very large collection of text assembled from multiple sources. But they don&#8217;t just accept all text. They start with substantial filtering and processing. <\/strong><\/p>\n\n\n\n<p>Now, some filtering is just mechanical. For example, systems can detect and remove (or at least reduce) spam and SEO-generated pages, duplicated or near-duplicated material, and machine-generated gibberish. <\/p>\n\n\n\n<p>It can also identify and remove pages consisting mostly of navigation or <a href=\"https:\/\/en.wikipedia.org\/wiki\/Boilerplate_text\" target=\"_blank\" rel=\"noreferrer noopener\">boilerplate<\/a>, certain unsafe or inappropriate material, and extremely low-quality text. They also estimate of the <em>quality<\/em> of each item to determine if it should be used for training.<\/p>\n\n\n\n<p>For example, compare:<\/p>\n\n\n\n<p><em>&#8220;Some SQL Server isolation levels use <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/postgresql\/multi-version-concurrency-control-mvcc-in-postgresql-learning-postgresql-with-grant\/\" target=\"_blank\" rel=\"noreferrer noopener\">MVCC<\/a> to allow multiple transactions to access different versions of rows concurrently\u2026&#8221;<\/em><\/p>\n\n\n\n<p>with:<\/p>\n\n\n\n<p><em>&#8220;SQL SERVER BEST DATABASE!!! CLICK HERE DOWNLOAD FREE DATABASE AMAZING SQL TIPS\u2026&#8221;<\/em><\/p>\n\n\n\n<p>There are signals that make the second one fairly easy to classify as low-quality, and therefore useless for training.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-quality-is-not-the-same-as-truth\">Quality is not the same as truth<\/h3>\n\n\n\n<p><strong>After applying the obvious statistical filtering, there\u2019s still an important limitation: quality is not the same as truth.<\/strong><\/p>\n\n\n\n<p>A beautifully written article can be completely wrong. And a badly formatted Stack Overflow answer written back in 2011 might still contain the exact obscure technical fact someone needs.<\/p>\n\n\n\n<p>So, filtering cannot simply apply a rule to <em>\u201ckeep authoritative-looking text.\u201d<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-frequency-doesn-t-always-indicate-truth\">Frequency doesn&#8217;t always indicate truth<\/h3>\n\n\n\n<p>If a fact like <em>&#8220;the capital of Australia is Canberra&#8221;<\/em> occurs repeatedly across thousands of independent pieces of high-quality material, but there are also pages saying <em>&#8220;the capital of Australia is Sydney&#8221;<\/em>, how should the filtering be applied?<\/p>\n\n\n\n<p>When training, the system can&#8217;t just store these as two database rows and choose between them. So, hopefully there&#8217;s an overwhelmingly consistent relationship between Australia and Canberra&#8230;but this has a nasty consequence.<\/p>\n\n\n\n<p>As I referenced with the baseball umpiring example, widely-repeated misinformation can also be learned. 20,000 sites that all copied the same incorrect information aren&#8217;t really 20,000 independent confirmations of the facts.<\/p>\n\n\n\n<p>Website A: <em>\u201cFeature X was introduced in version 1.6.\u201d<\/em><\/p>\n\n\n\n<p>Site B: <em>\u201cFeature X was introduced in version 1.6.\u201d<\/em><\/p>\n\n\n\n<p>Site C: <em>\u201cFeature X was introduced in version 1.6.\u201d<\/em><\/p>\n\n\n\n<p>That <em>looks<\/em> like three unique sources. However, if B copied A, and C was generated by an AI whose answer was based on B, that\u2019s effectively one source echoed three times.<\/p>\n\n\n\n<p>So, the people doing training need to also assign greater value to particular kinds of material. Carefully edited books, technical documentation, academic material, high-quality reference works, well-maintained software repositories, and educational material can provide useful training examples. But someone has to assess these.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-time-based-truth\">Time-based truth<\/h3>\n\n\n\n<p>If I ask an LLM: <em>\u201cHas <a href=\"https:\/\/db-engines.com\/en\/system\/DuckDB\" target=\"_blank\" rel=\"noreferrer noopener\">DuckDB<\/a> changed the behavior of feature X in the latest release?\u201d,<\/em> and it searches the internet, it&#8217;s not treating every search result equally. <\/p>\n\n\n\n<p>Of course, you&#8217;d hope it&#8217;s going to prefer the official DuckDB documentation\u2060, release notes, or repository over someone\u2019s two-year-old blog post.<\/p>\n\n\n\n<p>But if I asked <em>\u201cwhat problems are developers actually having with this DuckDB feature?\u201d<\/em>, the LLM needs to know that GitHub issues, Stack Overflow discussions, blogs and community discussions might be far more relevant.<\/p>\n\n\n\n<p><strong>Put simply, the <em>correct<\/em> source of truth can totally depend upon the question being asked.<\/strong><\/p>\n\n\n\n<p>An official page from the Microsoft site could be excellent for <em>\u201cwhat does Microsoft say this feature does?\u201d<\/em>, but is likely to be pretty useless for <em>\u201cwhat frustrations do developers encounter using this feature?\u201d<\/em><\/p>\n\n\n\n<p>None of these processes provide a magical mechanism for determining truth.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>LLMs don&#8217;t just have a problem with how much they&#8217;ve learned. Once you get past simple scenarios, they have a problem with knowing what they should be learning from. <\/p>\n\n\n\n<p>They can absorb an enormous amount of examples, but those examples vary wildly in quality, age, context, dialect, and intent. Popularity can easily be mistaken for correctness, and individually believable items can be combined into something that is simply wrong. <\/p>\n\n\n\n<p><strong>This doesn&#8217;t make LLMs useless as programming assistants (far from it) &#8211; but it <em>does<\/em> mean we should be careful about treating confidence, fluency, or frequency as evidence of expertise.<\/strong><\/p>\n\n\n\n<p><em><strong>What do you think? Feel free to leave a comment down below &#8211; I&#8217;d love to hear from you.<\/strong><\/em><\/p>\n\n\n\n<section id=\"my-first-block-block_2eb637c5ead971baddaad8f802061edd\" class=\"my-first-block alignwide\">\n    <div class=\"bg-brand-600 text-base-white py-5xl px-4xl rounded-sm bg-gradient-to-r from-brand-600 to-brand-500 red\">\n        <div class=\"gap-4xl items-start md:items-center flex flex-col md:flex-row justify-between\">\n            <div class=\"flex-1 col-span-10 lg:col-span-7\">\n                <h3 class=\"mt-0 font-display mb-2 text-display-sm\">Simple Talk is brought to you by Redgate Software<\/h3>\n                <div class=\"child:last-of-type:mb-0\">\n                                            Take control of your databases with the trusted Database DevOps solutions provider. Automate with confidence, scale securely, and unlock growth through AI.                                    <\/div>\n            <\/div>\n                                            <a href=\"https:\/\/www.red-gate.com\/solutions\/overview\/\" class=\"btn btn--secondary btn--lg\" aria-label=\"Discover how Redgate can help you: Simple Talk is brought to you by Redgate Software\">Discover how Redgate can help you<\/a>\n                    <\/div>\n    <\/div>\n<\/section>","protected":false},"excerpt":{"rendered":"<p>Why do AI models get hard questions correct, but fail easy ones? A look at how LLMs weigh popularity, quality, and time when learning from messy training data.&hellip;<\/p>\n","protected":false},"author":346483,"featured_media":104558,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[159169,143523,47125,53,3,30],"tags":[159075,4168,4170,4144],"coauthors":[159368],"class_list":["post-112551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-databases","category-editorials","category-featured","category-opinion","category-opinion-pieces","tag-ai","tag-database","tag-database-administration","tag-opinion"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/112551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/346483"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=112551"}],"version-history":[{"count":6,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/112551\/revisions"}],"predecessor-version":[{"id":112587,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/112551\/revisions\/112587"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media\/104558"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=112551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=112551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=112551"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=112551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}