<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
  <title>Jonas Öchsner</title>
  <subtitle>Applied computer science student in Bamberg, building machine-learning and data-protection systems. Writing about ML, distributed systems and the software behind them.</subtitle>
  <id>https://oechsner.dev/</id>
  <updated>2026-10-12T00:00:00Z</updated>
  <link rel="self" type="application/atom+xml" href="https://oechsner.dev/atom.xml" />
  <link rel="alternate" type="text/html" href="https://oechsner.dev/" />
  <author><name>Jonas Öchsner</name></author>
  <entry>
    <title>Winning a prize at my first hackathon</title>
    <link rel="alternate" type="text/html" href="https://oechsner.dev/blog/healthcare-innovation-challenge" />
    <id>https://oechsner.dev/blog/healthcare-innovation-challenge</id>
    <published>2026-10-12T00:00:00Z</published>
    <updated>2026-10-12T00:00:00Z</updated>
    <summary type="text">Tallaght University Hospital loses track of its wheelchairs because nobody has time to update an Excel file. We spent a night building an LLM-powered voice logger for inventory management and learned that the hard part of solving the problem isn't technology.</summary>
    <content type="html">&lt;p style=&quot;margin-bottom: 0.25em; font-size: 0.85em; color: #80818a&quot;&gt;12 October 2026 · 7 min read · 🤓 1/3 nerds&lt;/p&gt;
&lt;p style=&quot;margin-top: 0; font-size: 0.8em; letter-spacing: 0.08em; text-transform: uppercase; color: #a87a3c&quot;&gt;#hackathon&amp;nbsp;&amp;nbsp;#project report&lt;/p&gt;
&lt;p style=&quot;font-size: 1.1em; line-height: 1.7; padding-left: 1em; border-left: 3px solid #e0a85c&quot;&gt;Tallaght University Hospital loses track of its wheelchairs because nobody has time to update an Excel file. We spent a night building an LLM-powered voice logger for inventory management and learned that the hard part of solving the problem isn't technology.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://oechsner.dev/img/hic/cover.svg&quot; alt=&quot;&quot; style=&quot;width: 100%; height: auto; border-radius: 6px&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;padding: 0.75em 1em; border: 1px dashed rgba(128, 128, 128, 0.3); border-left: 3px solid #e0a85c; border-radius: 6px; font-size: 0.95em&quot;&gt;Our pitch deck for the app, produced AFTER Hackathon submission, for further presentation to TUH. Due to low risk and time constraints fully AI generated and iterated on. Source Code&lt;br&gt;&lt;a href=&quot;https://oechsner.dev/blog/healthcare-innovation-challenge&quot;&gt;▶ Interactive figure — try it on oechsner.dev&lt;/a&gt;&lt;/p&gt; &lt;h2 id=&quot;introduction&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Introduction&lt;/h2&gt; &lt;p&gt;This weekend I took part in the Health Innovation Challenge at TU Dublin’s Tallaght Campus, run together with Tallaght University Hospital (TUH) and supported by Amazon. Clinicians from TUH briefed us on real problems from their wards, Amazon people coached us on prototyping and pitching, and then we had ten hours, through the night, to build something.&lt;/p&gt; &lt;p&gt;My team, &lt;a href=&quot;https://www.linkedin.com/in/graciela-uscanga-781564125/&quot; rel=&quot;nofollow&quot;&gt;Graciela Uscanga&lt;/a&gt;, &lt;a href=&quot;https://www.linkedin.com/in/marvin-chewchut/&quot; rel=&quot;nofollow&quot;&gt;Marvin Chewchut&lt;/a&gt; and I, won &lt;strong&gt;Best Use of Technology&lt;/strong&gt;!&lt;/p&gt; &lt;p&gt;In this post I want to talk about our solution and approach. I especially want to cover the technical solution we chose.&lt;/p&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;Feel free to read the short version on &lt;a href=&quot;https://lnkd.in/p/eXHFBd4Y&quot; rel=&quot;nofollow&quot;&gt;LinkedIn&lt;/a&gt;, your time is valuable.&lt;/p&gt;&lt;/blockquote&gt; &lt;h2 id=&quot;the-situation-one-monolythic-excel-file&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;The situation: One monolythic Excel File&lt;/h2&gt; &lt;p&gt;We worked on Challenge 2, &lt;em&gt;Smarter equipment tracking for better patient care&lt;/em&gt;, submitted by a discharge planning occupational therapist.&lt;/p&gt; &lt;p&gt;The Occupational Therapy (OT) department owns about 155 items of specialist equipment. They are issued to inpatients on the daily, based on clinical need. Currently, all of it is tracked in an Excel workbook that only one person can open at any given time. Colour coding marks items that are in repair, out on a short-term loan or missing. A separate tab holds the waitlist.&lt;/p&gt; &lt;p&gt;When a therapist issues an item, they are supposed to open the spreadsheet and enter the patient, the equipment, the location, the date and whether it’s on loan. In practice, that often happens hours later or not at all. You can’t blame the Therapists for that, hospital reality is a lot of stress and chaos. It’s natural human error in a system, that’s not adjusted to the real needs.&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Updates are retrospective, so the tracker never reflects reality.&lt;/li&gt; &lt;li&gt;Therapy assistants do a monthly stock check, walking the wards to see where things actually are.&lt;/li&gt; &lt;li&gt;The waitlist gets skipped, because checking it means logging in, finding the file and scrolling through it, so equipment goes to whoever is asking rather than to whoever is next.&lt;/li&gt; &lt;li&gt;With that much colour-coded spreadsheet, it is hard to see at a glance what is actually available.&lt;/li&gt; &lt;li&gt;About &lt;strong&gt;€4,600 a year&lt;/strong&gt; of equipment goes missing and has to be replaced.&lt;/li&gt; &lt;li&gt;A lot of money gets lost due to the added working time.&lt;/li&gt;&lt;/ul&gt; &lt;h2 id=&quot;everything-we-wanted-to-build-and-why-we-couldn-t&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Everything we wanted to build, and why we couldn’t&lt;/h2&gt; &lt;p&gt;Our first brainstorm went where every engineer’s brainstorm goes: tag everything and track it automatically. RFID tags, NFC stickers, BLE beacons, OCR on Serial numbers, maybe even tracking staff location so the system could infer who moved what.&lt;/p&gt; &lt;p&gt;Research with the staff shut all of that down quickly:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;strong&gt;RFID won’t work.&lt;/strong&gt; That was the clearest &quot;&quot; we got all night.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Stickers don’t stick.&lt;/strong&gt; Equipment gets washed and decontaminated between patients. NFC tags fall off or get scrubbed off.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Staff don’t carry smartphones.&lt;/strong&gt; The device on the ward is the &lt;em&gt;Universal Communication Device&lt;/em&gt; (UCD from now on), a hospital handset whose main jobs are sending email and looking up patient records.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;No Cameras available&lt;/strong&gt; those UCD don’t have cameras. Buying them and supplying a device with a camera to every staff member wouldn’t be financially viable and will probably violate some privacy regulation.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Equipment leaves the building.&lt;/strong&gt; Some items go home with discharged patients on loan. A tracker that only works inside the hospital misses exactly the items that get lost.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;So the real constraint was not about technology at all. The tracker already holds the right information. It’s just that updating it is a separate task, done at a desk: a place where hospital staff should spend the least possible amount of time at.&lt;/p&gt; &lt;h2 id=&quot;the-winning-idea&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;The winning idea&lt;/h2&gt; &lt;p&gt;After some research and brainstorming, we realized that everything we needed for identification was already there! It turns out the hospital uses a service called &lt;em&gt;HealthCare21&lt;/em&gt; for equipment maintainence. This service requires a clear identifieing sticker on every piece of equipment they service: if the sticker is missing, they won’t maintain the equipment. This is perfect opportunity to use as a primary identifier for our system, since this is a Stable, Unique and always present ID. This also perfectly reflected on the approach on change: See &lt;a href=&quot;https://oechsner.dev/blog/healthcare-innovation-challenge#change-management-touch-as-little-as-possible&quot;&gt;Change management&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The moment a therapist hands a wheelchair to a patient, they already know everything needed for documentation: item id (it’s on the item), which patient, which bed, roughly how long. What they don’t have is a free hand.&lt;/p&gt; &lt;p&gt;So our solution was a central database replacing the spreadsheet, with &lt;strong&gt;voice input from the handset staff already carry&lt;/strong&gt;. At the bedside you press one button and say something like:&lt;/p&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;“Book wheelchair four eight two nine, ten fifty-three to bed 4B twelve for three weeks.”&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;An LLM turns that into a structured record, the screen shows what it understood, and one tap confirms it. If the item is already out, confirming puts the patient on the waitlist instead, and the waitlist stops being a tab nobody opens.&lt;/p&gt; &lt;p&gt;But of course we know that in a chaotic hospital environment, input would rather look like this:&lt;/p&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;“Uh, the wheelchair, four eight two nine one oh five three, no wait, ending three five, to bed twelve, actually, sorry, fourteen, for like a week. Oh and the cushion next to bed seven is broken by the way.”&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;This is why we also added a custom llm prompt that accounts for exactly that: Try to understand what was meant (not said) and always let the last value win&lt;/p&gt; &lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hic/dataflow.png&quot; alt=&quot;Data flow from voice to a verified record: speech recorded on the mobile device goes to the TUH server (local or AWS) for transcription, patient ID encryption and the custom prompt, then to an LLM (any cloud model through OpenRouter, or local inference with Ollama / OpenLLM), and the autofilled form comes back to the mobile device for modification and submission, with a human in the loop.&quot; style=&quot;max-width: 100%; height: auto; border-radius: 6px&quot;&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;The data architecture we chose. The patient id encryption is necessary to ensure pseudonymisation&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;None of this is clever on its own. Together, it’s the difference between a demo that works when you speak slowly and clearly, and one that works when someone talks the way people actually talk.&lt;/p&gt; &lt;h2 id=&quot;change-management-touch-as-little-as-possible&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Change management: touch as little as possible&lt;/h2&gt; &lt;p&gt;The first thing we emphasised in the pitch was that we were trying to change &lt;strong&gt;as little of the existing workflow as possible&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;The tracker’s columns stay the same. The asset numbers and HC21 stickers stay the same. The device stays the same. The only thing that changes is &lt;em&gt;when&lt;/em&gt; and &lt;em&gt;how&lt;/em&gt; the record gets updated: at the bedside, by voice, in the ten seconds after the handover, instead of hours later at a desk.&lt;/p&gt; &lt;p&gt;Why did we do this? A hospital is not a startup. Every new process needs training across shifts, and every new app competes for staff attention. And especially non-technical medical experts surely struggle to adapt to drastic change. A system that needs everyone to change their habits will fail just like the spreadsheet it depends on compliance.&lt;/p&gt; &lt;h2 id=&quot;financial-viability-someone-has-to-pay-for-this&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Financial viability: someone has to pay for this&lt;/h2&gt; &lt;p&gt;The second thing was money. Innovation is exciting, but the project still has to be fundable, and €4,600 a year in lost equipment does not pay for a building-wide tracking network.&lt;/p&gt; &lt;p&gt;Our approach needs no new hardware. Staff already have the handsets, and the equipment already has its stickers. What’s left is a database, a small app, and speech parsing per log entry, which costs very little at the volume of one OT department. Then there is the time that comes back: fewer monthly stock-check walks, fewer hunts for “that cushion that should be on 4B”. That’s an argument a hospital can take to whoever signs off the budget. &lt;em&gt;Installing RTLS everywhere&lt;/em&gt; is not.&lt;/p&gt; &lt;p&gt;It also scales perfectly well. Other departments that lend out shared equipment have the same problem, and none of them would need anything new installed either. We are talking about low initial investment and even lower scaling costs&lt;/p&gt; &lt;h2 id=&quot;learnings&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Learnings&lt;/h2&gt; &lt;ul&gt;&lt;li&gt;&lt;strong&gt;The constraints are the problem.&lt;/strong&gt; Our most exciting ideas were the first ones that were implicitly rejected. The ten hours of working time were only useful because we took our time to develop an idea that conforms to the constraints.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;LLMs are good at understanding stuff.&lt;/strong&gt; Extracting JSON is not impressive by itself. Handling a messy, self-correcting sentence and showing what was understood before saving anything is what makes it usable.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;The pitch is half the project.&lt;/strong&gt; Leading with restating the problem and ending with finance, rather than with the architecture, is what made the idea land.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Huge thanks to Graciela and Marvin, to TUH, to Amazon, and to the TU Dublin School of Enterprise Computing &amp;amp; Digital Transformation for organising it.&lt;/p&gt;
&lt;hr style=&quot;border: 0; border-top: 1px solid rgba(128, 128, 128, 0.3); margin: 2.5em 0 1em&quot; /&gt;
&lt;p style=&quot;font-size: 0.9em; color: #80818a&quot;&gt;Originally published on &lt;a href=&quot;https://oechsner.dev/blog/healthcare-innovation-challenge&quot;&gt;oechsner.dev&lt;/a&gt;. Read it there →&lt;/p&gt;</content>
    <category term="hackathon" />
    <category term="project report" />
  </entry>
  <entry>
    <title>This LLM has a Context window of 1</title>
    <link rel="alternate" type="text/html" href="https://oechsner.dev/blog/this-llm-has-a-context-of-1" />
    <id>https://oechsner.dev/blog/this-llm-has-a-context-of-1</id>
    <published>2026-09-21T00:00:00Z</published>
    <updated>2026-09-21T00:00:00Z</updated>
    <summary type="text">Exploring the basics of LLMs by training a N-Gram model on my lecture notes</summary>
    <content type="html">&lt;p style=&quot;margin-bottom: 0.25em; font-size: 0.85em; color: #80818a&quot;&gt;21 September 2026 · 9 min read · 🤓🤓🤓 3/3 nerds · ✒️ 100% human-written&lt;/p&gt;
