{
  "version": "https://jsonfeed.org/version/1",
  "title": "gruszka.dev",
  "home_page_url": "https://gruszka.dev/en",
  "feed_url": "https://gruszka.dev/en/tag-neural-networks.json",
  "description": "Things I would like to share",
  "items": [
    {
      "id": "https://gruszka.dev/en/from-neurons-to-memory.html",
      "url": "https://gruszka.dev/en/from-neurons-to-memory.html",
      "title": "From simple neurons to memory - the evolution of language models",
      "content_html": "<div class=\"markdown-alert markdown-alert-tip\">\n<p class=\"markdown-alert-title\">Tip</p>\n<p><strong>Want to run this code yourself?</strong> All the examples from this post (perceptron, RNN, LSTM) are in a ready-made Jupyter notebook: <a href=\"./from-neurons-to-memory.ipynb\">from-neurons-to-memory.ipynb</a></p>\n</div>\n<p>In the <a href=\"how-computer-reads-text.html\">previous post</a> we walked the whole path from cutting text into tokens, through counting words (TF-IDF), Markov chains, all the way to Word2Vec and meaning vectors. And at the end one fundamental question came up...</p>\n<p><strong>We have word vectors. Great. But how do we build something out of them that understands a sentence? Or a whole paragraph? Or a book?</strong></p>\n<p>Because &quot;Dog bites man&quot; isn't simply &quot;dog&quot; + &quot;bites&quot; + &quot;man&quot;. It's a <strong>sequence</strong> - words follow each other in a specific order, and that order <strong>changes the meaning</strong>. &quot;Dog bites man&quot; and &quot;Man bites dog&quot; are the same words, but completely different stories :D</p>\n<p>And Word2Vec? Word2Vec looks at words <strong>individually</strong>. It has no concept of order. It doesn't know that &quot;not&quot; before &quot;like&quot; changes everything.</p>\n<p>So we need something that can process <strong>sequences</strong>. Something that reads text in order and builds understanding step by step.</p>\n<p>And here begins a fascinating story - because the solution to this problem didn't appear overnight. It was an evolution that lasted several decades. From a single, simple neuron, to complicated memory cells. And each generation solved the previous generation's problem, but created a new one.</p>\n<p>This is the <strong>fourth post in the &quot;Understanding LLM&quot; series</strong>. Today we go deeper into the architecture of neural networks - but relax, still without formulas you can't understand ;-) Instead, there will be plenty of metaphors, diagrams, and real-life examples.</p>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"980\" height=\"326.75\" viewBox=\"0 0 980 326.75\"><rect x=\"0\" y=\"0\" width=\"980\" height=\"326.75\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><rect x=\"0\" y=\"0\" width=\"980.00\" height=\"326.75\" fill=\"#FFFFFF\"/><text x=\"490.00\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"490.00\" dy=\"0.00\">The evolution of neural</tspan><tspan x=\"490.00\" dy=\"21.00\">architectures</tspan></text><line x1=\"30.00\" y1=\"130.00\" x2=\"950.00\" y2=\"130.00\" stroke=\"#94A3B8\" stroke-width=\"3\"/><circle cx=\"90.00\" cy=\"130.00\" r=\"8\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"2\"/><line x1=\"90.00\" y1=\"138.00\" x2=\"90.00\" y2=\"160.00\" stroke=\"#94A3B8\" stroke-width=\"2\" stroke-dasharray=\"4,2\"/><rect x=\"30.00\" y=\"160.00\" width=\"120.00\" height=\"126.75\" rx=\"5\" ry=\"5\" fill=\"#ECECFF\" stroke=\"#94A3B8\" stroke-width=\"1\"/><text x=\"90.00\" y=\"180.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\" font-weight=\"bold\"><tspan x=\"90.00\" dy=\"0.00\">1943</tspan></text><text x=\"90.00\" y=\"200.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"12.599999\" fill=\"#0F172A\"><tspan x=\"90.00\" dy=\"0.00\">McCulloch &amp;</tspan><tspan x=\"90.00\" dy=\"18.90\">Pitts</tspan><tspan x=\"90.00\" dy=\"18.90\">mathematical</tspan><tspan x=\"90.00\" dy=\"18.90\">model of a</tspan><tspan x=\"90.00\" dy=\"18.90\">neuron</tspan></text><circle cx=\"250.00\" cy=\"130.00\" r=\"8\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"2\"/><line x1=\"250.00\" y1=\"138.00\" x2=\"250.00\" y2=\"160.00\" stroke=\"#94A3B8\" stroke-width=\"2\" stroke-dasharray=\"4,2\"/><rect x=\"190.00\" y=\"160.00\" width=\"120.00\" height=\"80.00\" rx=\"5\" ry=\"5\" fill=\"#FFE6CC\" stroke=\"#94A3B8\" stroke-width=\"1\"/><text x=\"250.00\" y=\"180.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\" font-weight=\"bold\"><tspan x=\"250.00\" dy=\"0.00\">1958</tspan></text><text x=\"250.00\" y=\"200.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"12.599999\" fill=\"#0F172A\"><tspan x=\"250.00\" dy=\"0.00\">Rosenblatt</tspan><tspan x=\"250.00\" dy=\"18.90\">perceptron</tspan></text><circle cx=\"410.00\" cy=\"130.00\" r=\"8\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"2\"/><line x1=\"410.00\" y1=\"138.00\" x2=\"410.00\" y2=\"160.00\" stroke=\"#94A3B8\" stroke-width=\"2\" stroke-dasharray=\"4,2\"/><rect x=\"350.00\" y=\"160.00\" width=\"120.00\" height=\"88.95\" rx=\"5\" ry=\"5\" fill=\"#D5E8D4\" stroke=\"#94A3B8\" stroke-width=\"1\"/><text x=\"410.00\" y=\"180.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\" font-weight=\"bold\"><tspan x=\"410.00\" dy=\"0.00\">1986</tspan></text><text x=\"410.00\" y=\"200.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"12.599999\" fill=\"#0F172A\"><tspan x=\"410.00\" dy=\"0.00\">Rumelhart et al.</tspan><tspan x=\"410.00\" dy=\"18.90\">backpropagation</tspan><tspan x=\"410.00\" dy=\"18.90\">+ MLP</tspan></text><circle cx=\"570.00\" cy=\"130.00\" r=\"8\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"2\"/><line x1=\"570.00\" y1=\"138.00\" x2=\"570.00\" y2=\"160.00\" stroke=\"#94A3B8\" stroke-width=\"2\" stroke-dasharray=\"4,2\"/><rect x=\"510.00\" y=\"160.00\" width=\"120.00\" height=\"88.95\" rx=\"5\" ry=\"5\" fill=\"#F8CECC\" stroke=\"#94A3B8\" stroke-width=\"1\"/><text x=\"570.00\" y=\"180.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\" font-weight=\"bold\"><tspan x=\"570.00\" dy=\"0.00\">1986</tspan></text><text x=\"570.00\" y=\"200.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"12.599999\" fill=\"#0F172A\"><tspan x=\"570.00\" dy=\"0.00\">RNN</tspan><tspan x=\"570.00\" dy=\"18.90\">recurrent</tspan><tspan x=\"570.00\" dy=\"18.90\">networks</tspan></text><circle cx=\"730.00\" cy=\"130.00\" r=\"8\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"2\"/><line x1=\"730.00\" y1=\"138.00\" x2=\"730.00\" y2=\"160.00\" stroke=\"#94A3B8\" stroke-width=\"2\" stroke-dasharray=\"4,2\"/><rect x=\"670.00\" y=\"160.00\" width=\"120.00\" height=\"88.95\" rx=\"5\" ry=\"5\" fill=\"#FFF2CC\" stroke=\"#94A3B8\" stroke-width=\"1\"/><text x=\"730.00\" y=\"180.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\" font-weight=\"bold\"><tspan x=\"730.00\" dy=\"0.00\">1997</tspan></text><text x=\"730.00\" y=\"200.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"12.599999\" fill=\"#0F172A\"><tspan x=\"730.00\" dy=\"0.00\">Hochreiter &amp;</tspan><tspan x=\"730.00\" dy=\"18.90\">Schmidhuber</tspan><tspan x=\"730.00\" dy=\"18.90\">LSTM</tspan></text><circle cx=\"890.00\" cy=\"130.00\" r=\"8\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"2\"/><line x1=\"890.00\" y1=\"138.00\" x2=\"890.00\" y2=\"160.00\" stroke=\"#94A3B8\" stroke-width=\"2\" stroke-dasharray=\"4,2\"/><rect x=\"830.00\" y=\"160.00\" width=\"120.00\" height=\"88.95\" rx=\"5\" ry=\"5\" fill=\"#E1D5E7\" stroke=\"#94A3B8\" stroke-width=\"1\"/><text x=\"890.00\" y=\"180.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\" font-weight=\"bold\"><tspan x=\"890.00\" dy=\"0.00\">2017</tspan></text><text x=\"890.00\" y=\"200.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"12.599999\" fill=\"#0F172A\"><tspan x=\"890.00\" dy=\"0.00\">Vaswani et al.</tspan><tspan x=\"890.00\" dy=\"18.90\">Transformer</tspan><tspan x=\"890.00\" dy=\"18.90\">(cliffhanger!)</tspan></text></svg></div>\n<p>The narrative of today's post: <strong>&quot;From a single cell to memory - and why that still wasn't enough.&quot;</strong> Let's start from the basics.</p>\n<hr />\n<h2><a href=\"#biological-neuron-vs-artificial---where-does-the-idea-even-come-from\" aria-hidden=\"true\" class=\"anchor\" id=\"biological-neuron-vs-artificial---where-does-the-idea-even-come-from\"></a>Biological neuron vs artificial - where does the idea even come from?</h2>\n<p>Before we get into architectures, let's quickly settle one question you're probably asking yourselves: <strong>why is it even called a &quot;neural network&quot;? What does it have to do with the brain?</strong></p>\n<p>Answer: both a lot, and a little ;-) In the beginning there was inspiration from biology. Take a look:</p>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"797.1526\" height=\"96\" viewBox=\"0 0 797.1526 96\"><rect x=\"0\" y=\"0\" width=\"797.1526\" height=\"96\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 258.340,44.000 L 308.340,44.000\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(308.34 44.00) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 506.768,44.000 L 556.768,44.000\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(556.77 44.00) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect x=\"556.77\" y=\"8.00\" width=\"224.38\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"668.96\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"668.96\" dy=\"0.00\">⚡ Axon</tspan><tspan x=\"668.96\" dy=\"21.00\">&lt;i&gt;passes it on&lt;/i&gt;</tspan></text><rect x=\"8.00\" y=\"8.00\" width=\"250.34\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"133.17\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"133.17\" dy=\"0.00\">🌿 Dendrites</tspan><tspan x=\"133.17\" dy=\"21.00\">&lt;i&gt;receive signals&lt;/i&gt;</tspan></text><rect x=\"308.34\" y=\"8.00\" width=\"198.43\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"407.55\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"407.55\" dy=\"0.00\">🧫 Soma</tspan><tspan x=\"407.55\" dy=\"21.00\">&lt;i&gt;processes&lt;/i&gt;</tspan></text></svg></div>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"857.7152\" height=\"117\" viewBox=\"0 0 857.7152 117\"><rect x=\"0\" y=\"0\" width=\"857.7152\" height=\"117\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 232.384,54.395 L 282.384,54.395\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(282.38 54.40) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 541.376,54.482 L 591.376,54.482\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(591.38 54.48) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect x=\"591.38\" y=\"18.46\" width=\"250.34\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"716.55\" y=\"47.46\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"716.55\" dy=\"0.00\">📤 Output</tspan><tspan x=\"716.55\" dy=\"21.00\">&lt;i&gt;activation(sum)&lt;/i&gt;</tspan></text><rect x=\"8.00\" y=\"18.29\" width=\"224.38\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"120.19\" y=\"47.29\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"120.19\" dy=\"0.00\">📥 Inputs x₁, x₂, x₃</tspan><tspan x=\"120.19\" dy=\"21.00\">&lt;i&gt;numbers&lt;/i&gt;</tspan></text><rect x=\"282.38\" y=\"8.00\" width=\"258.99\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"411.88\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"411.88\" dy=\"0.00\">➕ Weighted sum</tspan><tspan x=\"411.88\" dy=\"21.00\">&lt;i&gt;w₁x₁ + w₂x₂ + w₃x₃ +</tspan><tspan x=\"411.88\" dy=\"21.00\">b&lt;/i&gt;</tspan></text></svg></div>\n<p><strong>First diagram</strong> - a real neuron. It has <strong>dendrites</strong> (receive signals from other neurons), a <strong>soma</strong> (the cell body - decides whether to &quot;fire&quot;), and an <strong>axon</strong> (passes the signal on).</p>\n<p><strong>Second diagram</strong> - an artificial neuron. It has <strong>inputs</strong> (numbers), a <strong>weighted sum</strong> (multiplies each input by its &quot;importance&quot; and adds it all up), and an <strong>output</strong> (the result passed through an activation function).</p>\n<p>The resemblance is... loose. A biological neuron is unimaginably more complicated. But the <strong>inspiration</strong> was important - Warren McCulloch and Walter Pitts showed in 1943 that such a simplified model of a neuron can perform basic logical operations (AND, OR, NOT). And that meant a network of such neurons could theoretically compute <strong>anything</strong>.</p>\n<div class=\"markdown-alert markdown-alert-note\">\n<p class=\"markdown-alert-title\">Note</p>\n<p><strong>Does an LLM &quot;think&quot; like a brain?</strong> No. An artificial neuron is a mathematical abstraction, not a biological model. A biological neuron uses electrical impulses, neurotransmitters, has thousands of connections and a dynamics that can't be reduced to <code>w₁x₁ + w₂x₂</code>. But the inspiration was the starting point - and an important one.</p>\n</div>\n<p>OK, that's enough biology. Let's move on to what came out of it ;-)</p>\n<hr />\n<h2><a href=\"#perceptron---the-simplest-decision-in-the-world\" aria-hidden=\"true\" class=\"anchor\" id=\"perceptron---the-simplest-decision-in-the-world\"></a>Perceptron - the simplest decision in the world</h2>\n<p>In 1958 Frank Rosenblatt created the <strong>perceptron</strong> - the first algorithm that could <strong>learn</strong> from data. It was a milestone.</p>\n<p>The perceptron works trivially simply. Imagine you're deciding whether to go for a walk:</p>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"915.8044\" height=\"594.1909\" viewBox=\"0 0 915.8044 594.1909\"><rect x=\"0\" y=\"0\" width=\"915.8044\" height=\"594.1909\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 144.866,59.000 L 144.866,102.786 Q 144.866,112.786 154.866,112.786 L 339.844,112.786 Q 349.844,112.786 349.844,122.786 L 349.844,166.572\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(349.84 166.57) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-0\" data-label-kind=\"center\" x=\"100.82\" y=\"114.67\" width=\"88.10\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-0\" data-label-kind=\"center\"><text x=\"144.87\" y=\"132.37\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"144.87\" dy=\"0.00\">&quot;w = +5&quot;</tspan></text></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 310.146,59.000 L 310.146,71.480 Q 310.146,81.480 320.146,81.480 L 387.847,81.480 Q 397.847,81.480 397.847,91.480 L 397.847,159.191 Q 397.847,166.572 390.467,166.572 L 381.446,166.572\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(381.45 166.57) rotate(180.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-1\" data-label-kind=\"center\" x=\"371.96\" y=\"50.71\" width=\"88.10\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-1\" data-label-kind=\"center\"><text x=\"416.01\" y=\"68.41\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"416.01\" dy=\"0.00\">&quot;w = -8&quot;</tspan></text></g><path id=\"edge-2\" class=\"edgePath\" data-edge-id=\"edge-2\" d=\"M 479.924,59.000 L 498.624,59.000 Q 508.624,59.000 508.624,69.000 L 508.624,128.072 Q 508.624,138.072 498.624,138.072 L 443.222,138.072 Q 433.222,138.072 433.222,148.072 L 433.222,166.572\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(433.22 166.57) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-2\" data-label-kind=\"center\" x=\"418.52\" y=\"108.08\" width=\"88.10\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-2\" data-label-kind=\"center\"><text x=\"462.57\" y=\"125.78\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"462.57\" dy=\"0.00\">&quot;w = +3&quot;</tspan></text></g><path id=\"edge-3\" class=\"edgePath\" data-edge-id=\"edge-3\" d=\"M 695.103,59.000 L 695.103,152.786 Q 695.103,162.786 685.103,162.786 L 457.676,162.786 Q 455.972,162.786 455.972,164.489 L 455.972,166.572\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(455.97 166.57) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-4\" class=\"edgePath\" data-edge-id=\"edge-4\" d=\"M 402.141,217.572 L 402.141,228.295 Q 402.141,235.072 402.744,241.822 L 402.877,243.322 Q 403.480,250.072 403.480,256.848 L 403.480,267.572\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(403.48 267.57) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-5\" class=\"edgePath\" data-edge-id=\"edge-5\" d=\"M 404.480,463.298 L 414.105,463.298 Q 421.980,463.298 418.298,470.259 L 391.333,521.230 Q 387.651,528.191 395.526,528.191 L 405.151,528.191\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(405.15 528.19) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-5\" data-label-kind=\"center\" x=\"407.54\" y=\"480.21\" width=\"58.44\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.95\" stroke=\"#94A3B8\" stroke-opacity=\"0.45\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-5\" data-label-kind=\"center\"><text x=\"436.76\" y=\"497.91\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"436.76\" dy=\"0.00\">&quot;Yes&quot;</tspan></text></g><path id=\"edge-6\" class=\"edgePath\" data-edge-id=\"edge-6\" d=\"M 402.480,463.298 L 392.855,463.298 Q 384.980,463.298 383.510,471.035 L 374.121,520.454 Q 372.651,528.191 364.776,528.191 L 355.151,528.191\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(355.15 528.19) rotate(180.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-6\" data-label-kind=\"center\" x=\"328.86\" y=\"478.35\" width=\"48.55\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.95\" stroke=\"#94A3B8\" stroke-opacity=\"0.45\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-6\" data-label-kind=\"center\"><text x=\"353.13\" y=\"496.05\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"353.13\" dy=\"0.00\">&quot;No&quot;</tspan></text></g><rect x=\"640.81\" y=\"8.00\" width=\"258.99\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"770.31\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"770.31\" dy=\"0.00\">⚙️ Threshold (bias) = 0</tspan></text><rect x=\"195.87\" y=\"8.00\" width=\"155.17\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#9999ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"273.45\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"273.45\" dy=\"0.00\">🌧️ Raining?</tspan></text><polygon points=\"403.48,267.57 501.84,365.93 403.48,464.30 305.12,365.93\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"403.48\" y=\"358.93\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"403.48\" dy=\"0.00\">Sum &gt;= threshold?</tspan><tspan x=\"403.48\" dy=\"21.00\">(threshold = 0)</tspan></text><rect x=\"174.03\" y=\"527.19\" width=\"181.13\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#cc6666\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"264.59\" y=\"556.19\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"264.59\" dy=\"0.00\">❌ Staying home</tspan></text><rect x=\"8.00\" y=\"8.00\" width=\"137.87\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"76.93\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"76.93\" dy=\"0.00\">☀️ Sunny?</tspan></text><rect x=\"347.31\" y=\"166.57\" width=\"109.66\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#99ff99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"402.14\" y=\"195.57\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"402.14\" dy=\"0.00\">➕ SUM</tspan></text><rect x=\"401.04\" y=\"8.00\" width=\"189.78\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ff9999\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"495.92\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"495.92\" dy=\"0.00\">🌡️ Temp &gt; 20°C?</tspan></text><rect x=\"405.15\" y=\"527.19\" width=\"258.99\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#66cc66\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"534.65\" y=\"556.19\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"534.65\" dy=\"0.00\">✅ I&apos;m going for a walk!</tspan></text></svg></div>\n<p>The mechanics are simple:</p>\n<ol>\n<li>Each input has its own <strong>weight</strong> (importance) - sun has weight +5, rain -8, temperature +3</li>\n<li>The perceptron <strong>multiplies</strong> each input by its weight and <strong>adds it all up</strong> (that's the &quot;weighted sum&quot;)</li>\n<li>If the sum is greater than or equal to the <strong>threshold</strong> (in our case threshold = 0) - it fires &quot;yes&quot;. Otherwise - &quot;no&quot;.</li>\n</ol>\n<p>Example:</p>\n<table>\n<thead>\n<tr>\n<th>Situation</th>\n<th>Sun (+5)</th>\n<th>Rain (-8)</th>\n<th>Temp &gt;20° (+3)</th>\n<th>Sum</th>\n<th>Decision</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Sunny, warm, no rain</td>\n<td>1</td>\n<td>0</td>\n<td>1</td>\n<td>5 + 0 + 3 = <strong>8</strong></td>\n<td>✅ Going out</td>\n</tr>\n<tr>\n<td>Raining, cold</td>\n<td>0</td>\n<td>1</td>\n<td>0</td>\n<td>0 - 8 + 0 = <strong>-8</strong></td>\n<td>❌ Staying home</td>\n</tr>\n<tr>\n<td>Cloudy and raining, but warm</td>\n<td>0</td>\n<td>1</td>\n<td>1</td>\n<td>0 - 8 + 3 = <strong>-5</strong></td>\n<td>❌ Staying home</td>\n</tr>\n</tbody>\n</table>\n<p>And - most importantly - the perceptron can <strong>learn</strong> these weights. You show it 100 examples of &quot;went out / didn't go out&quot; and it gradually adjusts the weights so that its decisions match yours.</p>\n<p>Brilliant in its simplicity, right?</p>\n<h3><a href=\"#but-the-perceptron-has-one-big-problem\" aria-hidden=\"true\" class=\"anchor\" id=\"but-the-perceptron-has-one-big-problem\"></a>But the perceptron has one big problem...</h3>\n<p>A perceptron can draw <strong>a single straight line</strong> dividing data into two groups. Which is great if the data can be split that way:</p>\n<pre class=\"marmite-code\"><code class=\"marmite-code-inner\">⚫ ⚫ ⚫    │    ⚪ ⚪ ⚪\n⚫ ⚫ ⚫    │    ⚪ ⚪ ⚪\n           ↑\n      one line separates them ✅\n</code></pre>\n<p>But what if the data looks like this?</p>\n<pre class=\"marmite-code\"><code class=\"marmite-code-inner\">⚪  ⚫\n\n⚫  ⚪\n</code></pre>\n<p>That's the famous <strong>XOR problem</strong> (exclusive OR). The output is &quot;true&quot; only when exactly <strong>one</strong> input is true - not both and not neither. And you can't draw a single straight line that would separate them.</p>\n<p>This problem <strong>halted the development of neural networks for almost 20 years</strong>. Seriously. Researchers said: &quot;well OK, the perceptron is cool, but if it can't handle something as simple as XOR, what's the point?&quot; This period is called the <strong>&quot;AI Winter&quot;</strong>.</p>\n<div class=\"markdown-alert markdown-alert-warning\">\n<p class=\"markdown-alert-title\">Warning</p>\n<p><strong>Why was XOR so important?</strong> Because it showed that a single perceptron is limited to <strong>linearly separable</strong> problems. And the real world is rarely linear. Language definitely isn't.</p>\n</div>\n<p>And then someone said: <strong>what if we combine several perceptrons together?</strong></p>\n<hr />\n<h2><a href=\"#mlp---a-team-that-can-do-more-than-an-individual\" aria-hidden=\"true\" class=\"anchor\" id=\"mlp---a-team-that-can-do-more-than-an-individual\"></a>MLP - a team that can do more than an individual</h2>\n<p>A <strong>Multilayer Perceptron (MLP)</strong> is a network made up of many layers of neurons. Instead of one decision layer, we have:</p>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1341.5353\" height=\"459.6258\" viewBox=\"0 0 1341.5353 459.6258\"><rect x=\"0\" y=\"0\" width=\"1341.5353\" height=\"459.6258\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><rect x=\"261.03\" y=\"8.00\" width=\"330.34\" height=\"435.63\" rx=\"10\" ry=\"10\" fill=\"#F1F5F9\" stroke=\"#CBD5E1\" stroke-width=\"1\" /><text x=\"426.20\" y=\"35.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"426.20\" dy=\"0.00\">Hidden layer 1</tspan></text><rect x=\"671.37\" y=\"58.42\" width=\"304.38\" height=\"337.92\" rx=\"10\" ry=\"10\" fill=\"#F1F5F9\" stroke=\"#CBD5E1\" stroke-width=\"1\" /><text x=\"823.57\" y=\"85.92\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"823.57\" dy=\"0.00\">Hidden layer 2</tspan></text><rect x=\"1055.76\" y=\"111.37\" width=\"269.78\" height=\"227.84\" rx=\"10\" ry=\"10\" fill=\"#F1F5F9\" stroke=\"#CBD5E1\" stroke-width=\"1\" /><text x=\"1190.65\" y=\"138.87\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"1190.65\" dy=\"0.00\">Output layer</tspan></text><rect x=\"8.00\" y=\"66.36\" width=\"188.77\" height=\"300.43\" rx=\"10\" ry=\"10\" fill=\"#F1F5F9\" stroke=\"#CBD5E1\" stroke-width=\"1\" /><text x=\"102.38\" y=\"93.86\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"102.38\" dy=\"0.00\">Input layer</tspan></text><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 141.035,156.864 L 147.646,156.864 Q 153.055,156.864 156.250,161.229 L 285.819,338.261 Q 289.014,342.626 294.423,342.626 L 301.035,342.626\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 342.63) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 141.035,120.990 L 147.646,120.990 Q 153.055,120.990 158.392,120.108 L 283.677,99.383 Q 289.014,98.500 294.423,98.500 L 301.035,98.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 98.50) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-2\" class=\"edgePath\" data-edge-id=\"edge-2\" d=\"M 141.035,154.773 L 147.646,154.773 Q 153.055,154.773 158.459,155.014 L 283.610,160.613 Q 289.014,160.855 294.423,160.855 L 301.035,160.855\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 160.85) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-3\" class=\"edgePath\" data-edge-id=\"edge-3\" d=\"M 141.035,156.864 L 141.035,161.587 Q 141.035,165.450 144.898,165.450 L 149.191,165.450 Q 153.055,165.450 153.055,161.587 L 153.055,160.728 Q 153.055,156.864 156.274,159.001 L 284.507,244.103 Q 289.014,247.094 294.423,247.094 L 301.035,247.094\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 247.09) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-4\" class=\"edgePath\" data-edge-id=\"edge-4\" d=\"M 141.035,246.330 L 147.646,246.330 Q 153.055,246.330 157.469,249.457 L 285.861,340.393 Q 289.014,342.626 289.014,346.490 L 289.014,347.348 Q 289.014,351.212 292.878,351.212 L 297.171,351.212 Q 301.035,351.212 301.035,347.348 L 301.035,342.626\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 342.63) rotate(-90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-5\" class=\"edgePath\" data-edge-id=\"edge-5\" d=\"M 141.035,197.752 L 147.646,197.752 Q 153.055,197.752 157.418,194.553 L 284.651,101.277 Q 289.014,98.078 294.423,98.078 L 301.035,98.078\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 98.08) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-6\" class=\"edgePath\" data-edge-id=\"edge-6\" d=\"M 141.035,212.011 L 147.646,212.011 Q 153.055,212.011 158.427,211.373 L 283.642,196.510 Q 289.014,195.872 294.423,195.872 L 301.035,195.872\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 195.87) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-7\" class=\"edgePath\" data-edge-id=\"edge-7\" d=\"M 141.035,245.581 L 147.646,245.581 Q 153.055,245.581 158.410,246.344 L 283.659,264.198 Q 289.014,264.961 294.423,264.961 L 301.035,264.961\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 264.96) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-8\" class=\"edgePath\" data-edge-id=\"edge-8\" d=\"M 141.035,335.213 L 147.646,335.213 Q 153.055,335.213 158.424,335.876 L 283.645,351.324 Q 289.014,351.987 294.423,351.987 L 301.035,351.987\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 351.99) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-9\" class=\"edgePath\" data-edge-id=\"edge-9\" d=\"M 141.035,286.796 L 147.646,286.796 Q 153.055,286.796 156.222,282.410 L 286.752,101.633 Q 289.014,98.500 289.014,102.364 L 289.014,103.222 Q 289.014,107.086 292.878,107.086 L 297.171,107.086 Q 301.035,107.086 301.035,103.222 L 301.035,98.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 98.50) rotate(-90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-10\" class=\"edgePath\" data-edge-id=\"edge-10\" d=\"M 141.035,286.796 L 141.035,291.518 Q 141.035,295.382 144.898,295.382 L 149.191,295.382 Q 153.055,295.382 153.055,291.518 L 153.055,290.660 Q 153.055,286.796 156.271,284.654 L 284.512,199.208 Q 289.014,196.209 294.423,196.209 L 301.035,196.209\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 196.21) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-11\" class=\"edgePath\" data-edge-id=\"edge-11\" d=\"M 141.035,311.296 L 147.646,311.296 Q 153.055,311.296 158.412,310.545 L 283.657,292.989 Q 289.014,292.238 294.423,292.238 L 301.035,292.238\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(301.03 292.24) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-12\" class=\"edgePath\" data-edge-id=\"edge-12\" d=\"M 551.374,378.728 L 557.985,378.728 Q 563.395,378.728 568.752,377.978 L 693.997,360.436 Q 699.354,359.686 704.763,359.686 L 711.374,359.686\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 359.69) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-13\" class=\"edgePath\" data-edge-id=\"edge-13\" d=\"M 551.374,342.626 L 557.985,342.626 Q 563.395,342.626 566.502,338.198 L 696.246,153.343 Q 699.354,148.916 704.763,148.916 L 711.374,148.916\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 148.92) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-14\" class=\"edgePath\" data-edge-id=\"edge-14\" d=\"M 551.374,342.626 L 551.374,347.348 Q 551.374,351.212 555.238,351.212 L 559.531,351.212 Q 563.395,351.212 563.395,347.348 L 563.395,346.490 Q 563.395,342.626 566.551,340.397 L 694.935,249.744 Q 699.354,246.624 704.763,246.624 L 711.374,246.624\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 246.62) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-15\" class=\"edgePath\" data-edge-id=\"edge-15\" d=\"M 378.338,98.500 L 384.949,98.500 Q 390.359,98.500 394.921,101.406 L 694.791,292.427 Q 699.354,295.333 704.763,295.333 L 711.374,295.333\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 295.33) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-16\" class=\"edgePath\" data-edge-id=\"edge-16\" d=\"M 378.338,94.749 L 384.949,94.749 Q 390.359,94.749 395.757,95.094 L 693.955,114.134 Q 699.354,114.479 704.763,114.479 L 711.374,114.479\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 114.48) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-17\" class=\"edgePath\" data-edge-id=\"edge-17\" d=\"M 378.338,98.500 L 378.338,103.222 Q 378.338,107.086 382.202,107.086 L 386.495,107.086 Q 390.359,107.086 390.359,103.222 L 390.359,102.364 Q 390.359,98.500 394.003,99.782 L 694.251,205.412 Q 699.354,207.207 704.763,207.207 L 711.374,207.207\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 207.21) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-18\" class=\"edgePath\" data-edge-id=\"edge-18\" d=\"M 378.338,196.209 L 384.949,196.209 Q 390.359,196.209 395.509,197.861 L 695.674,294.153 Q 699.354,295.333 699.354,299.197 L 699.354,300.055 Q 699.354,303.919 703.217,303.919 L 707.510,303.919 Q 711.374,303.919 711.374,300.055 L 711.374,295.333\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 295.33) rotate(-90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-19\" class=\"edgePath\" data-edge-id=\"edge-19\" d=\"M 378.338,166.086 L 384.949,166.086 Q 390.359,166.086 395.755,165.715 L 693.957,145.241 Q 699.354,144.870 704.763,144.870 L 711.374,144.870\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 144.87) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-20\" class=\"edgePath\" data-edge-id=\"edge-20\" d=\"M 378.338,192.457 L 384.949,192.457 Q 390.359,192.457 395.752,192.877 L 693.961,216.082 Q 699.354,216.501 704.763,216.501 L 711.374,216.501\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 216.50) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-21\" class=\"edgePath\" data-edge-id=\"edge-21\" d=\"M 378.338,290.283 L 384.949,290.283 Q 390.359,290.283 395.749,290.735 L 693.963,315.757 Q 699.354,316.209 704.763,316.209 L 711.374,316.209\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 316.21) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-22\" class=\"edgePath\" data-edge-id=\"edge-22\" d=\"M 378.338,255.759 L 384.949,255.759 Q 390.359,255.759 395.471,253.991 L 695.702,150.178 Q 699.354,148.916 699.354,152.780 L 699.354,153.638 Q 699.354,157.502 703.217,157.502 L 707.510,157.502 Q 711.374,157.502 711.374,153.638 L 711.374,148.916\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 148.92) rotate(-90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-23\" class=\"edgePath\" data-edge-id=\"edge-23\" d=\"M 378.338,270.192 L 384.949,270.192 Q 390.359,270.192 395.746,269.711 L 693.966,243.061 Q 699.354,242.579 704.763,242.579 L 711.374,242.579\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(711.37 242.58) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-24\" class=\"edgePath\" data-edge-id=\"edge-24\" d=\"M 935.758,312.875 L 942.370,312.875 Q 947.779,312.875 953.177,312.522 L 1078.340,304.331 Q 1083.738,303.977 1089.147,303.977 L 1095.758,303.977\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1095.76 303.98) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-25\" class=\"edgePath\" data-edge-id=\"edge-25\" d=\"M 935.758,295.333 L 942.370,295.333 Q 947.779,295.333 952.236,292.269 L 1079.280,204.932 Q 1083.738,201.867 1089.147,201.867 L 1095.758,201.867\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1095.76 201.87) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-26\" class=\"edgePath\" data-edge-id=\"edge-26\" d=\"M 788.678,148.916 L 795.289,148.916 Q 800.698,148.916 805.841,150.592 L 1078.595,239.492 Q 1083.738,241.168 1089.147,241.168 L 1095.758,241.168\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1095.76 241.17) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-27\" class=\"edgePath\" data-edge-id=\"edge-27\" d=\"M 788.678,145.740 L 795.289,145.740 Q 800.698,145.740 806.086,146.217 L 1078.349,170.321 Q 1083.738,170.798 1089.147,170.798 L 1095.758,170.798\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1095.76 170.80) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-28\" class=\"edgePath\" data-edge-id=\"edge-28\" d=\"M 788.678,242.606 L 795.289,242.606 Q 800.698,242.606 806.089,243.057 L 1078.347,265.841 Q 1083.738,266.292 1089.147,266.292 L 1095.758,266.292\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1095.76 266.29) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-29\" class=\"edgePath\" data-edge-id=\"edge-29\" d=\"M 788.678,217.624 L 953.657,217.624 Q 962.547,217.624 962.547,208.734 L 962.547,206.758 Q 962.547,197.868 971.437,197.868 L 1095.758,197.868\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1095.76 197.87) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect x=\"711.37\" y=\"294.33\" width=\"224.38\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#99ff99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"823.57\" y=\"323.33\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"823.57\" dy=\"0.00\">g₁</tspan><tspan x=\"823.57\" dy=\"21.00\">&lt;i&gt;combinations&lt;/i&gt;</tspan></text><rect x=\"711.37\" y=\"98.92\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#99ff99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"750.03\" y=\"127.92\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"750.03\" dy=\"0.00\">g₂</tspan></text><rect x=\"711.37\" y=\"196.62\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#99ff99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"750.03\" y=\"225.62\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"750.03\" dy=\"0.00\">g₃</tspan></text><rect x=\"301.03\" y=\"341.63\" width=\"250.34\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"426.20\" y=\"370.63\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"426.20\" dy=\"0.00\">h₁</tspan><tspan x=\"426.20\" dy=\"21.00\">&lt;i&gt;simple features&lt;/i&gt;</tspan></text><rect x=\"301.03\" y=\"48.50\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"339.69\" y=\"77.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"339.69\" dy=\"0.00\">h₂</tspan></text><rect x=\"301.03\" y=\"146.21\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"339.69\" y=\"175.21\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"339.69\" dy=\"0.00\">h₃</tspan></text><rect x=\"301.03\" y=\"243.92\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"339.69\" y=\"272.92\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"339.69\" dy=\"0.00\">h₄</tspan></text><rect x=\"63.73\" y=\"106.86\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ff9999\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"102.38\" y=\"135.86\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"102.38\" dy=\"0.00\">x₁</tspan></text><rect x=\"63.73\" y=\"196.33\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ff9999\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"102.38\" y=\"225.33\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"102.38\" dy=\"0.00\">x₂</tspan></text><rect x=\"63.73\" y=\"285.80\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ff9999\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"102.38\" y=\"314.80\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"102.38\" dy=\"0.00\">x₃</tspan></text><rect x=\"1095.76\" y=\"237.21\" width=\"189.78\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#9999ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"1190.65\" y=\"266.21\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"1190.65\" dy=\"0.00\">y₁</tspan><tspan x=\"1190.65\" dy=\"21.00\">&lt;i&gt;decision&lt;/i&gt;</tspan></text><rect x=\"1095.76\" y=\"151.87\" width=\"77.30\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#9999ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"1134.41\" y=\"180.87\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"1134.41\" dy=\"0.00\">y₂</tspan></text></svg></div>\n<p>Every neuron in one layer is connected to <strong>every</strong> neuron in the next layer (that's why it's called &quot;fully connected&quot; or &quot;dense&quot;).</p>\n<p>The metaphor that fits best for me:</p>\n<p>Imagine a <strong>company</strong>. Analysts (layer 1) look at raw data and pick out simple patterns. Managers (layer 2) combine those patterns into something more meaningful. The director (the output layer) makes the final decision. None of these people understands the full picture alone - but together they form a <strong>cascade of abstraction</strong>.</p>\n<p>And that's exactly what solves the XOR problem! The first layer draws <strong>two lines</strong>. The second layer combines them into <strong>one region</strong>. Suddenly a non-linear problem becomes solvable.</p>\n<h3><a href=\"#but-careful---theres-a-catch\" aria-hidden=\"true\" class=\"anchor\" id=\"but-careful---theres-a-catch\"></a>But careful - there's a catch!</h3>\n<p>Adding hidden layers <strong>by itself</strong> does nothing. Why?</p>\n<p>Because if each layer just does <code>sum = weights × inputs + bias</code>, then two layers of that operation are still... <strong>one big linear operation</strong>. Let me show with numbers:</p>\n<p><strong>Layer 1:</strong> <code>y = 2·x + 1</code>\n<strong>Layer 2:</strong> <code>z = 3·y + 2</code></p>\n<p>Substitute the first into the second:</p>\n<pre class=\"marmite-code\"><code class=\"marmite-code-inner\">z = 3·(2·x + 1) + 2\nz = 6·x + 3 + 2\nz = 6·x + 5    ← one operation, just with different numbers\n</code></pre>\n<p>The two layers collapsed into one. Instead of two transformations, you get one - just with different coefficients. It's like using one coffee filter twice as thick instead of two. Same effect.</p>\n<p>So we need <strong>something non-linear</strong> between the layers. And that's where...</p>\n<h3><a href=\"#the-activation-function---the-unsung-hero-of-deep-learning\" aria-hidden=\"true\" class=\"anchor\" id=\"the-activation-function---the-unsung-hero-of-deep-learning\"></a>The activation function - the unsung hero of deep learning</h3>\n<p>An activation function is a kind of &quot;non-standard processing plant&quot; that we pass the sum through. The most popular today is <strong>ReLU</strong> (Rectified Linear Unit):</p>\n<pre class=\"marmite-code\"><code class=\"marmite-code-inner language-python\"><a-k>def</a-k> <a-f>relu</a-f>(<a-v>x</a-v>):\n    <a-k>if</a-k> <a-v>x</a-v> <a-o>&gt;</a-o> <a-n>0</a-n>:\n        <a-k>return</a-k> <a-v>x</a-v>\n    <a-k>else</a-k>:\n        <a-k>return</a-k> <a-n>0</a-n></code></pre>\n<p>That's it. <strong>If the value is positive - keep it. If negative - zero it out.</strong></p>\n<p>Sounds trivial? It is trivial. But this one simple operation <strong>breaks linearity</strong>.</p>\n<p>Back to our numbers example. Without ReLU, two layers collapsed into one (<code>z = 6·x + 5</code>). But now let's insert ReLU between them:</p>\n<pre class=\"marmite-code\"><code class=\"marmite-code-inner\">Layer 1:  y = ReLU(2·x + 1)\nLayer 2:  z = ReLU(3·y + 2)\n</code></pre>\n<p>Let's check for three values of <code>x</code>:</p>\n<table>\n<thead>\n<tr>\n<th>x</th>\n<th>2·x + 1</th>\n<th>y (after ReLU)</th>\n<th>3·y + 2</th>\n<th>after ReLU</th>\n<th>Without ReLU (6·x + 5)</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>-2</strong></td>\n<td>-3</td>\n<td><strong>0</strong> ⬅ zeroed out!</td>\n<td>2</td>\n<td>2</td>\n<td>-7</td>\n</tr>\n<tr>\n<td><strong>0</strong></td>\n<td>1</td>\n<td>1</td>\n<td>5</td>\n<td>5</td>\n<td>5</td>\n</tr>\n<tr>\n<td><strong>1</strong></td>\n<td>3</td>\n<td>3</td>\n<td>11</td>\n<td>11</td>\n<td>11</td>\n</tr>\n</tbody>\n</table>\n<p>Without ReLU the result changes linearly (-7, 5, 11 - constant increase). With ReLU, suddenly for <code>x = -2</code> we get <strong>2 instead of -7</strong>. This relationship is no longer a straight line. <strong>Zeroing out negative values is something that can't be expressed as <code>a·x + b</code></strong> - and that's exactly why layers stop collapsing into one.</p>\n<p>Analogy: imagine <strong>window blinds</strong>. Linearity is a transparent pane of glass - it lets everything through, slightly dimmed. ReLU is blinds that completely block light below a certain angle. You can't simulate &quot;complete blocking&quot; by &quot;dimming the glass more&quot;. It's a <strong>qualitatively different operation</strong>.</p>\n<p>Thanks to ReLU, each layer does something <strong>different</strong> from the previous one. And suddenly a network with many layers becomes powerful - it can model non-linear, complicated relationships in data.</p>\n<div class=\"markdown-alert markdown-alert-important\">\n<p class=\"markdown-alert-title\">Important</p>\n<p><strong>ReLU in a nutshell:</strong> Without a (non-linear) activation function between layers, a network with 100 layers is just as expressive as a network with 1 layer. ReLU (and its cousins: sigmoid, tanh, GELU) is <strong>the ingredient that makes depth make sense.</strong></p>\n</div>\n<p>Other popular activation functions:</p>\n<table>\n<thead>\n<tr>\n<th>Function</th>\n<th>Formula (simplified)</th>\n<th>Range</th>\n<th>Where it's used</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>ReLU</strong></td>\n<td>max(0, x)</td>\n<td>[0, +∞)</td>\n<td>Hidden layers (standard)</td>\n</tr>\n<tr>\n<td><strong>Sigmoid</strong></td>\n<td>1 / (1 + e⁻ˣ)</td>\n<td>(0, 1)</td>\n<td>LSTM gates, binary output</td>\n</tr>\n<tr>\n<td><strong>Tanh</strong></td>\n<td>(eˣ - e⁻ˣ) / (eˣ + e⁻ˣ)</td>\n<td>(-1, 1)</td>\n<td>LSTM gates, hidden states</td>\n</tr>\n<tr>\n<td><strong>Softmax</strong></td>\n<td>eˣⁱ / Σeˣʲ</td>\n<td>(0, 1), sum = 1</td>\n<td>Output layer (classification)</td>\n</tr>\n</tbody>\n</table>\n<div class=\"markdown-alert markdown-alert-tip\">\n<p class=\"markdown-alert-title\">Tip</p>\n<p><strong>An experiment for you:</strong> Open Python and run this:</p>\n<pre class=\"marmite-code\"><code class=\"marmite-code-inner language-python\"><a-k>import</a-k> <a-v>numpy</a-v> <a-k>as</a-k> <a-v>np</a-v>\n\n<a-k>def</a-k> <a-f>relu</a-f>(<a-v>x</a-v>):\n    <a-k>return</a-k> <a-v>np</a-v>.<a-pr>maximum</a-pr>(<a-n>0</a-n>, <a-v>x</a-v>)\n\n<a-v>x</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>array</a-pr>([<a-o>-</a-o><a-n>3</a-n>, <a-o>-</a-o><a-n>1</a-n>, <a-n>0</a-n>, <a-n>2</a-n>, <a-n>5</a-n>])\n<a-f>print</a-f>(<a-s>f&quot;Input: </a-s><a-p>{</a-p><a-v>x</a-v><a-p>}</a-p><a-s>&quot;</a-s>)\n<a-f>print</a-f>(<a-s>f&quot;After ReLU: </a-s><a-p>{</a-p><a-f>relu</a-f><a-eb>(</a-eb><a-v>x</a-v><a-eb>)</a-eb><a-p>}</a-p><a-s>&quot;</a-s>)</code></pre>\n<p>You'll see how ReLU &quot;cuts off&quot; everything below zero. This simple operation lets the network &quot;choose&quot; which features are active and which to ignore.</p>\n</div>\n<h3><a href=\"#mini-quiz-linear-or-not\" aria-hidden=\"true\" class=\"anchor\" id=\"mini-quiz-linear-or-not\"></a>Mini-quiz: linear or not?<sup class=\"footnote-ref\"><a href=\"#fn-1\" id=\"fnref-1\" data-footnote-ref>1</a></sup></h3>\n<ol>\n<li>Plain linear regression (y = ax + b) - linear or non-linear?</li>\n<li>A perceptron with a step function (0 or 1) - linear or non-linear?</li>\n<li>An MLP without an activation function between layers - linear or non-linear?</li>\n</ol>\n<hr />\n<h2><a href=\"#problem-an-mlp-doesnt-understand-order\" aria-hidden=\"true\" class=\"anchor\" id=\"problem-an-mlp-doesnt-understand-order\"></a>Problem: an MLP doesn't understand order</h2>\n<p>OK, we have an MLP. It can model non-linear relationships. Great. But there's one <strong>fundamental</strong> problem that blocks us from using an MLP for language.</p>\n<p>An MLP sees <strong>all features at once</strong>. It has no concept of order.</p>\n<p>Take a classic English example. Two sentences with <strong>exactly the same words</strong>, but in a different order:</p>\n<table>\n<thead>\n<tr>\n<th>Sentence</th>\n<th>dog</th>\n<th>bites</th>\n<th>man</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>&quot;Dog bites man&quot;</td>\n<td>1</td>\n<td>1</td>\n<td>1</td>\n</tr>\n<tr>\n<td>&quot;Man bites dog&quot;</td>\n<td>1</td>\n<td>1</td>\n<td>1</td>\n</tr>\n</tbody>\n</table>\n<p><strong>Identical vector.</strong> And the meaning? The first is a boring news item. The second is a newspaper sensation :D</p>\n<p>For an MLP both sentences are <strong>exactly the same</strong> - because the MLP gets the same vector and has no concept of order.</p>\n<div class=\"markdown-alert markdown-alert-note\">\n<p class=\"markdown-alert-title\">Note</p>\n<p><strong>What about Polish?</strong> Polish is tricky here - due to inflection (7 cases!) we rarely have two sentences with <strong>exactly the same</strong> word forms. &quot;Pies gryzie człowieka&quot; vs &quot;Człowiek gryzie psa&quot; are different forms (pies→psa, człowieka→człowiek). But English, with minimal inflection, shows this problem perfectly. And that's exactly why bag-of-words examples often use English ;-)</p>\n</div>\n<p>This is the <strong>permutation</strong> problem - an MLP can't distinguish <code>[A, B, C]</code> from <code>[C, B, A]</code>. And in language, order is <strong>everything</strong>. &quot;I do not like&quot; vs &quot;I like not&quot; - same words, completely different meaning.</p>\n<p>You might think: &quot;OK, then let's add word position as a feature.&quot; But that doesn't solve the problem - the MLP still doesn't understand that the word at position 1 has a <strong>relationship</strong> with the word at position 5. Each position is just another number on the input.</p>\n<p>So we need something that processes data <strong>step by step</strong>, <strong>in order</strong>, and builds understanding <strong>sequentially</strong>. Just like we read a book - sentence by sentence, word by word.</p>\n<p>And here enters the RNN.</p>\n<hr />\n<h2><a href=\"#rnn---reads-text-one-by-one\" aria-hidden=\"true\" class=\"anchor\" id=\"rnn---reads-text-one-by-one\"></a>RNN - &quot;reads text one by one&quot;</h2>\n<p>A <strong>Recurrent Neural Network (RNN)</strong> is a network that has something an MLP doesn't: <strong>memory</strong>. Well... sort of ;-)</p>\n<p>Imagine you're reading a book. You don't read the whole page at once (like an MLP would). You read <strong>word by word</strong>, <strong>sentence by sentence</strong>. And with each new word you <strong>update your understanding</strong> of what's going on.</p>\n<p>That's exactly what an RNN does. It has a <strong>hidden state</strong> - that's its &quot;understanding of the text so far&quot;. With each new word:</p>\n<ol>\n<li>It takes the new word (x_t)</li>\n<li>It takes its current understanding (h_{t-1})</li>\n<li>It combines them and creates a <strong>new</strong> understanding (h_t)</li>\n</ol>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1609.8755\" height=\"476.04822\" viewBox=\"0 0 1609.8755 476.04822\"><rect x=\"0\" y=\"0\" width=\"1609.8755\" height=\"476.04822\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><rect x=\"8.00\" y=\"8.00\" width=\"1585.88\" height=\"452.05\" rx=\"10\" ry=\"10\" fill=\"#F1F5F9\" stroke=\"#CBD5E1\" stroke-width=\"1\" /><text x=\"800.94\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"800.94\" dy=\"0.00\">RNN reads: &apos;The cat sits on</tspan><tspan x=\"800.94\" dy=\"21.00\">the mat&apos;</tspan></text><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 168.563,104.549 L 177.995,104.549 Q 185.713,104.549 193.419,104.953 L 253.268,108.095 Q 260.975,108.500 268.693,108.500 L 278.125,108.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(278.12 108.50) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 387.248,108.819 L 579.280,108.819\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(579.28 108.82) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-1\" data-label-kind=\"center\" x=\"402.19\" y=\"58.45\" width=\"186.98\" height=\"52.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.95\" stroke=\"#94A3B8\" stroke-opacity=\"0.45\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-1\" data-label-kind=\"center\"><text x=\"495.68\" y=\"77.65\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"495.68\" dy=\"0.00\">&quot;understands:</tspan><tspan x=\"495.68\" dy=\"21.00\">&apos;a cat is coming&apos;&quot;</tspan></text></g><path id=\"edge-2\" class=\"edgePath\" data-edge-id=\"edge-2\" d=\"M 168.563,209.605 L 177.995,209.605 Q 185.713,209.605 193.283,208.105 L 554.560,136.542 Q 562.130,135.043 569.847,135.043 L 579.280,135.043\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(579.28 135.04) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-3\" class=\"edgePath\" data-edge-id=\"edge-3\" d=\"M 688.403,109.387 L 942.728,109.387\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(942.73 109.39) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-3\" data-label-kind=\"center\" x=\"705.77\" y=\"57.76\" width=\"256.19\" height=\"52.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.95\" stroke=\"#94A3B8\" stroke-opacity=\"0.45\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-3\" data-label-kind=\"center\"><text x=\"833.87\" y=\"76.96\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"833.87\" dy=\"0.00\">&quot;understands:</tspan><tspan x=\"833.87\" dy=\"21.00\">&apos;the cat does something&apos;&quot;</tspan></text></g><path id=\"edge-4\" class=\"edgePath\" data-edge-id=\"edge-4\" d=\"M 177.214,280.048 L 186.647,280.048 Q 194.364,280.048 201.939,278.573 L 918.002,139.133 Q 925.578,137.658 933.295,137.658 L 942.728,137.658\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(942.73 137.66) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-5\" class=\"edgePath\" data-edge-id=\"edge-5\" d=\"M 1051.851,144.637 L 1069.000,144.637 L 931.343,156.437 L 948.493,156.437\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(948.49 156.44) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-6\" class=\"edgePath\" data-edge-id=\"edge-6\" d=\"M 229.125,382.223 L 238.558,382.223 Q 246.275,382.223 253.787,380.454 L 923.831,222.656 Q 931.343,220.887 939.060,220.887 L 948.493,220.887\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(948.49 220.89) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-7\" class=\"edgePath\" data-edge-id=\"edge-7\" d=\"M 1057.616,165.226 L 1067.048,165.226 Q 1074.766,165.226 1082.403,164.116 L 1296.052,133.072 Q 1303.690,131.962 1311.407,131.962 L 1320.839,131.962\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1320.84 131.96) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-7\" data-label-kind=\"center\" x=\"1097.28\" y=\"163.87\" width=\"266.08\" height=\"52.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-7\" data-label-kind=\"center\"><text x=\"1230.32\" y=\"183.07\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"1230.32\" dy=\"0.00\">&quot;understands:</tspan><tspan x=\"1230.32\" dy=\"21.00\">&apos;the cat sits on the mat&apos;&quot;</tspan></text></g><rect x=\"1320.84\" y=\"84.66\" width=\"233.04\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#66cc66\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"1437.36\" y=\"113.66\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"1437.36\" dy=\"0.00\">✅ Full understanding</tspan></text><rect x=\"278.12\" y=\"72.50\" width=\"109.12\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#9999ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"332.69\" y=\"101.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"332.69\" dy=\"0.00\">🔄 RNN</tspan><tspan x=\"332.69\" dy=\"21.00\">h₁</tspan></text><rect x=\"579.28\" y=\"73.14\" width=\"109.12\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#9999ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"633.84\" y=\"102.14\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"633.84\" dy=\"0.00\">🔄 RNN</tspan><tspan x=\"633.84\" dy=\"21.00\">h₂</tspan></text><rect x=\"942.73\" y=\"73.64\" width=\"109.12\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#9999ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"997.29\" y=\"102.64\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"997.29\" dy=\"0.00\">🔄 RNN</tspan><tspan x=\"997.29\" dy=\"21.00\">h₃</tspan></text><rect x=\"948.49\" y=\"155.44\" width=\"109.12\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#9999ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"1003.05\" y=\"184.44\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"1003.05\" dy=\"0.00\">🔄 RNN</tspan><tspan x=\"1003.05\" dy=\"21.00\">h₄</tspan></text><rect x=\"48.00\" y=\"79.05\" width=\"120.56\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"108.28\" y=\"108.05\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"108.28\" dy=\"0.00\">📖 &apos;The&apos;</tspan></text><rect x=\"48.00\" y=\"179.05\" width=\"120.56\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"108.28\" y=\"208.05\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"108.28\" dy=\"0.00\">📖 &apos;cat&apos;</tspan></text><rect x=\"48.00\" y=\"279.05\" width=\"129.21\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"112.61\" y=\"308.05\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"112.61\" dy=\"0.00\">📖 &apos;sits&apos;</tspan></text><rect x=\"48.00\" y=\"379.05\" width=\"181.13\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"138.56\" y=\"408.05\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"138.56\" dy=\"0.00\">📖 &apos;on the mat&apos;</tspan></text></svg></div>\n<p>This diagram is exactly the <strong>unrolling</strong> in time. In reality it's <strong>the same</strong> RNN neuron - but we &quot;unwrap&quot; it in time to show how it processes consecutive words. Notice: the arrow goes from left to right - information flows <strong>sequentially</strong>.</p>\n<p>This is brilliant in its simplicity. The RNN &quot;reads&quot; text just like we do - one by one, building understanding step by step.</p>\n<h3><a href=\"#rnn-in-code---minimal\" aria-hidden=\"true\" class=\"anchor\" id=\"rnn-in-code---minimal\"></a>RNN in code - minimal</h3>\n<p>To really feel this, let's write the simplest possible RNN. No PyTorch, no TensorFlow - just NumPy:</p>\n<pre class=\"marmite-code\"><code class=\"marmite-code-inner language-python\"><a-k>import</a-k> <a-v>numpy</a-v> <a-k>as</a-k> <a-v>np</a-v>\n\n<a-k>def</a-k> <a-f>simple_rnn</a-f>(<a-v>word_vectors</a-v>, <a-v>hidden_size</a-v><a-o>=</a-o><a-n>4</a-n>):\n    <a-v>words</a-v>, <a-v>dim</a-v> <a-o>=</a-o> <a-v>word_vectors</a-v>.<a-pr>shape</a-pr>\n    <a-v>np</a-v>.<a-pr>random</a-pr>.<a-pr>seed</a-pr>(<a-n>42</a-n>)\n    \n    <a-cr>W_h</a-cr> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>random</a-pr>.<a-pr>randn</a-pr>(<a-v>hidden_size</a-v>, <a-v>hidden_size</a-v>) <a-o>*</a-o> <a-n>0.01</a-n>\n    <a-cr>W_x</a-cr> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>random</a-pr>.<a-pr>randn</a-pr>(<a-v>hidden_size</a-v>, <a-v>dim</a-v>) <a-o>*</a-o> <a-n>0.01</a-n>\n    <a-v>bias</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>zeros</a-pr>(<a-v>hidden_size</a-v>)\n    \n    <a-v>h</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>zeros</a-pr>(<a-v>hidden_size</a-v>)\n    \n    <a-k>for</a-k> <a-v>t</a-v>, <a-v>word</a-v> <a-o>in</a-o> <a-f>enumerate</a-f>(<a-v>word_vectors</a-v>):\n        <a-v>h</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>tanh</a-pr>(<a-cr>W_h</a-cr> @ <a-v>h</a-v> <a-o>+</a-o> <a-cr>W_x</a-cr> @ <a-v>word</a-v> <a-o>+</a-o> <a-v>bias</a-v>)\n        <a-f>print</a-f>(<a-s>f&quot;  Step </a-s><a-p>{</a-p><a-v>t</a-v><a-o>+</a-o><a-n>1</a-n><a-p>}</a-p><a-s>: hidden state = </a-s><a-p>{</a-p><a-v>np</a-v><a-eb>.</a-eb><a-pr>round</a-pr><a-eb>(</a-eb><a-v>h</a-v><a-eb>, </a-eb><a-n>2</a-n><a-eb>)</a-eb><a-p>}</a-p><a-s>&quot;</a-s>)\n    \n    <a-k>return</a-k> <a-v>h</a-v>\n\n<a-v>the</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>array</a-pr>([<a-n>1.0</a-n>, <a-n>0.0</a-n>])\n<a-v>cat</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>array</a-pr>([<a-n>0.0</a-n>, <a-n>1.0</a-n>])\n<a-v>sits</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>array</a-pr>([<a-n>0.3</a-n>, <a-n>0.3</a-n>])\n<a-v>on_mat</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>array</a-pr>([<a-n>0.8</a-n>, <a-n>0.2</a-n>])\n\n<a-v>sentence</a-v> <a-o>=</a-o> <a-v>np</a-v>.<a-pr>array</a-pr>([<a-v>the</a-v>, <a-v>cat</a-v>, <a-v>sits</a-v>, <a-v>on_mat</a-v>])\n<a-f>print</a-f>(<a-s>&quot;Processing: &#39;The cat sits on the mat&#39;&quot;</a-s>)\n<a-v>final</a-v> <a-o>=</a-o> <a-f>simple_rnn</a-f>(<a-v>sentence</a-v>)\n<a-f>print</a-f>(<a-s>f&quot;\\nFinal hidden state: </a-s><a-p>{</a-p><a-v>np</a-v><a-eb>.</a-eb><a-pr>round</a-pr><a-eb>(</a-eb><a-v>final</a-v><a-eb>, </a-eb><a-n>2</a-n><a-eb>)</a-eb><a-p>}</a-p><a-s>&quot;</a-s>)</code></pre>\n<p>Run it! You'll see how with each word the <code>hidden state</code> changes. The last hidden state is the &quot;understanding&quot; of the whole sentence by our simple RNN.</p>\n<div class=\"markdown-alert markdown-alert-tip\">\n<p class=\"markdown-alert-title\">Tip</p>\n<p><strong>Key intuition:</strong> Notice the line <code>h = np.tanh(W_h @ h + W_x @ word + bias)</code>. That's the heart of the RNN.</p>\n<p><strong>Two parts of this line:</strong></p>\n<ul>\n<li><code>W_h @ h + W_x @ word + bias</code> - this is the same &quot;weighted sum&quot; as in the perceptron and MLP. Except now it sums <strong>two sources</strong>: the previous hidden state (<code>h</code>) and the new word (<code>word</code>).</li>\n<li><code>tanh(...)</code> - that's the <strong>activation function</strong>, exactly the same family as ReLU from the previous section. Instead of &quot;cutting off below zero&quot;, tanh squeezes everything into the range (-1, 1). But the goal is the same: <strong>break linearity</strong>.</li>\n</ul>\n<p>The new hidden state depends on <strong>two things</strong>: the previous hidden state (<code>h</code>) and the new word (<code>word</code>). That's exactly what we do when reading text - we combine what we already know with what we just read.</p>\n</div>\n<h3><a href=\"#but-the-rnn-has-one-big-problem\" aria-hidden=\"true\" class=\"anchor\" id=\"but-the-rnn-has-one-big-problem\"></a>But the RNN has one big problem...</h3>\n<p>And here we get to the topic that changed everything.</p>\n<hr />\n<h2><a href=\"#the-goldfish-problem---why-the-rnn-forgets\" aria-hidden=\"true\" class=\"anchor\" id=\"the-goldfish-problem---why-the-rnn-forgets\"></a>The goldfish problem - why the RNN forgets</h2>\n<p>The RNN has memory, yes. But it's a <strong>goldfish</strong> memory.</p>\n<p>Imagine this sentence:</p>\n<blockquote>\n<p>&quot;This is <strong>Jan</strong> and he's 30 years old. He likes hiking in the mountains, programming in Python, and playing the guitar. His favorite color is green. He once wanted to become an astronaut, but then he discovered that (...) [here 50 words about various things] (...) and that's why <strong>___</strong> went to music school.&quot;</p>\n</blockquote>\n<p>What should &quot;___&quot; be? <strong>Jan.</strong> But to know that, the RNN has to remember the name from the beginning of the sentence. And here's the problem: after 50+ words, the signal from the first word is so <strong>diluted</strong> that the RNN practically doesn't remember it.</p>\n<p>This is the famous <strong>vanishing gradient</strong> problem.</p>\n<p>Metaphor: <strong>Chinese whispers</strong>. You play Chinese whispers - the first person whispers a message to the second, that one to the third, and so on. After 10 people the message is a bit distorted. After 50 people - completely unreadable. After 100 people - someone says &quot;buy milk&quot;, and the last person hears &quot;grab bread&quot;.</p>\n<p>In an RNN the gradient (the learning signal) flows through the network exactly the same way - <strong>step by step</strong>. At each step it gets multiplied by some weights. If those weights are smaller than 1, then after many multiplications the gradient <strong>vanishes to zero</strong>. The network stops learning from distant words.</p>\n<p>And sometimes it's the other way - the weights are bigger than 1 and the gradient <strong>grows exponentially</strong> (exploding gradient). The network &quot;goes crazy&quot; and values shoot into space.</p>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1192.3552\" height=\"96\" viewBox=\"0 0 1192.3552 96\"><rect x=\"0\" y=\"0\" width=\"1192.3552\" height=\"96\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 189.125,44.000 L 274.806,44.000\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(274.81 44.00) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-0\" data-label-kind=\"center\" x=\"197.80\" y=\"13.70\" width=\"68.33\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-0\" data-label-kind=\"center\"><text x=\"231.97\" y=\"31.40\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"231.97\" dy=\"0.00\">&quot;×0.7&quot;</tspan></text></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 386.717,44.000 L 472.397,44.000\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(472.40 44.00) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-1\" data-label-kind=\"center\" x=\"395.39\" y=\"13.70\" width=\"68.33\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-1\" data-label-kind=\"center\"><text x=\"429.56\" y=\"31.40\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"429.56\" dy=\"0.00\">&quot;×0.7&quot;</tspan></text></g><path id=\"edge-2\" class=\"edgePath\" data-edge-id=\"edge-2\" d=\"M 584.308,44.000 L 669.988,44.000\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(669.99 44.00) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-2\" data-label-kind=\"center\" x=\"592.98\" y=\"13.70\" width=\"68.33\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-2\" data-label-kind=\"center\"><text x=\"627.15\" y=\"31.40\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"627.15\" dy=\"0.00\">&quot;×0.7&quot;</tspan></text></g><path id=\"edge-3\" class=\"edgePath\" data-edge-id=\"edge-3\" d=\"M 781.899,44.000 L 858.565,44.000\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(858.56 44.00) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-3\" data-label-kind=\"center\" x=\"791.01\" y=\"13.70\" width=\"58.44\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-3\" data-label-kind=\"center\"><text x=\"820.23\" y=\"31.40\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"820.23\" dy=\"0.00\">&quot;...&quot;</tspan></text></g><path id=\"edge-4\" class=\"edgePath\" data-edge-id=\"edge-4\" d=\"M 979.127,44.000 L 1055.793,44.000\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1055.79 44.00) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-4\" data-label-kind=\"center\" x=\"988.24\" y=\"13.70\" width=\"58.44\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-4\" data-label-kind=\"center\"><text x=\"1017.46\" y=\"31.40\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"1017.46\" dy=\"0.00\">&quot;...&quot;</tspan></text></g><rect x=\"8.00\" y=\"8.00\" width=\"181.13\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#66cc66\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"98.56\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"98.56\" dy=\"0.00\">Step 1</tspan><tspan x=\"98.56\" dy=\"21.00\">gradient = 1.0</tspan></text><rect x=\"274.81\" y=\"8.00\" width=\"111.91\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#99cc66\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"330.76\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"330.76\" dy=\"0.00\">Step 2</tspan><tspan x=\"330.76\" dy=\"21.00\">0.7</tspan></text><rect x=\"472.40\" y=\"8.00\" width=\"111.91\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#cccc66\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"528.35\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"528.35\" dy=\"0.00\">Step 3</tspan><tspan x=\"528.35\" dy=\"21.00\">0.49</tspan></text><rect x=\"669.99\" y=\"8.00\" width=\"111.91\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#cc9966\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"725.94\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"725.94\" dy=\"0.00\">Step 4</tspan><tspan x=\"725.94\" dy=\"21.00\">0.34</tspan></text><rect x=\"858.56\" y=\"8.00\" width=\"120.56\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#cc6666\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"918.85\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"918.85\" dy=\"0.00\">Step 20</tspan><tspan x=\"918.85\" dy=\"21.00\">0.001</tspan></text><rect x=\"1055.79\" y=\"8.00\" width=\"120.56\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#993333\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"1116.07\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"1116.07\" dy=\"0.00\">Step 50</tspan><tspan x=\"1116.07\" dy=\"21.00\">≈ 0</tspan></text></svg></div>\n<div class=\"markdown-alert markdown-alert-warning\">\n<p class=\"markdown-alert-title\">Warning</p>\n<p><strong>Why is this so important?</strong> Because language is full of <strong>long dependencies</strong>. &quot;The <strong>cat</strong>, which already ate all the fish in the fridge and then slept on the couch for three hours, was <strong>happy</strong>.&quot; - to connect &quot;cat&quot; with &quot;was happy&quot;, the model has to jump over a dozen words. An RNN can't do that.</p>\n</div>\n<p>And then in 1997 Sepp Hochreiter and Jürgen Schmidhuber said: <strong>what if we gave the network an explicit memory mechanism?</strong></p>\n<hr />\n<h2><a href=\"#lstm---the-network-with-a-notebook\" aria-hidden=\"true\" class=\"anchor\" id=\"lstm---the-network-with-a-notebook\"></a>LSTM - the network with a notebook</h2>\n<p>A <strong>Long Short-Term Memory (LSTM)</strong> is an RNN on steroids. Instead of one simple hidden state, the LSTM has a <strong>memory cell</strong> (cell state) and <strong>three gates</strong> that decide what to do with that memory.</p>\n<p>The metaphor that works best: <strong>an LSTM is a student with a notebook and three rules</strong>.</p>\n<h3><a href=\"#the-forget-gate---throw-out-old-notes\" aria-hidden=\"true\" class=\"anchor\" id=\"the-forget-gate---throw-out-old-notes\"></a>The forget gate - &quot;throw out old notes&quot;</h3>\n<p>At the beginning of each step the LSTM asks: <strong>&quot;what from my current memory is already outdated and I can throw out?&quot;</strong></p>\n<p>When you read a new chapter of a book, you don't need to remember what the characters had for breakfast three chapters ago. You forget irrelevant details to make room for new ones.</p>\n<p>In an LSTM: the forget gate passes each element of memory through a <strong>sigmoid</strong> (values 0-1). Close to 0 = &quot;forget&quot;. Close to 1 = &quot;keep&quot;.</p>\n<h3><a href=\"#the-input-gate---save-this-its-important\" aria-hidden=\"true\" class=\"anchor\" id=\"the-input-gate---save-this-its-important\"></a>The input gate - &quot;save this, it's important&quot;</h3>\n<p>Then the LSTM asks: <strong>&quot;what from the new word is worth saving?&quot;</strong></p>\n<p>When you read &quot;My name is <strong>Jan</strong>&quot; - you have a reflex: &quot;OK, this is important, I have to remember it&quot;. You don't memorize every word literally, but you <strong>pick out</strong> what's relevant.</p>\n<p>In an LSTM: the input gate decides which new information to let through to the cell state.</p>\n<h3><a href=\"#the-output-gate---show-me-what-i-need-right-now\" aria-hidden=\"true\" class=\"anchor\" id=\"the-output-gate---show-me-what-i-need-right-now\"></a>The output gate - &quot;show me what I need right now&quot;</h3>\n<p>Finally the LSTM asks: <strong>&quot;what from my memory is relevant to what I'm doing right now?&quot;</strong></p>\n<p>When someone asks you &quot;What's the name of that character we just read about?&quot; - you reach into the notebook and pull out the specific information. You don't show the whole notebook - only what's needed <strong>now</strong>.</p>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"900.41156\" height=\"1148.5\" viewBox=\"0 0 900.41156 1148.5\"><rect x=\"0\" y=\"0\" width=\"900.41156\" height=\"1148.5\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><rect x=\"8.00\" y=\"105.00\" width=\"876.41\" height=\"1027.50\" rx=\"10\" ry=\"10\" fill=\"#F1F5F9\" stroke=\"#CBD5E1\" stroke-width=\"1\" /><text x=\"446.21\" y=\"132.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"446.21\" dy=\"0.00\">LSTM - memory cell</tspan></text><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 451.103,238.500 L 451.103,248.125 Q 451.103,256.000 458.978,256.000 L 558.399,256.000 Q 568.399,256.000 568.399,266.000 L 568.399,410.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(568.40 410.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 677.310,360.500 L 677.310,370.125 Q 677.310,378.000 669.702,380.033 L 628.792,390.967 Q 621.184,393.000 621.184,400.875 L 621.184,410.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(621.18 410.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-2\" class=\"edgePath\" data-edge-id=\"edge-2\" d=\"M 536.399,461.500 L 536.399,471.125 Q 536.399,479.000 531.431,485.110 L 495.023,529.890 Q 490.055,536.000 490.055,543.875 L 490.055,553.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(490.05 553.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-3\" class=\"edgePath\" data-edge-id=\"edge-3\" d=\"M 379.825,503.500 L 379.825,513.125 Q 379.825,521.000 385.245,526.713 L 388.635,530.287 Q 394.055,536.000 394.055,543.875 L 394.055,553.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(394.05 553.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-4\" class=\"edgePath\" data-edge-id=\"edge-4\" d=\"M 214.296,360.500 L 214.296,370.125 Q 214.296,378.000 221.763,380.500 L 251.630,390.500 Q 259.098,393.000 259.098,400.875 L 259.098,410.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(259.10 410.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-5\" class=\"edgePath\" data-edge-id=\"edge-5\" d=\"M 442.066,604.500 L 442.066,654.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(442.07 654.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-6\" class=\"edgePath\" data-edge-id=\"edge-6\" d=\"M 442.083,747.500 L 442.083,797.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(442.08 797.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-7\" class=\"edgePath\" data-edge-id=\"edge-7\" d=\"M 458.094,848.500 L 458.094,898.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(458.09 898.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-8\" class=\"edgePath\" data-edge-id=\"edge-8\" d=\"M 453.827,360.500 L 453.827,379.300 Q 453.827,389.300 443.827,389.300 L 190.500,389.300 Q 180.500,389.300 180.500,399.300 L 180.500,866.500 Q 180.500,876.500 190.500,876.500 L 432.004,876.500 Q 441.904,876.500 441.904,886.400 L 441.904,898.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(441.90 898.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-9\" class=\"edgePath\" data-edge-id=\"edge-9\" d=\"M 442.099,949.500 L 442.099,999.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(442.10 999.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-10\" class=\"edgePath\" data-edge-id=\"edge-10\" d=\"M 215.976,80.000 L 215.976,102.750 Q 215.976,112.750 225.976,112.750 L 625.313,112.750 Q 635.313,112.750 635.313,122.750 L 635.313,288.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(635.31 288.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-11\" class=\"edgePath\" data-edge-id=\"edge-11\" d=\"M 144.776,80.000 L 144.776,93.116 Q 144.776,97.500 149.160,97.500 L 150.134,97.500 Q 154.518,97.500 154.518,101.884 L 154.518,288.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(154.52 288.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-12\" class=\"edgePath\" data-edge-id=\"edge-12\" d=\"M 188.427,80.000 L 188.427,256.500 Q 188.427,266.500 198.427,266.500 L 372.617,266.500 Q 382.517,266.500 382.517,276.400 L 382.517,288.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(382.52 288.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-13\" class=\"edgePath\" data-edge-id=\"edge-13\" d=\"M 732.478,80.000 L 732.478,89.625 Q 732.478,97.500 732.331,105.374 L 729.389,263.126 Q 729.242,271.000 729.242,278.875 L 729.242,288.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(729.24 288.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-14\" class=\"edgePath\" data-edge-id=\"edge-14\" d=\"M 642.301,80.000 L 642.301,85.280 Q 642.301,89.600 646.621,89.600 L 869.253,89.600 Q 869.973,89.600 869.973,88.880 L 869.973,88.720 Q 869.973,88.000 869.253,88.000 L 601.507,88.000 Q 594.982,88.000 594.982,81.475 L 594.982,80.025 Q 594.982,73.500 588.457,73.500 L 254.695,73.500 Q 244.695,73.500 244.695,83.500 L 244.695,288.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(244.69 288.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-15\" class=\"edgePath\" data-edge-id=\"edge-15\" d=\"M 602.982,79.000 L 593.357,79.000 Q 585.482,79.000 584.963,86.858 L 572.091,281.642 Q 571.572,289.500 563.697,289.500 L 554.072,289.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(554.07 289.50) rotate(180.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect x=\"329.86\" y=\"553.50\" width=\"224.38\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"442.05\" y=\"582.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"442.05\" dy=\"0.00\">➕ + new information</tspan></text><rect x=\"293.99\" y=\"145.50\" width=\"258.99\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"423.49\" y=\"174.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"423.49\" dy=\"0.00\">📥 Cell state (input)</tspan><tspan x=\"423.49\" dy=\"21.00\">&lt;i&gt;the conveyor belt of</tspan><tspan x=\"423.49\" dy=\"21.00\">information&lt;/i&gt;</tspan></text><rect x=\"321.23\" y=\"654.50\" width=\"241.69\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"442.08\" y=\"683.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"442.08\" dy=\"0.00\">📤 Cell state (output)</tspan><tspan x=\"442.08\" dy=\"21.00\">&lt;i&gt;updated conveyor</tspan><tspan x=\"442.08\" dy=\"21.00\">belt&lt;/i&gt;</tspan></text><rect x=\"604.07\" y=\"288.50\" width=\"250.34\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#ff6666\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"729.24\" y=\"317.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"729.24\" dy=\"0.00\">🗑️ Forget gate</tspan><tspan x=\"729.24\" dy=\"21.00\">&lt;i&gt;what to forget?&lt;/i&gt;</tspan></text><rect x=\"303.95\" y=\"999.50\" width=\"276.29\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#cc99ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"442.10\" y=\"1028.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"442.10\" dy=\"0.00\">🧠 Hidden state</tspan><tspan x=\"442.10\" dy=\"21.00\">&lt;i&gt;what it &apos;thinks&apos; right</tspan><tspan x=\"442.10\" dy=\"21.00\">now&lt;/i&gt;</tspan></text><rect x=\"602.98\" y=\"8.00\" width=\"258.99\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"732.48\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"732.48\" dy=\"0.00\">🧠 Previous hidden state</tspan><tspan x=\"732.48\" dy=\"21.00\">(h_{t-1})</tspan></text><rect x=\"38.00\" y=\"288.50\" width=\"233.04\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#66cc66\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"154.52\" y=\"317.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"154.52\" dy=\"0.00\">📥 Input gate</tspan><tspan x=\"154.52\" dy=\"21.00\">&lt;i&gt;what to save?&lt;/i&gt;</tspan></text><rect x=\"469.18\" y=\"410.50\" width=\"198.43\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"568.40\" y=\"439.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"568.40\" dy=\"0.00\">✖️ × forget gate</tspan></text><rect x=\"342.88\" y=\"898.50\" width=\"198.43\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"442.10\" y=\"927.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"442.10\" dy=\"0.00\">✖️ × output gate</tspan></text><rect x=\"212.10\" y=\"410.50\" width=\"207.08\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"315.64\" y=\"439.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"315.64\" dy=\"0.00\">📝 New information</tspan><tspan x=\"315.64\" dy=\"21.00\">&lt;i&gt;input gate ×</tspan><tspan x=\"315.64\" dy=\"21.00\">candidate&lt;/i&gt;</tspan></text><rect x=\"321.04\" y=\"288.50\" width=\"233.04\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#6666ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"437.55\" y=\"317.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"437.55\" dy=\"0.00\">📤 Output gate</tspan><tspan x=\"437.55\" dy=\"21.00\">&lt;i&gt;what to show?&lt;/i&gt;</tspan></text><rect x=\"394.79\" y=\"797.50\" width=\"94.61\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"442.09\" y=\"826.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"442.09\" dy=\"0.00\">tanh</tspan></text><rect x=\"45.56\" y=\"29.00\" width=\"198.43\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"144.78\" y=\"58.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"144.78\" dy=\"0.00\">📖 New word (x_t)</tspan></text></svg></div>\n<p>The key thing: the <strong>cell state</strong> is that &quot;conveyor belt&quot;. Information on it can flow <strong>almost unchanged</strong> through many steps - the gates only decide what to let through, what to add, and what to remove. This solves the vanishing gradient problem, because the information doesn't have to be &quot;multiplied&quot; at every step - it can just flow.</p>\n<div class=\"markdown-alert markdown-alert-note\">\n<p class=\"markdown-alert-title\">Note</p>\n<p><strong>RNN vs LSTM in one sentence:</strong> An RNN tries to remember <strong>everything</strong>, but forgets quickly. An LSTM is <strong>selective</strong> - it decides what to keep, what to update, and what to show. That's the difference between &quot;trying to memorize an entire lecture word for word&quot; and &quot;taking notes of the most important points&quot;.</p>\n</div>\n<details>\n<summary>For the curious: the math of LSTM gates</summary>\n<p>If you want to see the formulas, here they are (you don't have to memorize them, but it's worth seeing that it's not black magic):</p>\n<p><strong>Forget gate:</strong>\n$$f_t = \\sigma(W_f \\cdot [h_{t-1}, x_t] + b_f)$$</p>\n<p><strong>Input gate:</strong>\n$$i_t = \\sigma(W_i \\cdot [h_{t-1}, x_t] + b_i)$$</p>\n<p><strong>Cell state candidate:</strong>\n$$\\tilde{C}<em>t = \\tanh(W_c \\cdot [h</em>{t-1}, x_t] + b_c)$$</p>\n<p><strong>Cell state update:</strong>\n$$C_t = f_t \\odot C_{t-1} + i_t \\odot \\tilde{C}_t$$</p>\n<p><strong>Output gate:</strong>\n$$o_t = \\sigma(W_o \\cdot [h_{t-1}, x_t] + b_o)$$</p>\n<p><strong>Hidden state:</strong>\n$$h_t = o_t \\odot \\tanh(C_t)$$</p>\n<p>Where $\\sigma$ is the sigmoid (squashes values into 0-1), $\\odot$ is element-wise multiplication, and $[h_{t-1}, x_t]$ is the concatenation of the previous hidden state with the new input.</p>\n</details>\n<h3><a href=\"#an-experiment-for-you\" aria-hidden=\"true\" class=\"anchor\" id=\"an-experiment-for-you\"></a>An experiment for you</h3>\n<p>Try it yourself. Fire up ChatGPT (or Claude, Gemini - whatever you have) and send this prompt:</p>\n<blockquote>\n<p>&quot;Pola had a rare ability to remember numbers. Her favorite number was 42. She also liked longboarding, watercolor painting, and playing chess. Her cat was named Whiskers. (...) <em>[paste 3-4 paragraphs of any text here - a pancake recipe, a weather report, whatever]</em> (...) Still, it was ___ who decided to enter the math competition.&quot;</p>\n</blockquote>\n<p>See whether the model fills in the blank correctly (<strong>Pola</strong>). An LSTM would handle this. A plain RNN - probably not. And why? Because the LSTM has a mechanism that says &quot;remember the name <strong>Pola</strong> - this might be important later&quot;. The RNN would simply... forget ;-)</p>\n<hr />\n<h2><a href=\"#why-lstm-still-wasnt-enough\" aria-hidden=\"true\" class=\"anchor\" id=\"why-lstm-still-wasnt-enough\"></a>Why LSTM still wasn't enough</h2>\n<p>OK, so LSTM solved the memory problem. At least partially. But new problems appeared, and they turned out to be <strong>fundamental</strong>.</p>\n<h3><a href=\"#problem-1-even-lstm-has-its-limits\" aria-hidden=\"true\" class=\"anchor\" id=\"problem-1-even-lstm-has-its-limits\"></a>Problem 1: Even LSTM has its limits</h3>\n<p>LSTM solved vanishing gradient <strong>to a large extent</strong>, but not <strong>completely</strong>. When the distance between related words grows to hundreds or thousands of words, even LSTM starts losing the thread of the narrative. Bengio et al. (1994) showed that recurrent networks - even with gates - still struggle to maintain useful gradients over very long distances.</p>\n<p>So: instead of forgetting after 10 words (RNN), LSTM forgets after... 100? 200? Better, but still not ideal.</p>\n<h3><a href=\"#problem-2-sequentiality--bottleneck\" aria-hidden=\"true\" class=\"anchor\" id=\"problem-2-sequentiality--bottleneck\"></a>Problem 2: Sequentiality = bottleneck</h3>\n<p>And this is the <strong>most important</strong> problem.</p>\n<p>RNN and LSTM process data <strong>step by step</strong>. Step 2 has to wait for step 1. Step 3 for step 2. And so on.</p>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"899.1033\" height=\"75\" viewBox=\"0 0 899.1033 75\"><rect x=\"0\" y=\"0\" width=\"899.1033\" height=\"75\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 119.911,33.500 L 160.638,33.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(160.64 33.50) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 272.549,33.500 L 313.277,33.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(313.28 33.50) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-2\" class=\"edgePath\" data-edge-id=\"edge-2\" d=\"M 425.188,33.500 L 465.915,33.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(465.92 33.50) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-3\" class=\"edgePath\" data-edge-id=\"edge-3\" d=\"M 577.826,33.500 L 618.554,33.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(618.55 33.50) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-4\" class=\"edgePath\" data-edge-id=\"edge-4\" d=\"M 704.509,33.500 L 745.237,33.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(745.24 33.50) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect x=\"8.00\" y=\"8.00\" width=\"111.91\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"63.96\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"63.96\" dy=\"0.00\">Step 1</tspan></text><rect x=\"160.64\" y=\"8.00\" width=\"111.91\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"216.59\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"216.59\" dy=\"0.00\">Step 2</tspan></text><rect x=\"313.28\" y=\"8.00\" width=\"111.91\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"369.23\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"369.23\" dy=\"0.00\">Step 3</tspan></text><rect x=\"465.92\" y=\"8.00\" width=\"111.91\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"521.87\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"521.87\" dy=\"0.00\">Step 4</tspan></text><rect x=\"618.55\" y=\"8.00\" width=\"85.96\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"661.53\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"661.53\" dy=\"0.00\">...</tspan></text><rect x=\"745.24\" y=\"8.00\" width=\"137.87\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#F8FAFC\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"814.17\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"814.17\" dy=\"0.00\">Step 1000</tspan></text></svg></div>\n<p>Now think about GPUs. A GPU is a machine that <strong>loves</strong> doing many things at once (parallel processing). Thousands of cores working simultaneously.</p>\n<p>But RNN/LSTM tells the GPU: &quot;no, no, wait. First let's finish step 1, <strong>only then</strong> start step 2&quot;. The GPU cries.</p>\n<p>It's like a book with 10,000 chapters, where <strong>each chapter has to be read after the previous one</strong>. You can't read chapter 500 until you've finished 499. You can't parallelize this. For short texts it's not a problem, but when training a model on <strong>billions</strong> of words? That's a nightmare.</p>\n<p>LSTM additionally has <strong>4x more parameters</strong> than a simple RNN (three gates + cell state = four sets of weights per neuron). So it trains slower and uses more memory.</p>\n<h3><a href=\"#problem-3-black-box\" aria-hidden=\"true\" class=\"anchor\" id=\"problem-3-black-box\"></a>Problem 3: &quot;Black box&quot;</h3>\n<p>LSTM (like most deep learning models) is hard to interpret. The model can generate correct results, but <strong>it's hard to understand why</strong> it made this decision and not another. In applications like medicine or finance, where interpretability is key, that's a serious problem.</p>\n<h3><a href=\"#evolution-summary---what-solved-what\" aria-hidden=\"true\" class=\"anchor\" id=\"evolution-summary---what-solved-what\"></a>Evolution summary - what solved what</h3>\n<table>\n<thead>\n<tr>\n<th>Architecture</th>\n<th>Year</th>\n<th>Solves...</th>\n<th>But can't...</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Perceptron</strong></td>\n<td>1958</td>\n<td>Linear classification</td>\n<td>XOR, non-linearity</td>\n</tr>\n<tr>\n<td><strong>MLP</strong></td>\n<td>1986</td>\n<td>Non-linear relationships</td>\n<td>Understand word order</td>\n</tr>\n<tr>\n<td><strong>RNN</strong></td>\n<td>1986</td>\n<td>Process sequences step by step</td>\n<td>Remember long dependencies</td>\n</tr>\n<tr>\n<td><strong>LSTM</strong></td>\n<td>1997</td>\n<td>Remember longer thanks to gates</td>\n<td>Process in parallel, very long texts</td>\n</tr>\n</tbody>\n</table>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1284.3135\" height=\"117.12468\" viewBox=\"0 0 1284.3135 117.12468\"><rect x=\"0\" y=\"0\" width=\"1284.3135\" height=\"117.12468\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 1034.787,54.556 L 1179.992,54.556\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(1179.99 54.56) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-0\" data-label-kind=\"center\" x=\"1043.56\" y=\"24.26\" width=\"127.65\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-0\" data-label-kind=\"center\"><text x=\"1107.39\" y=\"41.96\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"1107.39\" dy=\"0.00\">&quot;add layers&quot;</tspan></text></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 163.170,54.562 L 163.170,66.772 Q 163.170,76.762 173.160,76.762 L 332.992,76.762 Q 342.982,76.762 342.982,66.772 L 342.982,54.562\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(342.98 54.56) rotate(-90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-1\" data-label-kind=\"center\" x=\"194.19\" y=\"78.76\" width=\"117.77\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-1\" data-label-kind=\"center\"><text x=\"253.08\" y=\"96.46\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"253.08\" dy=\"0.00\">&quot;add gates&quot;</tspan></text></g><path id=\"edge-2\" class=\"edgePath\" data-edge-id=\"edge-2\" d=\"M 567.367,54.494 L 644.262,54.494\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(644.26 54.49) rotate(0.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect data-edge-id=\"edge-2\" data-label-kind=\"center\" x=\"576.59\" y=\"56.49\" width=\"58.44\" height=\"28.40\" rx=\"2\" ry=\"2\" fill=\"#FFFFFF\" fill-opacity=\"0.00\" stroke=\"#94A3B8\" stroke-opacity=\"0.00\" stroke-width=\"0.8\"/><g class=\"edgeLabel\" data-edge-id=\"edge-2\" data-label-kind=\"center\"><text x=\"605.81\" y=\"74.19\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"605.81\" dy=\"0.00\">&quot;???&quot;</tspan></text></g><rect x=\"342.98\" y=\"8.00\" width=\"224.38\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#cc99ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"455.17\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"455.17\" dy=\"0.00\">LSTM</tspan><tspan x=\"455.17\" dy=\"21.00\">✅ longer memory</tspan><tspan x=\"455.17\" dy=\"21.00\">❌ sequential = slow</tspan></text><rect x=\"1179.99\" y=\"29.11\" width=\"88.32\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"1224.15\" y=\"58.11\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"1224.15\" dy=\"0.00\">MLP</tspan></text><rect x=\"845.01\" y=\"8.00\" width=\"189.78\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#ff9999\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"939.90\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"939.90\" dy=\"0.00\">Perceptron</tspan><tspan x=\"939.90\" dy=\"21.00\">✅ classifies</tspan><tspan x=\"939.90\" dy=\"21.00\">❌ only linearly</tspan></text><rect x=\"644.26\" y=\"28.99\" width=\"151.70\" height=\"51.00\" rx=\"3\" ry=\"3\" fill=\"#ff6666\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"720.11\" y=\"57.99\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"720.11\" dy=\"0.00\">&lt;b&gt;???&lt;/b&gt;</tspan></text><rect x=\"8.00\" y=\"8.12\" width=\"155.17\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#99ccff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"85.58\" y=\"37.12\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"85.58\" dy=\"0.00\">RNN</tspan><tspan x=\"85.58\" dy=\"21.00\">✅ sequences</tspan><tspan x=\"85.58\" dy=\"21.00\">❌ forgets</tspan></text></svg></div>\n<p>Each generation solved the previous one's problem, but created a <strong>new</strong> one. It's like a game of whack-a-mole - you hit one mole, another pops up.</p>\n<p>And then in 2017 someone asked a crazy question...</p>\n<hr />\n<h2><a href=\"#what-if-we-stop-reading-one-by-one\" aria-hidden=\"true\" class=\"anchor\" id=\"what-if-we-stop-reading-one-by-one\"></a>&quot;What if we stop reading one by one?&quot;</h2>\n<p>The metaphor that changes everything.</p>\n<p>Imagine you're reading a novel. Now you have three ways to do it:</p>\n<ul>\n<li><strong>RNN</strong> - you remember the last few sentences. The rest blurs.</li>\n<li><strong>LSTM</strong> - you hold onto the main plot, forget the small details. Better, but you still read linearly.</li>\n<li><strong>???</strong> - instead of reading word by word, <strong>you look at the whole page at once</strong>. Your attention jumps to the key characters, important plot moments, unexpected twists. <strong>You don't read in order - you grasp the whole thing simultaneously!</strong></li>\n</ul>\n<p>In 2017 a group of researchers at Google published a paper with the modest title: <strong>&quot;Attention Is All You Need&quot;</strong>. Their crazy idea? <strong>What if we stop reading one by one altogether?</strong> What if every word could &quot;see&quot; <strong>all the other words at once</strong>?</p>\n<p>And <strong>a revolution happened</strong>. Because if every word looks at every other <strong>simultaneously</strong> (not waiting for its turn), then:</p>\n<ul>\n<li>There's no sequential bottleneck - everything happens <strong>in parallel</strong></li>\n<li>The GPU is in heaven - thousands of cores working at once</li>\n<li>Long dependencies? No problem - word no. 1 and word no. 1000 &quot;see&quot; each other <strong>directly</strong>, without 999 intermediate steps</li>\n</ul>\n<p>This architecture is called the <strong>Transformer</strong>. And it's what ChatGPT, Claude, Gemini, and all the LLMs you know are built on.</p>\n<hr />\n<h2><a href=\"#summary---the-whole-evolution-in-one-place\" aria-hidden=\"true\" class=\"anchor\" id=\"summary---the-whole-evolution-in-one-place\"></a>Summary - the whole evolution in one place</h2>\n<table>\n<thead>\n<tr>\n<th>Architecture</th>\n<th>Metaphor</th>\n<th>What it can do</th>\n<th>What it can't?</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Perceptron</strong></td>\n<td>A ruler</td>\n<td>Draws one line, classifies into 2 groups</td>\n<td>XOR, non-linearity, anything complex</td>\n</tr>\n<tr>\n<td><strong>MLP</strong></td>\n<td>A team of analysts</td>\n<td>Models non-linear relationships, &quot;depth&quot;</td>\n<td>Doesn't understand order, sees everything at once</td>\n</tr>\n<tr>\n<td><strong>RNN</strong></td>\n<td>A word-by-word reader</td>\n<td>Processes sequences, has a hidden state</td>\n<td>Short memory (vanishing gradient)</td>\n</tr>\n<tr>\n<td><strong>LSTM</strong></td>\n<td>A student with a notebook and gates</td>\n<td>Selective memory, three control gates</td>\n<td>Sequential = slow, no parallelization</td>\n</tr>\n<tr>\n<td><strong>Transformer</strong></td>\n<td>The whole page at once</td>\n<td>Parallelism, attention to everything</td>\n<td>...to be discovered in the next posts...</td>\n</tr>\n</tbody>\n</table>\n<div class=\"mermaid-diagram\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"368.94678\" height=\"605.5\" viewBox=\"0 0 368.94678 605.5\"><rect x=\"0\" y=\"0\" width=\"368.94678\" height=\"605.5\" fill=\"#FFFFFF\"/><defs><marker id=\"arrow-0\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker><marker id=\"arrow-start-0\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"1\" stroke-dasharray=\"1,0\"/></marker></defs><rect x=\"8.00\" y=\"8.00\" width=\"344.95\" height=\"581.50\" rx=\"10\" ry=\"10\" fill=\"#F1F5F9\" stroke=\"#CBD5E1\" stroke-width=\"1\" /><text x=\"180.47\" y=\"37.00\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#0F172A\"><tspan x=\"180.47\" dy=\"0.00\">From a neuron to an LLM -</tspan><tspan x=\"180.47\" dy=\"21.00\">the path we took</tspan></text><path id=\"edge-0\" class=\"edgePath\" data-edge-id=\"edge-0\" d=\"M 180.472,144.500 L 180.472,168.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(180.47 168.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-1\" class=\"edgePath\" data-edge-id=\"edge-1\" d=\"M 180.472,240.500 L 180.473,264.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(180.47 264.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-2\" class=\"edgePath\" data-edge-id=\"edge-2\" d=\"M 180.473,336.500 L 180.473,360.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(180.47 360.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><path id=\"edge-3\" class=\"edgePath\" data-edge-id=\"edge-3\" d=\"M 180.473,432.500 L 180.473,456.500\" fill=\"none\" stroke=\"#64748B\" stroke-width=\"2\"    stroke-linecap=\"round\" stroke-linejoin=\"round\" /><g transform=\"translate(180.47 456.50) rotate(90.00)\"><polygon points=\"0,0 -7.50,3.90 -7.50,-3.90\" fill=\"#64748B\" stroke=\"#64748B\" stroke-width=\"2\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/></g><rect x=\"76.93\" y=\"360.50\" width=\"207.08\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#cc99ff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"180.47\" y=\"389.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"180.47\" dy=\"0.00\">LSTM 1997</tspan><tspan x=\"180.47\" dy=\"21.00\">memory with gates</tspan></text><rect x=\"55.30\" y=\"168.50\" width=\"250.34\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#ffcc99\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"180.47\" y=\"197.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"180.47\" dy=\"0.00\">MLP 1986</tspan><tspan x=\"180.47\" dy=\"21.00\">non-linearity + layers</tspan></text><rect x=\"59.63\" y=\"72.50\" width=\"241.69\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#ff9999\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"180.47\" y=\"101.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"180.47\" dy=\"0.00\">Perceptron 1958</tspan><tspan x=\"180.47\" dy=\"21.00\">linear classification</tspan></text><rect x=\"46.65\" y=\"264.50\" width=\"267.64\" height=\"72.00\" rx=\"3\" ry=\"3\" fill=\"#99ccff\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"180.47\" y=\"293.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#000\"><tspan x=\"180.47\" dy=\"0.00\">RNN 1986</tspan><tspan x=\"180.47\" dy=\"21.00\">sequences + hidden state</tspan></text><rect x=\"38.00\" y=\"456.50\" width=\"284.95\" height=\"93.00\" rx=\"3\" ry=\"3\" fill=\"#ff6666\" stroke=\"#94A3B8\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><text x=\"180.47\" y=\"485.50\" text-anchor=\"middle\" font-family=\"Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,DejaVu Sans,Liberation Sans,sans-serif,Noto Color Emoji,Apple Color Emoji,Segoe UI Emoji\" font-size=\"14\" fill=\"#fff\"><tspan x=\"180.47\" dy=\"0.00\">Transformer 2017</tspan><tspan x=\"180.47\" dy=\"21.00\">attention to everything at</tspan><tspan x=\"180.47\" dy=\"21.00\">once</tspan></text></svg></div>\n<h3><a href=\"#final-quiz-match-the-architecture\" aria-hidden=\"true\" class=\"anchor\" id=\"final-quiz-match-the-architecture\"></a>Final quiz: match the architecture<sup class=\"footnote-ref\"><a href=\"#fn-2\" id=\"fnref-2\" data-footnote-ref>2</a></sup></h3>\n<ol>\n<li>You want to predict the price of a house based on square footage, number of rooms, and neighborhood - which architecture is enough?</li>\n<li>You need to process a 50-word sentence and determine its sentiment (positive/negative) - what do you choose?</li>\n<li>You're training a model on 10,000-word texts and every word has to &quot;see&quot; every other - RNN, LSTM, or something else?</li>\n<li>You want to classify points on a plane into two groups, but they're arranged in an X shape (XOR) - is a single perceptron enough?</li>\n</ol>\n<hr />\n<p>This post is quite long, but I felt this evolution from the perceptron to LSTM deserved a full, told story.</p>\n<p>If anything is unclear - <strong>let me know in the comments</strong>, I'll try to explain.</p>\n<p>Which architecture surprised you the most? Did you know that the &quot;AI Winter&quot; was caused by something as &quot;simple&quot; as XOR?</p>\n<blockquote>\n<p><strong>What's in the next post?</strong> We're getting into the <strong>Transformer</strong> - the architecture that changed everything. Attention, self-attention, positional encoding, multi-head attention - all the things that made ChatGPT exist in the first place. Stay tuned!</p>\n</blockquote>\n<p>See you next time!</p>\n<hr />\n<p><strong>Sources and interesting links:</strong></p>\n<p>If you want to go deeper, here are the materials I used:</p>\n<ul>\n<li><a href=\"https://d2l.ai/chapter_multilayer-perceptrons/mlp.html\">Multilayer Perceptrons - d2l.ai</a> - an excellent, visual introduction to MLP: layers, activation functions, the transition from linear regression to multi-layer networks</li>\n<li><a href=\"https://en.wikipedia.org/wiki/Multilayer_perceptron\">Multilayer perceptron - Wikipedia</a> - definitions, network diagrams, a timeline of the history from 1943 to the present</li>\n<li><a href=\"https://dev.to/zeromathai/multilayer-perceptron-mlp-a-practical-way-to-understand-neural-networks-3hic\">Multilayer Perceptron (MLP): A Practical Way to Understand Neural Networks - dev.to</a> - a fresh, very intuitive article with metaphors and a comparison of MLP vs CNN vs Transformer</li>\n<li><a href=\"https://ai.plainenglish.io/deep-learning-specialization-perceptron-explained-building-blocks-working-limitations-c1e3b0815f08\">Perceptron Explained - PlainEnglish</a> - the perceptron as the &quot;building block&quot; of networks, components, geometric intuition, limitations</li>\n<li><a href=\"https://www.geeksforgeeks.org/deep-learning/multi-layer-perceptron-learning-in-tensorflow/\">Multi-Layer Perceptron Learning in TensorFlow - GeeksforGeeks</a> - clear diagrams, forward propagation, backpropagation with implementation</li>\n<li><a href=\"https://www.geeksforgeeks.org/deep-learning/deep-learning-introduction-to-long-short-term-memory/\">Introduction to Long Short Term Memory - GeeksforGeeks</a> - an accessible introduction to LSTM: memory cell, gates, the long-term dependencies problem</li>\n<li><a href=\"https://papers.ssrn.com/sol3/JELJOUR_Results.cfm?form_name=journalBrowse&amp;journal_id=3747444\">Drawbacks of LSTM Algorithm: A Case Study - SSRN</a> - the drawbacks of LSTM: computational complexity, overfitting, lack of parallelization, sensitivity to hyperparameters</li>\n<li><a href=\"https://dev.to/sreeni5018/understanding-transformer-model-types-the-evolution-from-rnn-to-modern-ai-1j4i\">Understanding Transformer Model Types: The Evolution from RNN to Modern AI - dev.to</a> - a narrative account of the transition from RNNs to Transformers, encoder/decoder types</li>\n<li><a href=\"https://www.youtube.com/watch?v=gNusDo8D8gk\">LLM: Large Language Models Evolution - YouTube</a> - a video telling the development line from sequential models to attention-based architectures</li>\n</ul>\n<section class=\"footnotes\" data-footnotes>\n<ol>\n<li id=\"fn-1\">\n<p>Mini-quiz answers: 1) Linear - y = ax + b is a linear function. 2) Non-linear - the step function &quot;breaks&quot; linearity. 3) Linear! Without a non-linear activation, an MLP with 100 layers = one big linear transformation. That's exactly why activation functions are necessary. <a href=\"#fnref-1\" class=\"footnote-backref\" data-footnote-backref data-footnote-backref-idx=\"1\" aria-label=\"Back to reference 1\">↩</a></p>\n</li>\n<li id=\"fn-2\">\n<p>My answers: 1) A simple <strong>MLP</strong> is enough - tabular data, no sequence. 2) <strong>LSTM</strong> - a sequence of moderate length, LSTM will handle it. 3) <strong>Transformer</strong> - 10,000 words is too much even for LSTM. A Transformer with self-attention lets every word &quot;see&quot; every other without waiting. 4) <strong>No</strong> - a single perceptron can't solve XOR. You need at least an MLP (2 layers). <a href=\"#fnref-2\" class=\"footnote-backref\" data-footnote-backref data-footnote-backref-idx=\"2\" aria-label=\"Back to reference 2\">↩</a></p>\n</li>\n</ol>\n</section>\n",
      "summary": "\"From a single neuron in 1958, through MLP and RNN with the forgetting problem, to LSTM with memory gates. The evolution of architectures that led to Transformers.\"",
      "date_published": "2026-06-17T00:00:00-00:00",
      "image": "",
      "authors": [
        {
          "name": "Blazej Gruszka",
          "url": "https://www.linkedin.com/in/blazejgruszka/",
          "avatar": "https://github.com/bgruszka.png"
        }
      ],
      "tags": [
        "llm",
        "ai",
        "neural-networks",
        "rnn",
        "lstm",
        "perceptron",
        "mlp",
        "language-models",
        "deep-learning"
      ],
      "language": "en"
    }
  ]
}