Meet the smallest, simplest, and most educational language model ever created — written in a single line of AWK.
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.
Removes punctuation and converts everything to lowercase.
Uses AWK's powerful associative arrays to count every word.
Sorts by frequency (most common first) — just like real language models prioritize likely words.