&lt;p style=&quot;margin-top: 0; font-size: 0.8em; letter-spacing: 0.08em; text-transform: uppercase; color: #a87a3c&quot;&gt;#project report&lt;/p&gt;
&lt;p style=&quot;font-size: 1.1em; line-height: 1.7; padding-left: 1em; border-left: 3px solid #e0a85c&quot;&gt;Exploring the basics of LLMs by training a N-Gram model on my lecture notes&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://oechsner.dev/img/markov/cover.svg&quot; alt=&quot;A generated sentence where only the last word is lit, above a word graph whose weighted arrows give the probabilities of the next word&quot; style=&quot;width: 100%; height: auto; border-radius: 6px&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;introduction&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Introduction&lt;/h2&gt; &lt;p&gt;An &lt;em&gt;n-gram model&lt;/em&gt; analyzes training data to determine how frequently specific word sequences occur. For example, given the phrase “my house is,” the model examines all words that follow “my” in the dataset. If “house” is the most common continuation, the model predicts “house.”&lt;/p&gt; &lt;p&gt;In this Post, I will cover the mathematical basics of modern LMs and train my own N-Gram Model based on my lecture notes. I’ll take a mathematical dive into different token selection functions and prove why the maximum likelihood assumption leads to periodic repetition.&lt;/p&gt; &lt;h2 id=&quot;mathematical-basics&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Mathematical Basics&lt;/h2&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;This section is largely based on the book Speech and Language Processing by Jurafsky &amp;amp; Martin  (&lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-NLP2026&quot; title=&quot;Jurafsky, D., &amp;amp; Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, with Language Models (3rd ed., I.3). https://web.stanford.edu/~jurafsky/slp3/&quot; style=&quot;text-decoration: underline dotted&quot;&gt;2026, I.3&lt;/a&gt;)&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Most language models use context consisting of &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;n-1&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; tokens &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;mo&gt;⋯&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;C:= w_1w_2\cdots w_{n-1}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; to predict the &lt;em&gt;nth&lt;/em&gt; token &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_n&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; and describe the probability for every
next token with &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P(w_n|w_{1:n-1}) = P(w_n|C)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. N-Gram models limit this context
by assuming &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;≈&lt;/mo&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo&gt;⋯&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\approx P(w_n| w_{n-N+1} \cdots w_{n-1})&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. In the extreme case of a &lt;em&gt;bigram model&lt;/em&gt; (&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;) this assumption simplifies to &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;≈&lt;/mo&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P(w_n|C)\approx P(w_n|w_{n-1})&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, we call
this the &lt;em&gt;markov assumption&lt;/em&gt;. The probability of outputting a sentence &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;s&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;mo&gt;…&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;s=w_{1}w_{2}\dots w_{m}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; with token-length &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;m&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; based on context token &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;c&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;s&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mo&gt;∏&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;s&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P(s)=\prod_{w\in s}P(w)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. I define &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;S_{N}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; as the set of all sentences with length N. And &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;s&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;s_{w_n}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; We define &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;T(a | B)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; as the number of occurrences of &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;a&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; with the sentence &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;B&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; preceeding. The next token selection is decided by &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi&gt;l&lt;/mi&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo&gt;⟶&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Sel: C \longrightarrow w_n&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt; &lt;p&gt;In our case, we define &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;⋯&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P(w_{n}|C)=\frac{ T(w_{n}| w_{n-N+1 \cdots w_{n-1}})}{ T(w_{n})}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, simplifying to &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P(w_{n}|C) = \frac{T(w_n|w_{n-1})}{T(w_n)}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; with bigrams.&lt;/p&gt; &lt;h3 id=&quot;greedy-decoding-always-ends-in-a-loop&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Greedy decoding always ends in a loop&lt;/h3&gt; &lt;p&gt;Let’s take the &lt;em&gt;maximum likelihood assumption&lt;/em&gt; of picking with &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi&gt;l&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;max&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;/mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Sel(C) := \max_{w_{i}} (P(w_{i}|C))&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt; &lt;p&gt;Before we improve &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi&gt;l&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Sel&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, let’s prove &lt;em&gt;why&lt;/em&gt; choosing greedily will fail.&lt;/p&gt; &lt;h4&gt;Proof&lt;/h4&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;Adapted from &lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-knuth1997&quot; title=&quot;Knuth, D. E. (1997). The Art of Computer Programming, Volume 2: Seminumerical Algorithms (3rd ed.). Addison-Wesley.&quot; style=&quot;text-decoration: underline dotted&quot;&gt;Knuth (1997)&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;We define a greedy &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi&gt;l&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Sel&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; as:&lt;/p&gt;  &lt;figure style=&quot;margin: 1.75em 0; --latex-scale: 1&quot;&gt; &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mo&gt;⟶&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mspace width=&quot;1em&quot;&gt;&lt;/mspace&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;munder&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;arg max&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;msup&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo mathvariant=&quot;normal&quot; lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;′&lt;/mo&gt;&lt;/msup&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;/munder&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo mathvariant=&quot;normal&quot; lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;′&lt;/mo&gt;&lt;/msup&gt;&lt;mo&gt;∣&lt;/mo&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;f: V \longrightarrow V, \quad f(w) := \operatorname*{arg\,max}_{w' \in V} P(w' \mid w),&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;&lt;span&gt;Token selection function under the maximum likelihood assumption&lt;/span&gt;&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;Given vocabulary &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;V&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; with &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;mo&gt;&amp;lt;&lt;/mo&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∞&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;|V| = v &amp;lt; \infty&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;:
Generation from a seed &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_{0}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is then nothing but iterating: &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;/msup&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;.&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_{t} = f(w_{t-1}) = f^{t}(w_{0}).&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;&lt;strong&gt;Theorem.&lt;/strong&gt; For every &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;/msub&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_{0} \in V&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; the greedy sequence &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;mo&gt;≥&lt;/mo&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;(w_{t})_{t \ge 0}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is &lt;em&gt;eventually periodic&lt;/em&gt;: there are &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi mathvariant=&quot;double-struck&quot;&gt;R&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i,j \in \mathbb{R}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; where &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;&amp;lt;&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i &amp;lt; j \le v&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; such that &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_{i} = w_{j}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, and the sequence repeats with an arbitrary period &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;p&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;: &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msup&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msup&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;f^{p+1}(w_{i})=w_j&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;strong&gt;Proof.&lt;/strong&gt; Look at the first &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;v+1&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; tokens &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;/msub&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/msub&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mo&gt;…&lt;/mo&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_{0}, w_{1}, \dots, w_{v}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. They are &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;v+1&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; elements drawn from a set of only &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;v&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; tokens, so by the pigeonhole principle two of them must
coincide: &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_{i} = w_{j}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; for some &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;&amp;lt;&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mo&gt;≤&lt;/mo&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;0 \le i &amp;lt; j \le v&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. Because &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;f&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is a &lt;em&gt;function&lt;/em&gt;:&lt;/p&gt;  &lt;figure style=&quot;margin: 1.75em 0; --latex-scale: 1&quot;&gt; &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∀&lt;/mi&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;mo&gt;≥&lt;/mo&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mspace width=&quot;1em&quot;&gt;&lt;/mspace&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/msup&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/msup&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\forall k \ge 0:\quad w_{i+k} = f^{k}(w_{i}) = f^{k}(w_{j}) = w_{j+k}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/figure&gt; &lt;p&gt;So the sequence is periodic with period &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;p = j - i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; from index &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; on. &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;■&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\blacksquare&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;h4&gt;What do we learn from that?&lt;/h4&gt; &lt;ol&gt;&lt;li&gt;&lt;strong&gt;Repetition is structural, not a bug of the dataset.&lt;/strong&gt; Any finitely large dataset doesn’t fix the underlying problem.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;The model can produce at most &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;|V|&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; distinct texts&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Termination is luck.&lt;/strong&gt; We can’t guarantee the loop contains a EOS.&lt;/li&gt;&lt;/ol&gt; &lt;h3 id=&quot;markov&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Markov&lt;/h3&gt; &lt;p&gt;To prevent this, we sample from &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mo&gt;⋅&lt;/mo&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P(\cdot|C)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. Thus, &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;f&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;f&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is no longer a &lt;em&gt;function&lt;/em&gt;, but a &lt;em&gt;stochastic kernel&lt;/em&gt; of a markov chain. This leads to the key insight that a &lt;em&gt;bigram model&lt;/em&gt; with this &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi&gt;l&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Sel&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is equivalent to a markov chain, where nodes are tokens and edge weights are &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P(w_n|w_{n-1})&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt; &lt;p&gt;We can also model higher-order N-Grams as markov chains, where the number of nodes increases exponentially with &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msup&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;/msup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;V^N&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt; &lt;h3 id=&quot;the-better-selection-funct&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;The better selection Funct&lt;/h3&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;This section is based on &lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-NLP2026&quot; title=&quot;Jurafsky, D., &amp;amp; Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, with Language Models (3rd ed., I.3). https://web.stanford.edu/~jurafsky/slp3/&quot; style=&quot;text-decoration: underline dotted&quot;&gt;Jurafsky &amp;amp; Martin (2026)&lt;/a&gt; too&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;The maximum likelihood assumption fails in the real world. No matter how big the training set, some sentences will never be able to be generated. That leaves the model locked on a subset &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;⊂&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\subset&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; of real language.&lt;/p&gt; &lt;p&gt;One option is Laplace Smoothing:&lt;/p&gt;  &lt;figure style=&quot;margin: 1.75em 0; --latex-scale: 1&quot;&gt; &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mtext&gt;Laplace&lt;/mtext&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P_\text{Laplace}(w_{i})=\frac{ T(w_{i} + 1}{ T(w_{n})}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;&lt;span&gt;&lt;strong&gt;Laplace smoothing&lt;/strong&gt;: Just adding 1 for every token&lt;/span&gt;&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;This leads to this Prediction function in bigram models:&lt;/p&gt;  &lt;figure style=&quot;margin: 1.75em 0; --latex-scale: 1&quot;&gt; &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mtext&gt;Laplace&lt;/mtext&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;munder&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;/munder&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mo&gt;&lt;mover&gt;&lt;mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;/mo&gt;&lt;mrow&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;/mover&gt;&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P_\text{Laplace} (w_{n}|w_{n-1})=\frac{T(w_{n-1}w_n)+1}{\sum\limits_{w}(T(w_{n-1}w)+1)}\overset{\sum1=V}{=}\frac{T(w_{n-1}w_{n})+1}{T(w_{n-1})+V}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;&lt;span&gt;&lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-NLP2026&quot; title=&quot;Jurafsky, D., &amp;amp; Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, with Language Models (3rd ed., I.3). https://web.stanford.edu/~jurafsky/slp3/&quot; style=&quot;text-decoration: underline dotted&quot;&gt;Jurafsky &amp;amp; Martin (2026)&lt;/a&gt;, eq. 3.26&lt;/span&gt;&lt;/figcaption&gt;&lt;/figure&gt; &lt;h4&gt;Laplace charges a proportional tax on evidence&lt;/h4&gt; &lt;p&gt;&lt;em&gt;What count would
have produced this probability without smoothing?&lt;/em&gt; Solving &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mtext&gt;Laplace&lt;/mtext&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;msup&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;∗&lt;/mo&gt;&lt;/msup&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P_\text{Laplace}=\frac{T^{*}}{T(w_{n-1})}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; for &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msup&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;∗&lt;/mo&gt;&lt;/msup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;T^{*}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; gives the &lt;strong&gt;effective count&lt;/strong&gt;&lt;/p&gt;  &lt;figure style=&quot;margin: 1.75em 0; --latex-scale: 1&quot;&gt; &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msup&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;∗&lt;/mo&gt;&lt;/msup&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo fence=&quot;true&quot; stretchy=&quot;true&quot; minsize=&quot;1.2em&quot; maxsize=&quot;1.2em&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo fence=&quot;true&quot; stretchy=&quot;true&quot; minsize=&quot;1.2em&quot; maxsize=&quot;1.2em&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;⋅&lt;/mo&gt;&lt;munder&gt;&lt;munder&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mo stretchy=&quot;true&quot;&gt;⏟&lt;/mo&gt;&lt;/munder&gt;&lt;mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mi&gt;d&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/munder&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;T^{*}(w_{n-1}w_{n}) = \bigl(T(w_{n-1}w_{n})+1\bigr)\cdot\underbrace{\frac{T(w_{n-1})}{T(w_{n-1})+V}}_{=:d(w_{n-1})}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;&lt;span&gt;The discount factor &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;d&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;d&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; does not depend on the bigram at all, only on the context. So Laplace is a &lt;em&gt;proportional&lt;/em&gt; tax: every continuation of &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_{n-1}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is scaled by the same &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;d&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;d&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, no matter whether we
saw it 500 times or never.&lt;/span&gt;&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;That factor is brutal at the vocabulary sizes we are dealing with. My vault has &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mo&gt;≈&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mo&gt;⋅&lt;/mo&gt;&lt;msup&gt;&lt;mn&gt;10&lt;/mn&gt;&lt;mn&gt;4&lt;/mn&gt;&lt;/msup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;V\approx 2\cdot10^{4}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; types, and a decently frequent context like &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;Gradient&lt;/code&gt; might have &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;200&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;T(w_{n-1})=200&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. Then &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;d&lt;/mi&gt;&lt;mo&gt;≈&lt;/mo&gt;&lt;mfrac&gt;&lt;mn&gt;200&lt;/mn&gt;&lt;mn&gt;20200&lt;/mn&gt;&lt;/mfrac&gt;&lt;mo&gt;≈&lt;/mo&gt;&lt;mn&gt;0.0099&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;d \approx \frac{200}{20200}\approx 0.0099&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, and the bigram &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;Gradient Descent&lt;/code&gt;, observed 50 times, ends up with an effective count of roughly &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;0.5&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;0.5&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. We spent a whole corpus collecting that evidence and then threw away &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;99&lt;/mn&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;%&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;99\%&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; of it to fund &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;V&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; continuations that never happened.&lt;/p&gt; &lt;h4&gt;Lets add more!&lt;/h4&gt; &lt;p&gt;Add-&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;k&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; smoothing, &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mrow&gt;&lt;mtext&gt;add-&lt;/mtext&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P_{\text{add-}k}(w_{n}|w_{n-1})=\frac{T(w_{n-1}w_{n})+k}{T(w_{n-1})+kV}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, only
changes the tax &lt;em&gt;rate&lt;/em&gt;. The structural problem survives: the amount of mass taken from observed
events scales with &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;V&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; and with nothing about the context except its total count. A single &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;k&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; tuned
on held-out data is always a compromise between contexts we know a lot about and contexts we saw
three times.&lt;/p&gt; &lt;h4&gt;Discount, don’t rescale&lt;/h4&gt; &lt;p&gt;Both scale &lt;em&gt;multiplicatively&lt;/em&gt;. But held-out counts show the MLE error is &lt;strong&gt;additive&lt;/strong&gt;: bigrams seen &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;r&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; times recur about &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;0.75&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;r-0.75&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; times (&lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-NLP2026&quot; title=&quot;Jurafsky, D., &amp;amp; Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, with Language Models (3rd ed., I.3). https://web.stanford.edu/~jurafsky/slp3/&quot; style=&quot;text-decoration: underline dotted&quot;&gt;2026&lt;/a&gt;). So subtract a fixed &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;δ&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\delta&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; instead. Normalization then forces the freed mass to be&lt;/p&gt;  &lt;figure style=&quot;margin: 1.75em 0; --latex-scale: 1&quot;&gt; &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;λ&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;δ&lt;/mi&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;msub&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo&gt;∙&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mspace width=&quot;2em&quot;&gt;&lt;/mspace&gt;&lt;msub&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo&gt;∙&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo fence=&quot;true&quot; stretchy=&quot;true&quot; minsize=&quot;1.2em&quot; maxsize=&quot;1.2em&quot;&gt;∣&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;{&lt;/mo&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;&amp;gt;&lt;/mo&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;}&lt;/mo&gt;&lt;mo fence=&quot;true&quot; stretchy=&quot;true&quot; minsize=&quot;1.2em&quot; maxsize=&quot;1.2em&quot;&gt;∣&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\lambda_{w_{n-1}}=\frac{\delta\,N_{1+}(w_{n-1}\bullet)}{T(w_{n-1})},\qquad N_{1+}(w_{n-1}\bullet)=\bigl|\{w: T(w_{n-1}w)&amp;gt;0\}\bigr|&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/figure&gt; &lt;p&gt;so diverse contexts leak more. It is only consulted in &lt;em&gt;unseen&lt;/em&gt; contexts, so count how many distinct contexts &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; appears in, not how often. &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;Descent&lt;/code&gt; is frequent, yet almost always follows &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;Gradient&lt;/code&gt;.&lt;/p&gt; &lt;h3 id=&quot;knesner-ney&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Knesner-Ney&lt;/h3&gt;  &lt;figure style=&quot;margin: 1.75em 0; --latex-scale: 1&quot;&gt; &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mtext&gt;KneserNey&lt;/mtext&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;munder&gt;&lt;munder&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;max&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mi&gt;δ&lt;/mi&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;munder&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;/munder&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mo stretchy=&quot;true&quot;&gt;⏟&lt;/mo&gt;&lt;/munder&gt;&lt;mrow&gt;&lt;mtext&gt;measured&amp;nbsp;evidence,&amp;nbsp;deficient&amp;nbsp;by&amp;nbsp;&lt;/mtext&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;λ&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;/munder&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;λ&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P_{\text{KneserNey}}(w_{i}|w_{i-1})=\underbrace{\frac{\max (T(w_{i-1}w_{i})-\delta,0)}{\sum_{w}T(w_{i-1}w)}}_{\text{measured evidence, deficient by}\ 1-\lambda_{w_{i-1}}} +\lambda_{w_{i-1}}P_{KN}(w_{i})&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;&lt;span&gt;Bigram KneserNey-Smoothing. Adapted from &lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-NEY1994&quot; title=&quot;Ney, H., Essen, U., &amp;amp; Kneser, R. (1994). On structuring probabilistic dependences in stochastic language modelling. Computer Speech &amp;amp; Language, 8(1), 1–38. https://doi.org/https://doi.org/10.1006/csla.1994.1001&quot; style=&quot;text-decoration: underline dotted&quot;&gt;Ney et al. (1994)&lt;/a&gt;&lt;/span&gt;&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;We arrive at Knesner-Ney.
The &lt;strong&gt;right term&lt;/strong&gt; spends exactly the deficit the &lt;strong&gt;left one creates&lt;/strong&gt;. &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;λ&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\lambda&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is normalized, so &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P_{KN}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is freely chosen.&lt;/p&gt; &lt;h3 id=&quot;perplexity&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Perplexity&lt;/h3&gt; &lt;p&gt;For LM evaluation, we use &lt;strong&gt;Perplexity&lt;/strong&gt;. It is the exponentiated average negative log-likelihood the model assigns to held-out text:&lt;/p&gt;  &lt;figure style=&quot;margin: 1.75em 0; --latex-scale: 1&quot;&gt; &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mtext&gt;PP&lt;/mtext&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mi&gt;M&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;exp&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;mrow&gt;&lt;mo fence=&quot;true&quot;&gt;(&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mfrac&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mi&gt;M&lt;/mi&gt;&lt;/mfrac&gt;&lt;munderover&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mi&gt;M&lt;/mi&gt;&lt;/munderover&gt;&lt;mi&gt;log&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;∣&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo fence=&quot;true&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\text{PP}(w_{1:M}) = \exp\left(-\frac{1}{M}\sum_{i=1}^{M}\log P(w_{i}\mid w_{i-N+1:i-1})\right)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;&lt;span&gt;&lt;strong&gt;Perplexity&lt;/strong&gt;: the model’s average surprise per token&lt;/span&gt;&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;Read it as an effective branching factor: &lt;em&gt;how many words is the model effectively choosing between at each step?&lt;/em&gt; A uniform model over my vocabulary has a perplexity of exactly 15,622, because it is choosing uniformly between 15,622 options. Lower is better (&lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-NLP2026&quot; title=&quot;Jurafsky, D., &amp;amp; Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, with Language Models (3rd ed., I.3). https://web.stanford.edu/~jurafsky/slp3/&quot; style=&quot;text-decoration: underline dotted&quot;&gt;Jurafsky &amp;amp; Martin, 2026&lt;/a&gt;).&lt;/p&gt; &lt;h2 id=&quot;building-an-n-gram-model&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Building an N-Gram Model&lt;/h2&gt; &lt;p&gt;I was able to extract 585 .md files, skipping the following:&lt;/p&gt; &lt;pre style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; line-height: 1.6; padding: 1em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 6px; overflow-x: auto&quot;&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace&quot;&gt;forbidden &lt;span&gt;=&lt;/span&gt; &lt;span&gt;[&lt;/span&gt;
    &lt;span&gt;r&quot;*/.claude/*&quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;
    &lt;span&gt;r&quot;*/.obsidian/*&quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;
    &lt;span&gt;r&quot;*.excalidraw.md&quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;
    &lt;span&gt;r&quot;*/node_modules/*&quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;
&lt;span&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;&lt;strong&gt;Preprocessing:&lt;/strong&gt; Markdown is not prose, since markup is far more repetitive than text, so a model trained on the raw vault would spend most of its probability mass learning that &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;[&lt;/code&gt; follows &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;]&lt;/code&gt;. Twenty-one ordered regex substitutions normalise this, anything carrying display text is reduced to it (aliased wikilinks, markdown links, callout headers), anything else is deleted rather than replaced (frontmatter, code, math, embeds, URLs, HTML, hashtags, rules). Pure markers (headings, bullets, blockquotes, checkboxes, emphasis) are stripped. Because a lecture note is a stack of grammatically unrelated bullet fragments, each &lt;strong&gt;line&lt;/strong&gt; becomes its own training sequence. All exact duplicate notes are dropped by content hash, since the same content being in training and validation set would defeat the point.&lt;/p&gt; &lt;div&gt;&lt;table style=&quot;width: 100%; border-collapse: collapse; font-size: 0.95em&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;markdown files&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;588&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;after deduplication&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;533&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;non-empty documents&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;388&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;training tokens&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;277,208&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;held-out tokens&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;11,023&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;types → vocabulary&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;23,988 → 15,622 (96.98% coverage)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;277k tokens is &lt;em&gt;very small&lt;/em&gt;. For scale, GPT-3 was trained on roughly 300 billion.&lt;/p&gt;&lt;/blockquote&gt; &lt;h3 id=&quot;how-much-context-is-worth-paying-for&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;How much context is worth paying for?&lt;/h3&gt; &lt;p&gt;So I trained one model per order, from &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=0&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; (uniform) up to &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;19&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=19&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, and measured each on the same held-out documents:&lt;/p&gt; &lt;div&gt;&lt;table style=&quot;width: 100%; border-collapse: collapse; font-size: 0.95em&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;N&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;0&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;1&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;2&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;3&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;4&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;5&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;6&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;8&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;10&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;12&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;15&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;19&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;Perplexity&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;15622&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;801&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;137.8&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;42.6&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;28.8&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;25.5&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;24.0&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;22.8&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;22.5&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;22.5&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;23.0&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;23.9&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;p&gt;Improvement seems to be lorarithmic. The “context window of 1” divides perplexity by almost six, and the trigram cuts it by another two thirds. After &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;4&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=4&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; perplexity doesn’t seem to improve.&lt;/p&gt; &lt;p&gt;Later &lt;strong&gt;it surprisingly goes back up&lt;/strong&gt;. Past &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;12&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=12&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, more context makes the model measurably worse. This seemingly is because it has fewer training data for longer lines. At &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, 15% of held-out tokens arrive with a context the model has never seen; by &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;12&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=12&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; it is 35%.&lt;/p&gt; &lt;h3 id=&quot;what-it-actually-writes&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;What it actually writes&lt;/h3&gt; &lt;p&gt;Perplexity doesn’t paint the whole Picture. So a test run: same seed, same prompt, one model per order:&lt;/p&gt; &lt;pre style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; line-height: 1.6; padding: 1em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 6px; overflow-x: auto&quot;&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace&quot;&gt;--- N = 1 ---
the main
 of
: ,
:
.
 . 1
 the 3 the , b
die

--- N = 2 ---
the main process
:
for all
x lecture 03 .
removed and the
in order to a basis of b ,
fixed a 4 , then there is true .

--- N = 3 ---
the main process before processes are launched when using a kernel , the
removed property from the other files : , email 42 , concat name , :
the trainer no longer randomly selects a seed no longer returns a triplet 18390
: there is a subset of examples for pytorch 2.4 .
if is even .

--- N = 5 ---
the main academic risks are : unclosed gaps in securityprivacy weeks 14 15 , the rsa calculation error , and the missing .
you can decompress drawing data with the command palette : decompress current excalidraw file .

--- N = 10 ---
the main academic risks are : unclosed gaps in securityprivacy weeks 14 15 , the rsa calculation error , and the missing buffer-overflow payload practice .
a graph is planar if it can be drawn on a paper such that no edges cross each other&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;Every line break is the model emitting &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;&amp;lt;/s&amp;gt;&lt;/code&gt; and starting a fresh sequence, so the number of lines is itself a signal: the higher the order, the longer it keeps going before it decides EOS.&lt;/p&gt; &lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=1&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is function words and punctuation — the model has no context, so it produces the most common tokens in the language, which are the ones carrying no meaning. &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is the interesting one: locally grammatical, globally nonsense. &lt;em&gt;“the main process before processes are launched when using a kernel”&lt;/em&gt; actually quite good, you’d have to secondguess to figure out it is nonsense.&lt;/p&gt; &lt;p&gt;And then &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;5&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=5&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; and &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;10&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=10&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; stop writing and start &lt;strong&gt;quoting&lt;/strong&gt;. &lt;em&gt;“A graph is planar if it can be drawn on a paper such that no edges cross each other”&lt;/em&gt; is a line from my notes on discrete modelling, reproduced word for word.&lt;/p&gt; &lt;h3 id=&quot;the-minimum-is-a-lie&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;The minimum is a lie&lt;/h3&gt; &lt;p&gt;That is just an impression though, so let’s measure it. For each order I sampled a few hundred lines, cut them into 8-grams, and checked how many of those 8-grams appear word for word in the training split and, separately, how many of the generated lines are entire lines of the vault reproduced exactly:&lt;/p&gt; &lt;div&gt;&lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/markov/Citations.png&quot; alt=&quot;A chart visualising Citations for different N&quot; style=&quot;max-width: 100%; height: auto; box-sizing: border-box; padding: 1em; background: #f2f2ef; border-radius: 6px&quot;&gt;&lt;/figure&gt; &lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/markov/Perplexity.png&quot; alt=&quot;A chart visualising Perplexity for different N&quot; style=&quot;max-width: 100%; height: auto; box-sizing: border-box; padding: 1em; background: #f2f2ef; border-radius: 6px&quot;&gt;&lt;/figure&gt;&lt;/div&gt; &lt;p&gt;The rows move together. Every point of perplexity I bought past &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; was paid for in originality: at the perplexity minimum, &lt;strong&gt;two out of three 8-word spans the model produces are copied straight out of my notes, and half of the lines it writes are completely out of my notes.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;At &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;10&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=10&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, 62% of the contexts the model knows occur exactly &lt;em&gt;once&lt;/em&gt; in the entire corpus. The model isn’t choosing. It is looking up the rest of the line.&lt;/p&gt; &lt;p&gt;Which brings us back to its own proof. Greedy decoding fails because it is a function on a finite set, so it must eventually cycle. Sampling fixes that, but at high &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; it stops repeating &lt;em&gt;itself&lt;/em&gt; and starts repeating &lt;em&gt;me&lt;/em&gt;. Both are a model with nothing of its own to say, and only the first one is visible in the loss.&lt;/p&gt; &lt;p&gt;If you want the most original model, I suggest &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;3&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;N=3&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; or &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;4&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;4&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;: still recombining, just before the counts get sparse enough to overfit. &lt;strong&gt;→ The best-scoring model and the best model are not the same.&lt;/strong&gt;&lt;/p&gt; &lt;h3 id=&quot;one-model-two-languages&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;One model, two languages&lt;/h3&gt; &lt;p&gt;My notes are bilingual, and both go into one model with one vocabulary. So it code-switches mid-line, as I do in my notes:&lt;/p&gt; &lt;pre style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; line-height: 1.6; padding: 1em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 6px; overflow-x: auto&quot;&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace&quot;&gt;fixed an issue to avoid validation loop : : set aller möglichen hypothesen nach der hypothesis
der lokale daemon muss als eigenständige for any&lt;/code&gt;&lt;/pre&gt; &lt;h2 id=&quot;improvement-opportunities&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Improvement opportunities&lt;/h2&gt; &lt;ul&gt;&lt;li&gt;&lt;strong&gt;Estimate the discount instead of guessing it.&lt;/strong&gt; &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;δ&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\delta&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is hard-coded to 0.75 throughout. Let’s change that and use a separate delta for N=1,2,3+: &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;δ&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;msub&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/msub&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/msub&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;msub&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\delta = \frac{n_1}{n_1 + 2n_2}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; (&lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-NLP2026&quot; title=&quot;Jurafsky, D., &amp;amp; Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, with Language Models (3rd ed., I.3). https://web.stanford.edu/~jurafsky/slp3/&quot; style=&quot;text-decoration: underline dotted&quot;&gt;2026&lt;/a&gt;).&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Top-k sampling&lt;/strong&gt;. We could store the k most next &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;w_i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; and &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;P(w_i| C)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, normalized such that &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msubsup&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mi&gt;k&lt;/mi&gt;&lt;/msubsup&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;C&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\sum\limits_{i=1}^{k}P(w_{i}|C)=1&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; in a key-value store and run the Markov kernel only on those fixed number of tokens. This would mean Inference goes from &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;Θ&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;mo&gt;⋅&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\Theta(N\cdot V)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; per token to &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;Θ&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\Theta(1)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;, independent of vocabulary and order. Note that this isn’t a lossless operation (&lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-fan2018&quot; title=&quot;Fan, A., Lewis, M., &amp;amp; Dauphin, Y. (2018). Hierarchical Neural Story Generation. https://arxiv.org/abs/1805.04833&quot; style=&quot;text-decoration: underline dotted&quot;&gt;Fan et al., 2018&lt;/a&gt;).&lt;/li&gt;&lt;/ul&gt; &lt;h2 id=&quot;limitation&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Limitation&lt;/h2&gt; &lt;p&gt;There is a ceiling, and it is not an engineering problem. An n-gram model stores a table indexed by context, so its parameter count grows as &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msup&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mi&gt;N&lt;/mi&gt;&lt;/msup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;V^{N}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;. With my modest 15,622-token vocabulary, a 10-gram table has &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msup&gt;&lt;mn&gt;15622&lt;/mn&gt;&lt;mn&gt;10&lt;/mn&gt;&lt;/msup&gt;&lt;mo&gt;≈&lt;/mo&gt;&lt;msup&gt;&lt;mn&gt;10&lt;/mn&gt;&lt;mn&gt;42&lt;/mn&gt;&lt;/msup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;15622^{10} \approx 10^{42}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; cells. I observed 277,208 of them. Every additional token of context multiplies the space by 15,622 and adds zero new evidence.&lt;/p&gt; &lt;p&gt;That is the wall the whole field hit, and the reason the next idea had to be structurally different rather than merely bigger. This ceiling was already visible in the smoothing literature by 2001 (&lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1#ref-goodman2001&quot; title=&quot;Goodman, J. T. (2001). A bit of progress in language modeling. Computer Speech &amp;amp; Language, 15(4), 403–434. https://doi.org/10.1006/csla.2001.0174&quot; style=&quot;text-decoration: underline dotted&quot;&gt;Goodman, 2001&lt;/a&gt;), and still standing in 2007 when Google trained 5-grams on two trillion tokens of web text and watched the gains go logarithmic.&lt;/p&gt; &lt;h2 id=&quot;conclusion&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Conclusion&lt;/h2&gt; &lt;p&gt;&lt;em&gt;So: what does a context window of 1 get you?&lt;/em&gt; &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;→&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\rightarrow&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; A perplexity of 137.8, sentences that are grammatical for about four words at a time, and a model small enough an Arduino would be able to run it easily.&lt;/p&gt; &lt;p&gt;It doesn’t get you anywhere near the level of competence modern LLMs have and finds no relation between &lt;em&gt;similar&lt;/em&gt; tokens. You can’t &lt;em&gt;embed&lt;/em&gt; tokens or find any semantically valuable information in the models.&lt;/p&gt; &lt;h2 id=&quot;references&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;References&lt;/h2&gt; &lt;ol style=&quot;list-style: none; padding-left: 0; font-size: 0.875em; line-height: 1.6&quot;&gt;&lt;li id=&quot;ref-fan2018&quot; style=&quot;padding-left: 1.5em; text-indent: -1.5em&quot;&gt;Fan, A., Lewis, M., &amp;amp; Dauphin, Y. (2018). &lt;i&gt;Hierarchical Neural Story Generation&lt;/i&gt;. &lt;a href=&quot;https://arxiv.org/abs/1805.04833&quot;&gt;https://arxiv.org/abs/1805.04833&lt;/a&gt;&lt;/li&gt; &lt;li id=&quot;ref-goodman2001&quot; style=&quot;padding-left: 1.5em; text-indent: -1.5em&quot;&gt;Goodman, J. T. (2001). A bit of progress in language modeling. &lt;i&gt;Computer Speech &amp;amp; Language&lt;/i&gt;, &lt;i&gt;15&lt;/i&gt;(4), 403–434. &lt;a href=&quot;https://doi.org/10.1006/csla.2001.0174&quot;&gt;https://doi.org/10.1006/csla.2001.0174&lt;/a&gt;&lt;/li&gt; &lt;li id=&quot;ref-NLP2026&quot; style=&quot;padding-left: 1.5em; text-indent: -1.5em&quot;&gt;Jurafsky, D., &amp;amp; Martin, J. H. (2026). &lt;i&gt;Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition, with Language Models&lt;/i&gt; (3rd ed., I.3). &lt;a href=&quot;https://web.stanford.edu/~jurafsky/slp3/&quot;&gt;https://web.stanford.edu/~jurafsky/slp3/&lt;/a&gt;&lt;/li&gt; &lt;li id=&quot;ref-knuth1997&quot; style=&quot;padding-left: 1.5em; text-indent: -1.5em&quot;&gt;Knuth, D. E. (1997). &lt;i&gt;The Art of Computer Programming, Volume 2: Seminumerical Algorithms&lt;/i&gt; (3rd ed.). Addison-Wesley.&lt;/li&gt; &lt;li id=&quot;ref-NEY1994&quot; style=&quot;padding-left: 1.5em; text-indent: -1.5em&quot;&gt;Ney, H., Essen, U., &amp;amp; Kneser, R. (1994). On structuring probabilistic dependences in stochastic language modelling. &lt;i&gt;Computer Speech &amp;amp; Language&lt;/i&gt;, &lt;i&gt;8&lt;/i&gt;(1), 1–38. &lt;a href=&quot;https://doi.org/https://doi.org/10.1006/csla.1994.1001&quot;&gt;https://doi.org/https://doi.org/10.1006/csla.1994.1001&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;hr style=&quot;border: 0; border-top: 1px solid rgba(128, 128, 128, 0.3); margin: 2.5em 0 1em&quot; /&gt;
&lt;p style=&quot;font-size: 0.9em; color: #80818a&quot;&gt;Originally published on &lt;a href=&quot;https://oechsner.dev/blog/this-llm-has-a-context-of-1&quot;&gt;oechsner.dev&lt;/a&gt;. Read it there →&lt;/p&gt;</content>
    <category term="project report" />
  </entry>
  <entry>
    <title>Obsidian for school and Uni</title>
    <link rel="alternate" type="text/html" href="https://oechsner.dev/blog/obsidian-setup" />
    <id>https://oechsner.dev/blog/obsidian-setup</id>
    <published>2026-09-10T00:00:00Z</published>
    <updated>2026-09-10T00:00:00Z</updated>
    <summary type="text">In this blogpost I will cover my full 4-Year daily obsidian workflow, explain the rationale behind the plugins I chose and why links didn't work for me.</summary>
    <content type="html">&lt;p style=&quot;margin-bottom: 0.25em; font-size: 0.85em; color: #80818a&quot;&gt;10 September 2026 · 4 min read · 🤓 1/3 nerds · ✒️ 100% human-written&lt;/p&gt;
&lt;p style=&quot;margin-top: 0; font-size: 0.8em; letter-spacing: 0.08em; text-transform: uppercase; color: #a87a3c&quot;&gt;#obsidian&amp;nbsp;&amp;nbsp;#workflow&lt;/p&gt;
&lt;p style=&quot;font-size: 1.1em; line-height: 1.7; padding-left: 1em; border-left: 3px solid #e0a85c&quot;&gt;In this blogpost I will cover my full 4-Year daily obsidian workflow, explain the rationale behind the plugins I chose and why links didn't work for me.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://oechsner.dev/img/obsidian/cover.svg&quot; alt=&quot;The Obsidian logo at the centre of a note graph, with links radiating outwards to connected notes&quot; style=&quot;width: 100%; height: auto; border-radius: 6px&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;introduction&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Introduction&lt;/h2&gt; &lt;p&gt;Most developers should know the benefits of writing docs in &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;.md&lt;/code&gt;. Markdown not only gives you full ownership of all of your files, but also enables integration of arbitrary tools. Especially in the AI age, this is an essential strength.
Integrating AI into your notes becomes as easy as just spawning an agent in your vault root and formulating some behaviour rules.
You aren’t dependent on any toolset given to you by a firm with the same audience as scam callers.&lt;/p&gt; &lt;p&gt;&lt;em&gt;Choosing Obsidian means configurability, stability and (generally) a feeling of superiority.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;But like every highly configurable tool, it needs some setup to be nice to use. I’ve seen many bad tutorials and tips, and want to work my own experience into a small guide.
I built my vault to meet specifically my needs as a MINT student.&lt;/p&gt; &lt;h2 id=&quot;the-vault&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;The vault&lt;/h2&gt; &lt;p&gt;I’ve used the software for 4 years now. I’ve installed (and uninstalled) hundreds of community plugins and was in configuration hell, a minimalism trip and everything in between. I think I found a nice middle ground that works for me.&lt;/p&gt; &lt;p&gt;Believe it or not, but I found the builtin link system (and thus the infamous obsidian &lt;a href=&quot;https://forum.obsidian.md/uploads/default/original/3X/6/0/604d3693c38722b0c4b29628df1d45ffa473dd0a.png&quot; rel=&quot;nofollow&quot;&gt;graph network&lt;/a&gt;) as completely useless. That goes against the whole “second brain” crowd and I’m proud of it.
When I study, am completely organized into semesters, courses and lectures. Seeing the hierarchy?
Specific lecture notes correspond to specific lecture slides and embedded assets correspond to specific files.&lt;/p&gt; &lt;p&gt;&lt;em&gt;Connections in my vault aren’t made via links, they are made with locations and the hierarchy that this creates, so why would I need any more links?&lt;/em&gt;&lt;/p&gt; &lt;pre style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; line-height: 1.6; padding: 1em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 6px; overflow-x: auto&quot;&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace&quot;&gt;.
├── Archive/
│   ├── SS25/
│   │   └── Course1
│   └── ...
├── Course2/
│   ├── assets/
│   │   └── Lecture01/
│   │       └── image.png
│   ├── Assignments/
│   ├── Exam-prep/
│   ├── ...
│   ├── LecturePDF/
│   │   ├── Lecture01.pdf
│   │   └── Lecture02.pdf
│   ├── Lecture01.md
│   └── Lecture02.md
└── Course3/
    └── ...&lt;/code&gt;&lt;/pre&gt; &lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/obsidian/screenshot.png&quot; alt=&quot;The Obsidian window: a file explorer of semester folders on the left, a lecture note with LaTeX and a hand-drawn sketch in the middle, and a chat pane on the right&quot; style=&quot;max-width: 100%; height: auto; box-sizing: border-box; padding: 1em; background: #f2f2ef; border-radius: 6px&quot;&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;That same hierarchy, live: semesters inside Archive, courses inside those. Note what is missing: no ribbon, no tab title bar.&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;What follows is a list of all the plugins I use, sorted into specific usecases and a short explaination.&lt;/p&gt; &lt;h2 id=&quot;note-taking&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Note-Taking&lt;/h2&gt; &lt;h3 id=&quot;editor-feel&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Editor feel&lt;/h3&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Vimrc Support&lt;/strong&gt; — Loads a startup vimrc, so my Vim mappings are identical in Obsidian and in my editor.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Vim Yank Highlight&lt;/strong&gt; — Flashes the yanked region, must-have&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Code Editor Shortcuts&lt;/strong&gt; — VS Code key bindings (line move, duplicate, multi-cursor) inside the editor&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Spacekeys&lt;/strong&gt; — Leader-key style command sequences, so vault actions are reachable from the keyboard without hotkeys.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Typewriter Mode&lt;/strong&gt; — Buffer lines below the cursor, so you don't have to work at the edge of your screen.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;All to meet my needs of navigating quickly. I grew dependent the Vim keybindings.&lt;/p&gt; &lt;p&gt;My &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;.obsidian.vimrc&lt;/code&gt;:&lt;/p&gt; &lt;pre style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; line-height: 1.6; padding: 1em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 6px; overflow-x: auto&quot;&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace&quot;&gt;&quot; Have j and k navigate visual lines
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k

&quot; Quickly remove search highlights with ESC
nmap &amp;lt;ESC&amp;gt; :nohl&amp;lt;CR&amp;gt;

&quot;&quot; Smarter o and O (inserting prefix for markdown lists). 
nmap o A&amp;lt;CR&amp;gt;
nmap O kA&amp;lt;CR&amp;gt;

&quot; Yank to system clipboard
set clipboard=unnamed&lt;/code&gt;&lt;/pre&gt; &lt;h3 id=&quot;math-and-code&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Math and code&lt;/h3&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Quick Latex&lt;/strong&gt; — Auto-fractions, matrix and align shortcuts, custom shorthands, use immediately&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Completr&lt;/strong&gt; — Autocompletion for LaTeX commands (I disabled it for everything else)&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Solve&lt;/strong&gt; — Inline calculations in plain text: arithmetic, percentages, unit conversion and date math right where I am writing.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Code Emitter&lt;/strong&gt; — Executes code blocks directly in Document. I use it mainly for syntax verification&lt;/li&gt;&lt;li&gt;&lt;strong&gt;VSCode Editor&lt;/strong&gt; — Convenience plugin. Open arbitrary code files in Vault in a handy editor, not for fullon coding, good for a quick look&lt;/li&gt;&lt;/ul&gt; Quick Latex is probably the most important plugin of them all. $\LaTeX$ equations get rapid fast and my custom shorthand list grew to almost $90$. 
VSCode Editor is nice if you need to look something not .md up quick. &lt;h3 id=&quot;sketches-and-diagrams&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Sketches and diagrams&lt;/h3&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Excalidraw&lt;/strong&gt; — One of the most important elements in My workflow. Quickly draw and Embed handdrawn sketches&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Mermaid Tools&lt;/strong&gt; — Toolbar with common Mermaid elements, making it a smoother experience the few times I use Mermaind.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Obsidian Functionplot&lt;/strong&gt; — Plots mathematical functions inline.&lt;/li&gt;&lt;/ul&gt; Excalidraw should be self-explaining, as one of the worlds most popular whiteboards. &lt;p&gt;I’m a bit unhappy with the drawing &amp;amp; config speed though, Diagrams are clunky. This is where Mermaid comes into play. Obsidian has a builtin mermaid renderer, just label a block code with &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;mermaid&lt;/code&gt;. I still struggle with the syntax though, thus I use the toolbar.&lt;/p&gt; &lt;p&gt;A small regret I have is Obsidian Functionplot.  Have used it a few times and am now stuck with the plugin for backwards compatibility. &lt;em&gt;Don’t be like me, actually think about what you’ll use&lt;/em&gt;.&lt;/p&gt; &lt;h3 id=&quot;sources&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Sources&lt;/h3&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;PDF++&lt;/strong&gt; — Annotates lecture slides and papers inside Obsidian and links notes back to the exact highlighted passage in the PDF. I usually split-screen the PDF and note.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Media Extended&lt;/strong&gt; — Built in media player for lecture recordings. Supports timestamped embeds and Screenshots.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Auto Link Title&lt;/strong&gt; — Pasting a paper, docs page or lecture URL fetches a readable title instead of a naked link.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Paste URL into selection&lt;/strong&gt; — Select text, paste a URL, get a Markdown link. Just Intuitive behaviour, should be built in.&lt;/li&gt;&lt;/ul&gt; Both PDF++ and Media Extended are in my daily workflow. I usually splitscreen the source and my notes. &lt;p&gt;PDF++ is especially good, because it supports dynamic embeds. It just specifies a rectangle in the source file and renders on-demand, no additional images sitting in assets.
Media Extended sadly just takes screenshots. I’m not even sure if dynamic loading would be resourceful though, no idea if the .mp4 file structure would support this.&lt;/p&gt; &lt;h3 id=&quot;consistency&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Consistency&lt;/h3&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Linter&lt;/strong&gt; — Normalises YAML, headings, spacing and math blocks on save, making the vault a bit more normalized.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Smart Typography&lt;/strong&gt; — Converts quotes, dashes and ellipses to their typographic forms so exported PDFs look properly typeset.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Header Adjuster&lt;/strong&gt; — Bulk-shifts heading levels up or down&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Linter is great for solving a very specific problem of mine, because I often use this note structure:&lt;/p&gt; &lt;pre style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; line-height: 1.6; padding: 1em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 6px; overflow-x: auto&quot;&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace&quot;&gt;**Technical term**
- Aspect 1
- Aspect 2
**Broken term (gets wrapped upwards)**
- Aspect 1&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;Sadly, lines directly after lists in markdown gets merged into the previous line.
I forced an empty line after every bullet list with this custom regex:&lt;/p&gt; &lt;p&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;^((?:[ \t]*[-*+] .*\n)+)(?=[ \t]*(?![-*+] )\S)&lt;/code&gt; - &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;gm&lt;/code&gt; - &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;$1\n&lt;/code&gt;&lt;/p&gt; &lt;p&gt;I won’t explain it though, go figure it out yourself at &lt;a href=&quot;https://regex101.com/?regex=%5E((%3F%3A%5B%20%5Ct%5D*%5B-*%2B%5D%20.*%5Cn)%2B)(%3F%3D%5B%20%5Ct%5D*(%3F!%5B-*%2B%5D%20)%5CS)&amp;amp;testString=**Technical%20term**%0A-%20Aspect%201%0A-%20Aspect%202%0A**Broken%20term%20(gets%20wrapped%20upwards)**%0A-%20Aspect%201%0A&amp;amp;flags=gm&amp;amp;flavor=javascript&amp;amp;delimiter=%2F&quot; rel=&quot;nofollow&quot;&gt;Regex101&lt;/a&gt; — the example above is already loaded as the test string.&lt;/p&gt; &lt;h2 id=&quot;visuals&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Visuals&lt;/h2&gt; &lt;h3 id=&quot;styling&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Styling&lt;/h3&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Style Settings&lt;/strong&gt; — Exposes theme, snippet and plugin CSS variables as real settings, which is how I tune the look of callouts and tables without editing CSS by hand.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;List Callouts&lt;/strong&gt; — Lightweight inline callouts inside lists. See Better Export PDF, only exporter that supports them.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Iconize&lt;/strong&gt; — Icons on course folders and key notes so I can navigate the vault by shape instead of reading every folder name.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I’m currently using the &lt;a href=&quot;https://github.com/nickmilo/soft-paper&quot; rel=&quot;nofollow&quot;&gt;Soft Paper&lt;/a&gt; Theme, mainly for its customisability with style settings. I also like the pastel background.&lt;/p&gt; &lt;h3 id=&quot;how-the-screen-looks&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;How the screen looks&lt;/h3&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Hider&lt;/strong&gt; — Hides specific visual elements. Important for a distraction-free Workspace.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Status Bar Organizer&lt;/strong&gt; — Reorders and hides status bar items, keeping only the counters I actually watch (edit time, word count) visible.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Hide Sidebars on Window Resize&lt;/strong&gt; — Collapses sidebars automatically when I shrink the window. This means that notes are always readable, even if I have obsidian only on one side of the screen&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I found the standard view to be much to cluttered and distracting, thus I hid most of it. I hid:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The ribbon&lt;/li&gt; &lt;li&gt;the tab title bar&lt;/li&gt; &lt;li&gt;Many Statusbar items, including Vim mode&lt;/li&gt; &lt;li&gt;backlink, canvas, footnotes, page-preview, daily-notes, slash-command, bookmarks, markdown-importer, zk-prefixer, random-note, audio-recorder, publish, bases&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I also have keyboard shortcuts to directly hide sidebars and tabbar. This means in fullscreen I only see my note, perfect focus.&lt;/p&gt; &lt;h2 id=&quot;navigation-search&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Navigation &amp;amp; Search&lt;/h2&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Workspaces Plus&lt;/strong&gt; — Fast switching between saved layouts: One for each Course and usecase&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Multiple Notes Outline&lt;/strong&gt; — Shows the outlines of several notes side by side, which is how I get an overview of a whole course before an exam.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Settings Search&lt;/strong&gt; — Global search across all settings tabs&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Multiple Notes outline is a gem I found relatively recently.
I configured it to display the outline of every note in a course folder, superb for navigation and getting a overview on how far your notes are done.&lt;/p&gt; &lt;h2 id=&quot;getting-things-out-of-the-vault&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Getting things out of the vault&lt;/h2&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Advanced Slides&lt;/strong&gt; — Turns a course note into a slide deck without leaving the vault: Used mainly for tutoring&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Better Export PDF&lt;/strong&gt; — Exports notes as PDFs, produce printable summary sheets for friends. Replaces Obsidian export, because it supports List callouts&lt;/li&gt;&lt;/ul&gt; &lt;h2 id=&quot;service-callers&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Service callers&lt;/h2&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Claudian&lt;/strong&gt; — Embeds Claude Code and other coding agents with the vault as working directory, so an agent can read my notes and PDFs, run shell commands and edit files for me.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Google Calendar&lt;/strong&gt; — Pulls lecture, lab and deadline events into the vault so planning notes sit next to the actual schedule.&lt;/li&gt;&lt;/ul&gt; Even though claude integration is very easy (see above), I like to have a custom view for the LLM. Claudian gives me that: it embeds the agent in a sidebar pane with the vault as its working directory, and it renders $\LaTeX$, important for math questions. I've tried many agent plugins, Claudian was the best. &lt;p&gt;Custom system prompt:&lt;/p&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;You are mainly used as a university tutor for students with solid CS experience (especially ML). Act accordingly, highlight connections and explain with related concepts.
If you create a file, mark it with the “LLM: Claude” property.
If you modify a file, insert ”— (Claude)” as header and footer to your modification.&lt;/p&gt;&lt;/blockquote&gt; &lt;h2 id=&quot;under-the-hood&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Under the hood&lt;/h2&gt; &lt;ul style=&quot;padding-left: 1.25em&quot;&gt;&lt;li&gt;&lt;strong&gt;Plugin Groups&lt;/strong&gt; — Enables and disables sets of plugins with one command and delays startup of heavy ones, which keeps this long list from slowing down launch.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Custom Attachment Location&lt;/strong&gt; — Store embeds near the actual note, not in one big photo wasteland&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Update time on edit&lt;/strong&gt; — Keeps the frontmatter timestamps current automatically, Which is what my Dataview &quot;recently touched&quot; queries depend on.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;NLP&lt;/strong&gt; — Provides NLP primitives (tokenisation, similarity, keyword extraction) that other plugins and my own queries can build on for text analysis over the vault.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Custom Attachment Location is very important to me, since my hierarchical filestructure needs me to have embeds near the actual note. This is where I store my embeds:&lt;/p&gt; &lt;pre style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; line-height: 1.6; padding: 1em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 6px; overflow-x: auto&quot;&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace&quot;&gt;.
├── assets/
│   ├── Note1/
│   │   └── img1.png
│   └── Note2/
│       └── drawing.excalidraw
├── Note1.md (embeds img1.png)
└── Note2.md (embeds drawing.excalidraw)&lt;/code&gt;&lt;/pre&gt; &lt;h2 id=&quot;sync-and-backup&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Sync and backup&lt;/h2&gt; &lt;p&gt;I actually don’t have a dedicated backup system for obsidian. I put all of my documents in a partition &lt;strong&gt;BEFORE&lt;/strong&gt; my OS. This is backed up to Google drive using &lt;a href=&quot;https://support.google.com/a/users/answer/13022292?hl=en&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt; &lt;h2 id=&quot;disclaimer&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Disclaimer&lt;/h2&gt; &lt;p&gt;Keep in mind that nothing good comes from optimising your note-taking system to the brim, it’s just wasted time. If another system works for you, honestly keep it. But if you’re already deep in the obsidian rabbithole, I suggest giving my method a try :). Thanks for reading my second blogpost!&lt;/p&gt;
&lt;hr style=&quot;border: 0; border-top: 1px solid rgba(128, 128, 128, 0.3); margin: 2.5em 0 1em&quot; /&gt;
&lt;p style=&quot;font-size: 0.9em; color: #80818a&quot;&gt;Originally published on &lt;a href=&quot;https://oechsner.dev/blog/obsidian-setup&quot;&gt;oechsner.dev&lt;/a&gt;. Read it there →&lt;/p&gt;</content>
    <category term="obsidian" />
    <category term="workflow" />
  </entry>
  <entry>
    <title>Solving (German) Hangman with Letter Frequencies</title>
    <link rel="alternate" type="text/html" href="https://oechsner.dev/blog/analysing-hangman" />
    <id>https://oechsner.dev/blog/analysing-hangman</id>
    <published>2026-09-06T00:00:00Z</published>
    <updated>2026-09-06T00:00:00Z</updated>
    <summary type="text">In this article, I walk through how I analysed and solved Hangman with some Stat. I'll talk about game rules, high level implementation of a winning strategy and letter frequencies. </summary>
    <content type="html">&lt;p style=&quot;margin-bottom: 0.25em; font-size: 0.85em; color: #80818a&quot;&gt;6 September 2026 · 4 min read · 🤓🤓 2/3 nerds · ✒️ 100% human-written&lt;/p&gt;
&lt;p style=&quot;margin-top: 0; font-size: 0.8em; letter-spacing: 0.08em; text-transform: uppercase; color: #a87a3c&quot;&gt;#statistics&amp;nbsp;&amp;nbsp;#sidequest&lt;/p&gt;
&lt;p style=&quot;font-size: 1.1em; line-height: 1.7; padding-left: 1em; border-left: 3px solid #e0a85c&quot;&gt;In this article, I walk through how I analysed and solved Hangman with some Stat. I'll talk about game rules, high level implementation of a winning strategy and letter frequencies. &lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/cover.svg&quot; alt=&quot;A hangman gallows beside a six-letter word with two letters still blank, above a decision tree whose highlighted branch picks out the matching German word&quot; style=&quot;width: 100%; height: auto; border-radius: 6px&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This project is heavily inspired by &lt;a href=&quot;https://www.youtube.com/watch?v=ApdLgfgfh5o&quot; rel=&quot;nofollow&quot;&gt;this video&lt;/a&gt; by Ballpark Figures.&lt;/em&gt; &lt;strong&gt;All code used for this project is available on &lt;a href=&quot;https://github.com/JonasOech/analysing_Hangman&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;display:inline-flex;align-items:center;gap:0.3em&quot;&gt;Github&lt;/span&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt; &lt;h2 id=&quot;hangman-rules&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Hangman Rules&lt;/h2&gt; &lt;p&gt;Hangman is a two player game, where one player is the &lt;em&gt;Game master&lt;/em&gt;, deciding on
a secret word (in my case a noun in German). The other player tries to guess this
word by asking for individual letters. If the secret word contains that letter, the
Game master reveals all positions, where that letter is at. If it doesn’t, the player loses a life.
Figuratively, one body part is added to a stick figure hanging from the gallows.
The guessing player knows the number of letters in the secret word.
In the following, I will assume the guessing player has perfect knowledge of the wordset and the choosing player randomly selects a word from it.&lt;/p&gt; &lt;p&gt;I settled on hangman with 6 lives (Head, Body and 4 limbs) and set umlauts (Ä, Ö, Ü) and the ‘sharp S’ (ß) as separate characters.&lt;/p&gt; &lt;h2 id=&quot;taumata-whakatangihanga-koauau-o-tamatea-turi-pukaka-piki-maunga-horo-nuku-pokai-whenua-ki-tana-tahu&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Taumata­whakatangihanga­koauau­o­tamatea­turi­pukaka­piki­maunga­horo­nuku­pokai­whenua­ki­tana­tahu&lt;/h2&gt; &lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/NounDistribution.png&quot; alt=&quot;A histogram of German noun lengths, peaking at 10 letters and trailing off to a maximum of 85&quot; style=&quot;max-width: 100%; height: auto; box-sizing: border-box; padding: 1em; background: #f2f2ef; border-radius: 6px&quot;&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;The distribution of noun lengths in German&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;Taumata­whakatangihanga­koauau­o­tamatea­turi­pukaka­piki­maunga­horo­nuku­pokai­whenua­ki­tana­tahu is the longest word in my &lt;a href=&quot;https://raw.githubusercontent.com/gambolputty/german-nouns/main/german_nouns/nouns.csv&quot; rel=&quot;nofollow&quot;&gt;Wordlist&lt;/a&gt;. It has &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;85&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;85&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; letters and apparently is the name of a hill in New Zealand. Note that in German, you can infinitely chain nouns together. &lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; padding: 0.1em 0.35em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 3px&quot;&gt;German-Nouns&lt;/code&gt; only selects words that were mentioned in German Wikipedia.
Since the guessing player knows the number of letters at the start of the game, we can treat every word length as its own separate problem.&lt;/p&gt; &lt;p&gt;Each different guess can have a maximum of &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msup&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;2^{n}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; different outcomes, where &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;n&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; is the number of unknown positions in the word.&lt;/p&gt; &lt;h2 id=&quot;the-frequency-tactic&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;The Frequency tactic&lt;/h2&gt; &lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/letterfreq.png&quot; alt=&quot;A bar chart of German letter frequencies in nouns, descending from e at almost 13 percent down to q&quot; style=&quot;max-width: 100%; height: auto; box-sizing: border-box; padding: 1em; background: #f2f2ef; border-radius: 6px&quot;&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;The distribution of letter uses in German&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;The first real tactic that comes to mind is picking the most frequent letters in order. It is flawed, because it completely disregards existing information the guessing player has: Letter count of the word, Existing successful guesses and his knowledge about the German language.&lt;/p&gt; &lt;p&gt;This naive tactic yields a winrate of about &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;9.0&lt;/mn&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;%&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;9.0\%&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; with an average number of &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;10.73&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;10.73&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; misses per word. We are already significantly better than just choosing letters in &lt;em&gt;alphabetical order&lt;/em&gt;, where we get a winrate of &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;0.2&lt;/mn&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;%&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;0.2\%&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; with &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;13.89&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;13.89&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; avg misses per word. Note that the miss counts come from letting every game run to the end of the alphabet instead of stopping at the sixth wrong guess. That is why they are so far above the 6 lives an actual game gives you.&lt;/p&gt; &lt;h2 id=&quot;the-greedy-strategy&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;The greedy Strategy&lt;/h2&gt; &lt;p&gt;At every game step, we can perform a letter frequency analysis on the remaining
word options and select the most frequent letter and thus make the optimal
greedy choice. I will call this strategy &lt;em&gt;Letter Counting&lt;/em&gt; from here on. This of course assumes perfect knowledge of the choosing player’s
wordset. After running for about 10 minutes on 500 samples per wordlength, this achieved a &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;97.2&lt;/mn&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;%&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;97.2\%&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; winrate with &lt;span&gt;&lt;span&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;1.21&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;1.21&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; average misses. We mainly fail on short, unconventional words. Some examples for len 3-8:&lt;/p&gt; &lt;pre style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; line-height: 1.6; padding: 1em; background: rgba(128, 128, 128, 0.08); border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 6px; overflow-x: auto&quot;&gt;&lt;code style=&quot;font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace&quot;&gt;Len 3: 'gäa' in 8 guesses (6 wrong: eoinbd, 6 to finish)
Len 3: 'sou' in 8 guesses (6 wrong: aebndg, 7 to finish)
Len 3: 'rtl' in 6 guesses (6 wrong: aeouid, 7 to finish)
Len 3: 'ivf' in 7 guesses (6 wrong: aeouhl, 8 to finish)
Len 3: 'ria' in 8 guesses (6 wrong: eocdfm, 7 to finish)
Len 4: 'tipp' in 8 guesses (6 wrong: aeonkl, 7 to finish)
Len 4: 'crow' in 8 guesses (6 wrong: aelgbf, 6 to finish)
Len 4: 'smog' in 8 guesses (6 wrong: aelrnh, 6 to finish)
Len 4: 'chef' in 7 guesses (6 wrong: aiorln, 6 to finish)
Len 4: 'zaya' in 7 guesses (6 wrong: mrgnpv, 7 to finish)
Len 5: 'füdle' in 9 guesses (6 wrong: aiuoth, 6 to finish)
Len 5: 'wippe' in 8 guesses (6 wrong: anlktr, 8 to finish)
Len 5: 'ziege' in 9 guesses (6 wrong: smflrw, 6 to finish)
Len 5: 'haxen' in 10 guesses (6 wrong: rlmgbf, 7 to finish)
Len 5: 'debüt' in 8 guesses (6 wrong: aiourh, 6 to finish)
Len 6: 'tauber' in 9 guesses (6 wrong: lnskgp, 6 to finish)
Len 6: 'medium' in 7 guesses (6 wrong: nrlstg, 6 to finish)
Len 6: 'fasson' in 9 guesses (6 wrong: eirkmb, 6 to finish)
Len 6: 'schulz' in 11 guesses (6 wrong: eaiotd, 7 to finish)
Len 6: 'zörbig' in 7 guesses (6 wrong: eansou, 6 to finish)
Len 7: 'dämlack' in 7 guesses (6 wrong: eonhru, 7 to finish)
Len 7: 'curling' in 10 guesses (6 wrong: eathbm, 6 to finish)
Len 7: 'bexbach' in 7 guesses (6 wrong: nrslti, 6 to finish)
Len 7: 'fußfall' in 8 guesses (6 wrong: eonhrb, 6 to finish)
Len 7: 'gezücht' in 11 guesses (6 wrong: nrslim, 6 to finish)
Len 8: 'luftkuss' in 7 guesses (6 wrong: eaoicn, 6 to finish)&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;&lt;em&gt;Note that the first guess can be different depending on lengths, because each len has a unique letter distribution&lt;/em&gt;&lt;/p&gt; &lt;p&gt;These words are pretty unsurprising. Due to the lower letter count, we have much less
information that narrows down the candidate count. There also is a lower
probability the letter appears in the guessed word, just because it is shorter.
Thus, we can generally expect worse performance on shorter words.&lt;/p&gt; &lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/letterCounting.png&quot; alt=&quot;A bar chart of the average number of false guesses per word length under Letter Counting, falling from about 6 at length 3 to near zero by length 15&quot; style=&quot;max-width: 100%; height: auto; box-sizing: border-box; padding: 1em; background: #f2f2ef; border-radius: 6px&quot;&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;Average number of wrong guesses for every word length. From about length 15 onwards, misses are already negligible.&lt;/figcaption&gt;&lt;/figure&gt; &lt;h3 id=&quot;letter-distributions&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Letter distributions&lt;/h3&gt; &lt;p&gt;It’s actually pretty interesting, how the letter distribution of the words &lt;em&gt;Letter Counting loses on&lt;/em&gt; differs from the wordset as a whole:&lt;/p&gt; &lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/newDistrib.png&quot; alt=&quot;A grouped bar chart comparing letter frequencies across all words against the words Letter Counting lost on&quot; style=&quot;max-width: 100%; height: auto; box-sizing: border-box; padding: 1em; background: #f2f2ef; border-radius: 6px&quot;&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;Letter distribution on All words in the dataset vs just the ones Letter Counting lost on.&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;We see, that unpopular letters such as &lt;em&gt;j, ß&lt;/em&gt; or &lt;em&gt;x&lt;/em&gt; are much more popular in &lt;em&gt;difficult&lt;/em&gt; words, confirming my theory. By looking at the outliers, we can conclude, that the choosing player should generally choose words with &lt;em&gt;a, u, k and specifically p and z&lt;/em&gt; more, and &lt;em&gt;n,r and s&lt;/em&gt; less often.&lt;/p&gt; &lt;h2 id=&quot;conclusion&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;Conclusion&lt;/h2&gt; &lt;figure style=&quot;margin: 1.75em 0&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/strategies.png&quot; alt=&quot;A line chart comparing three strategies, with alphabetical order highest, frequency in the middle and Letter Counting near zero across word lengths&quot; style=&quot;max-width: 100%; height: auto; box-sizing: border-box; padding: 1em; background: #f2f2ef; border-radius: 6px&quot;&gt; &lt;figcaption style=&quot;margin-top: 0.6em; font-size: 0.85em; color: #80818a&quot;&gt;Average false guesses per word length, for all three strategies&lt;/figcaption&gt;&lt;/figure&gt; &lt;p&gt;We can see, that for long words, the game is pretty much trivial. To ensure a fair (and fun) game assuming perfect play, I suggest a system of dynamic lives according to this table:&lt;/p&gt; &lt;div&gt;&lt;table style=&quot;width: 100%; border-collapse: collapse; font-size: 0.95em&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;Word Length&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;3&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;4&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;5&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;6&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;7/8&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;9+&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;Lives&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;6&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;5&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;4&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;3&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;2&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th scope=&quot;row&quot; style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase&quot;&gt;Hangman&lt;/th&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/hangman-6.svg&quot; alt=&quot;&quot; style=&quot;height: 120px; width: auto&quot;&gt;&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/hangman-5.svg&quot; alt=&quot;&quot; style=&quot;height: 120px; width: auto&quot;&gt;&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/hangman-4.svg&quot; alt=&quot;&quot; style=&quot;height: 120px; width: auto&quot;&gt;&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/hangman-3.svg&quot; alt=&quot;&quot; style=&quot;height: 120px; width: auto&quot;&gt;&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/hangman-2.svg&quot; alt=&quot;&quot; style=&quot;height: 120px; width: auto&quot;&gt;&lt;/td&gt;&lt;td style=&quot;text-align: left; padding: 0.5em 0.75em; border-bottom: 1px solid rgba(128, 128, 128, 0.3)&quot;&gt;&lt;img src=&quot;https://oechsner.dev/img/hangman/hangman-1.svg&quot; alt=&quot;&quot; style=&quot;height: 120px; width: auto&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;p&gt;Every colour in those hangmen is one life. As the count drops, parts get merged into a single stroke: both legs at once, then both arms, until for 9+ letters we just draw a head. &lt;em&gt;Hangmen drawn in Excalidraw btw&lt;/em&gt;&lt;/p&gt; &lt;h2 id=&quot;what-now&quot; style=&quot;font-family: 'Playfair Display', 'Iowan Old Style', Georgia, serif; line-height: 1.3; margin-top: 2em&quot;&gt;What now?&lt;/h2&gt; &lt;p&gt;A list of possible research questions for the future:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;You could further investigate the frequency differences to English (or other languages) and do a frequency analysis on specific wordlengths.&lt;/li&gt; &lt;li&gt;You could also develop a system for humans to implement the greedy strategy as best as they can.&lt;/li&gt; &lt;li&gt;The dataset doesn't consider arbitrary composite nouns&lt;/li&gt; &lt;li&gt;What would happen if the guessing player &lt;em&gt;didn't&lt;/em&gt; know the letter count?&lt;/li&gt;&lt;/ul&gt; &lt;blockquote style=&quot;margin: 1.5em 0; padding-left: 1em; border-left: 2px solid #a87a3c; font-style: italic&quot;&gt;&lt;p&gt;Seriously try playing it this way! It actually is really fun. Thanks for reading this post, it took a lot of effort. :)&lt;/p&gt;&lt;/blockquote&gt;
&lt;hr style=&quot;border: 0; border-top: 1px solid rgba(128, 128, 128, 0.3); margin: 2.5em 0 1em&quot; /&gt;
&lt;p style=&quot;font-size: 0.9em; color: #80818a&quot;&gt;Originally published on &lt;a href=&quot;https://oechsner.dev/blog/analysing-hangman&quot;&gt;oechsner.dev&lt;/a&gt;. Read it there →&lt;/p&gt;</content>
    <category term="statistics" />
    <category term="sidequest" />
  </entry>
</feed>