1977 2026

The Baby Language Model
in One Line of AWK

Meet the smallest, simplest, and most educational language model ever created — written in a single line of AWK.

What is an AWK Baby LLM?

A "Baby Language Model" is a tiny statistical model that learns the most basic thing about language: which words appear most often.

This one-liner AWK script is the most minimal version of a unigram language model — the same core idea that powered early statistical language models before deep learning took over.

"It doesn't understand meaning. It just knows what words like to hang out together."

awk '{
    gsub(/[^a-zA-Z0-9 ]/, " ");
    for(i=1;i<=NF;i++) {
        w = tolower($i);
        if(w) count[w]++
    }
} END { for(w in count) print count[w], w }' text.txt | sort -nr

One command. Zero dependencies. Pure Unix magic.

How Does It Work?

1

Clean the text

Removes punctuation and converts everything to lowercase.

2

Count word frequencies

Uses AWK's powerful associative arrays to count every word.

3

Sort & Display

Sorts by frequency (most common first) — just like real language models prioritize likely words.

Try the Baby LLM Live

Baby LLM vs Modern LLMs

Baby LLM (AWK)

  • One line of code
  • Runs instantly on any Unix system
  • Teaches core statistical idea
  • Zero training cost

Modern LLMs (Grok, GPT, etc.)

  • Billions of parameters
  • Trained on trillions of tokens
  • Understands context & meaning
  • Can generate coherent text
The Baby LLM shows us that at the heart of modern AI is a very old and beautiful idea:
"Language is just patterns in data."

Made with curiosity • Share freely