How Autocorrect Works: An AI Lesson for Middle School
A student raises her hand in the middle of a typing lesson and asks: “Why does my phone keep changing my words?” It’s a fair question, and a common one. The honest answer — the mechanism behind it — is not something most teachers were ever handed. Nobody sent home a PD on phoneme-detection models and edit-distance algorithms. That absence is not a gap in any teacher’s effort. It is a gap in the curriculum no one thought to fill. The good news: autocorrect runs on a four-step system that any grade-6 student can trace by hand. Once you see those four steps, the behavior of every keyboard on the planet stops looking like magic and starts looking like a very specific machine — one worth understanding.
Autocorrect works in four sequential steps. First, the keyboard records where your finger actually lands on the screen and estimates which keys are nearby — it captures coordinates, not just keystrokes. Second, it searches a dictionary for real words that are close (a few edits away) to the garbled taps it received. Third, a language model scores those candidates against the words you already typed, picking the one that fits the context best. Fourth, it substitutes the top-ranked word and remembers which words you accept or override to improve next time. The whole cycle runs in milliseconds, invisibly, billions of times per day.
Why does autocorrect keep changing your words?
The short answer: because autocorrect is not reading your mind. It is running a probability calculation about which word you most likely intended, based on where your fingers landed and what you already said.
That calculation fails in predictable ways, and middle schoolers know every one of them. A name that no one else in the dictionary has — the system changes it to the closest common word. A slang term the training data never saw — gone. A correctly spelled word that happens to look a lot like a different word — swapped without warning, right before you hit send. (“Ducking” had its own decade-long career in text messages for exactly this reason.)
These failure moments are not random glitches. Each one is a window into the mechanism: the system guessed, and it guessed wrong. When a 7th grader can name why the phone made that particular mistake — proximity bias in the touch model, a frequency-table gap, a context window that missed the joke — they’ve started doing what AI4K12 Big Idea #3 describes: understanding how computers learn patterns from data. The failures are the doorway. Walk through them deliberately.
How autocorrect actually works: the four-step pipeline

Autocorrect is a pipeline. Data goes in at one end, a substituted word comes out at the other. Four distinct stages do the work.
Step 1 — Touch model. The keyboard records the x-y coordinates of where your finger landed on the glass, not which key you intended. Because fingers are wider than keys, that coordinate sits inside a probability cloud — it could plausibly be an “e,” “r,” or “d.” The touch model assigns a probability to each nearby key by physical distance. Research on touch-screen keyboard decoding found that modeling finger position as a probability distribution — rather than a single “pressed” key — dramatically improves accuracy (arXiv:1704.03987, Vertanen et al.).
Step 2 — Candidate generation (edit distance). The system searches the dictionary for real words that require the fewest corrections — inserts, deletes, or substitutions — to match the probabilistic tap sequence. This measure is called Levenshtein distance. A word needing two changes scores lower than one needing one. The result is a ranked candidate list. (SamMobile explainer)
Step 3 — Language-model context scoring. Candidates are re-ranked by how well each fits the sentence already typed. The scoring formula approximates: score = P(word) × P(taps | word) — the probability of that word in English times the probability those taps would produce it. A common contextually fitting word beats a rare spelling match. (Slate / Nuance, 2010)
Step 4 — Selection and personalization. The top-ranked word is offered as a suggestion or substituted automatically depending on confidence. The system records whether you accept or override — every override is a training signal. Address-book names get added to the personal dictionary. The system adapts to your vocabulary over time.
Worked trace — one example end-to-end (the probability values below are illustrative, chosen to show the mechanism, not measured from a specific device):
| Stage | Input / Output |
|---|---|
| Raw taps | ”teh” (finger landed left of “h”, near “e” and “h” keys) |
| Touch model | Probability cloud: t=0.95, e=0.91, h=0.88, y=0.34 |
| Candidate generation | the (1 transposition), teh (0 edits but not a dictionary word), ten (1 substitution) |
| Language-model scoring | Context is “I saw ___” → “the” scores highest; “ten” plausible but weaker match |
| Output | ”the” substituted automatically |
The same process runs for every word. Every millisecond. On every phone in every classroom.
Old autocorrect vs. the new AI keyboard

Direct answer first: old autocorrect knew which word was most common; new autocorrect tries to guess which word you meant — and the difference matters enormously for understanding what “AI” actually means.
T9 and early smartphone keyboards worked from static frequency tables and n-gram dictionaries: given a sequence of key presses, return the most common matching word. No sense of meaning, no context. Just a frequency rank.
Modern keyboards work differently. Google’s Gboard switched to an LSTM neural network with federated learning — training happens on each person’s device, and only encrypted weight updates (not the actual words typed) leave the phone. Google published this approach in 2019. (Google Research, 2019) Apple’s iOS 17 (WWDC, June 2023) went further, replacing statistical autocorrect with an on-device transformer language model that reads whole-sentence context — which is why iOS 17 finally stopped the decade-long “ducking” swap: the transformer could read enough context to know the word was intentional. (MacRumors iOS 17 guide; NPR, June 2023)
This maps directly to AI4K12 Big Idea #3 — computers learn from data — but the nuance worth naming in class: what data was collected, from whom, and which patterns did it miss? That question leads to the next section.
Where autocorrect fails — and why that’s the real lesson

The answer your students are waiting for: autocorrect fails because probability is not truth — and the data it learned from was not collected from everyone equally.
Failure table — real documented cases:
| Failure type | What happened | Why it happened | Source |
|---|---|---|---|
| The Cupertino effect | Old spellcheck replaced “cooperation” with “Cupertino” in corporate docs; the error made it into published wire-service copy (“Muttonhead Quail movement” in a Reuters dispatch is a documented example) | Dictionary did not know the intended word; frequency table picked the closest common match | Wikipedia; Mental Floss |
| The “ducking” filter | Apple’s profanity filter swapped a specific word for “ducking” for over a decade, even in legitimate uses | A blunt substring-match block, no context; fixed in iOS 17 with a transformer model | NPR, June 2023 |
| Name and dialect bias | Devices routinely flag or change non-Western names as “misspellings”; a campaign called “I Am Not a Typo” found that roughly 41% of names recorded in England & Wales are marked incorrect by a standard English dictionary | Training corpora skewed toward Western, English-language text; names outside that distribution are invisible to the frequency model | ABC News AU, May 2024; Dyal-Chand, BU Law Review, 2021 |
The third row is the heart of the lesson. When a student types her own name and the phone marks it red, that is not a technical glitch. It is a design choice embedded in the training data — and it has a traceable cause. This is AI4K12 Big Idea #5 (societal impact) meeting ISTE 1.2.b (understand the social and cultural implications of digital tools) in a way students can feel personally.
A no-device lesson: ‘Be the Autocorrect’
This is a fully runnable unplugged activity — no phone required, no Wi-Fi, no login. Students physically act out the four-step pipeline using index cards and paper.
Setup (5 minutes). Each table group of four gets: a set of index cards with dictionary words written on them (the “dictionary”), a frequency tally sheet showing how often each word appears in sample sentences (the “language model”), and a garbled handwritten sentence — for example, “Teh snu ius shinung briguhtly” — where the letters are close to correct but slightly off.
Running the pipeline (15 minutes). Each group works through the four steps by hand. One student is the touch model — writes down two or three dictionary cards phonetically close to each garbled word. One is the candidate generator — counts edit-distance for each candidate and ranks them. One is the language model — uses the frequency sheet and already-corrected words to pick the best fit. One is the personalization layer — accepts or overrides, and marks it.
Compare (5-10 minutes). Groups type the same garbled sentence into a phone. How close did their hand-run pipeline come? Where did it diverge?
A typical class finishes the full cycle — pipeline run, phone comparison, discussion — in 25-30 minutes. The divergence moments are the richest: they usually reveal a frequency-table difference (the phone’s training corpus versus the classroom sheet) or a context effect the phone caught that students didn’t notice.
Standards crosswalk:
| Activity step | Standard |
|---|---|
| Touch-model + edit-distance ranking step | ISTE 1.5.d — understand algorithmic thinking; design and test solutions |
| Investigate-how-it-works comparison phase | ISTE 1.3.d — build knowledge by actively exploring real-world issues |
| Bias and name-flagging discussion | AI4K12 Big Idea #5 + CCSS.ELA-LITERACY.SL.7.1 — engage in collaborative discussion |
| Written reflection on divergence | CCSS.ELA-LITERACY.W.7.8 — gather information and assess credibility |
For the full no-device unit — 10 unplugged activities built around the same card-sort and role-play structure — the Unplugged AI Activities bundle on TPT covers algorithmic thinking, bias detection, and the underlying math of probability in a format that runs in rooms with no devices and no login walls.
The mechanism was always knowable. The explainer just wasn’t there.
The AI confusion students bring into a middle school classroom — the sense that their phone is deciding things for them, that technology is a black box they’re supposed to accept — is not a sign they can’t handle technical explanations. It is a sign they haven’t been given one yet.
A student who asks “why does my phone keep changing my words?” is already doing the right thing. She noticed a pattern. She asked for the cause. The four-step pipeline is the answer — touchscreen probability, edit distance, language-model context scoring, personalization. It is learnable. It is teachable. And you have everything in this post to teach it with no devices, no subscriptions, and no background in computer science.
That gap — the one where the curriculum should have been — was never the teacher’s problem to solve from scratch. It was a resourcing failure. The tools exist now.
The How AI Works MEGA bundle extends this pattern across 16 mechanism lessons for grades 6-12 — each following the same sequence: mechanism, worked example, unplugged simulation, failure and bias, standards. If students need to sort what kind of AI autocorrect is before the mechanism lesson lands, the Types of AI Deep-Dive lesson builds that vocabulary first. The full catalog is at /shop.
For the speech-recognition follow-on — how a voice assistant turns sound into words before it responds — the how voice assistants work lesson uses the same methodology. And to show students how autocorrect’s “predict the next word” logic scales to a tool that writes entire paragraphs, the how generative AI works lesson makes that bridge explicit.
This post was drafted with AI assistance and human-finalized.
Quick questions
Autocorrect runs a four-step pipeline: a touch model estimates which keys your finger was near, a candidate generator finds real dictionary words a few edits away, a language model scores those candidates against the words you already typed, and the top-ranked word is substituted while the system learns from your overrides.
Because autocorrect predicts the most probable word from finger position and context, not the word you actually meant. When a name, slang term, or lookalike word scores lower than a common alternative, the system swaps it — a probability error, not a random glitch.
Run the 'Be the Autocorrect' unplugged activity: student groups use index-card dictionaries and a frequency tally sheet to hand-correct a garbled sentence through the four pipeline roles, then compare their result to a phone. A typical class finishes in 25-30 minutes.
Get the free AI-Proof Assignment Toolkit
10 ways to redesign any assignment so an AI chatbot structurally can't do it — plus a redesign worksheet, a 45-minute lesson, the “Spot AI Work” card, and parent templates. One email, all 5 pieces.
Prefer the full breakdown? See everything inside the toolkit →