If you’ve ever played around with ChatGPT (i.e., you haven’t been living under a rock for the past 2 years), you’ve seen how it demonstrates an uncanny ability to generate human-like text. From crafting poetry that tugs at your heartstrings to explaining complex scientific concepts with ease, these AI language models seem to have an almost magical grasp of human communication.
Last week, we discussed how LLMs are able to generate this text.
But have you ever wondered how these models actually “learn” natural language? How does a machine, trained on vast amounts of data, manage to produce language that feels so genuinely human?
In this article, we’ll talk about the implications of how large language models are architected, and how these factors contribute to their ability to “learn” language.
As we previously discussed, LLMs are essentially highly complex sequence predictors. Given a sequence of tokens, the purpose of an LLM is to predict the next token that would come in the sequence.
This could be accomplished trivially with simple statistical modeling, where we simply choose the next most likely “word” given the previous word. For example, one could employ traditional probabilistic approaches by choosing the next most likely word or token given the previous word, as determined by statistical frequency in large corpora of text. This concept aligns closely with the notion of n-gram models, where the likelihood of a given word appearing is based solely on the sequence of the previous n words. (If you are familiar with Markov processes from probability theory or computational modeling, you can think of this prediction as a type of Markov process, in which the next event in a sequence is governed entirely by the preceding event.)1
But language is much more intricate than what simple statistical probabilities can capture. Predicting the next token isn’t just a matter of identifying the most frequent word to follow another—it requires understanding context, syntax, semantics, and even pragmatics.
For instance, if you’ve ever spam clicked the word predictions on your iPhone keyboard, you’ve probably seen that the language it generates is incoherent gibberish. These predictions are surface-level, and don’t take into account the complexities of language.
Human language is filled with nuances that simple statistical models struggle to replicate. For example, words can have multiple meanings depending on the context (polysemy), phrases can carry idiomatic meanings that aren’t obvious from the individual words, and sentences often rely on information introduced much earlier in the text. How do we move beyond surface-level sequence prediction, and take into account the complexities of natural language?
Enter what is often considered the most revolutionary advancement in machine learning of the 2010s: transformer architectures. All modern language models are built off of this technology, and they enable us to capture complex linguistic relationships and contextual nuances far beyond simple statistical probabilities.
From a computational linguistics perspective, we can view human language as a series of dependent clauses and phrases that come together to make a coherent statement:
The above image is an example of a “dependency graph,” generated by a natural language processing software. Notice how each word is connected to each other—the meaning of the sentence is dependent on the ordering of the words, the actual content of the words, and how each word is related to one another.
Transformers were designed to capture these complex linguistic relationships. At their core is a mechanism called self-attention. This mechanism allows a model to weigh the importance of different words in relation to each other. This mimics our own innate ability to understand dependencies in language, where the meaning of a word often depends on its context within the broader sentence or paragraph.
These architectural features elevate transformer-based models far beyond simple statistical probability calculations. They can understand context over long ranges, capturing dependencies between words that are far apart in a sentence. This ability allows them to disambiguate words with multiple meanings based on their surrounding context, a task that often challenges simpler language models.
Here’s an example of the result of the attention mechanism when a certain sentence is run through a GPT model. Notice how the ambiguous pronoun “it” is strongly correlated with “The animal” and not “the street”, even though “the street” comes closer. This shows how transformers are able to learn dependencies between different words in a sentence irregardless of their location in the text.
Transformer models can generate text that maintains coherence and logical flow over extended passages, a feat that requires understanding of both local and global context. They're capable of performing tasks that demand comprehension of implicit information, such as answering complex questions or summarizing lengthy texts. These abilities stem from their capacity to engage with the nuances and intricacies of natural language in a way that more closely mimics human understanding.
In a future article, we’ll go more in depth about the technical aspects of transformer architectures that endow them with these capabilities. But at a high-level, all you need to know is transformers consider relationships between all words in a sequence, allowing the model to capture both local patterns and long-range dependencies, thereby enabling them to comprehend language in a similar fashion to humans.
In some ways, machine learning models learn very similarly to how humans do. For a lot of the tasks we’ve learned to do proficiently in our lives, we were never taught explicit rules or instructions on how to do them—they were picked up through trial and error. The same can largely be said about machine learning models like LLMs.
Learning through error is fundamental to how LLMs develop their capabilities. During training, the model makes predictions about what token should come next in a sequence, compares its prediction to the actual correct answer in the training data, and adjusts its internal parameters based on how wrong it was.
We call the difference between the expected and actual outcomes (in other words, the calculated “error”) the loss of the model. The general goal of any machine learning model, LLMs included, is to minimize loss as much as possible.
The process of updating internal parameters to reduce loss, known as backpropagation, is similar to how humans learn from mistakes. When we make an error, our brain registers the difference between what we expected and what actually happened, helping us adjust our future behavior. For LLMs, this happens billions of times during training, with each iteration slightly refining the model's understanding.
Backpropagation determines how much each parameter contributed to the loss. But how do these models determine how much to adjust each parameter to minimize loss? That’s where another process, stochastic2 gradient descent (or SGD), comes into play. SGD enables a model to (literally) take small steps in the direction that reduces its prediction errors. The size of the steps is a critical factor—too big of steps can lead us to overshoot our adjustments and can accidentally increase errors, while too small of steps can lead us to never actually minimize the loss.
Here’s a visualization of what SGD is actually doing. We calculate the gradient3 of the loss function (J(w) in this example) to determine in which direction, and by how much, we need to update the parameters of the model to minimize the loss.
Now we know how models learn through errors, but what are the models being trained on during the learning process?
LLMs don’t just memorize a dictionary or a set of grammar rules. Instead, they learn language by training on massive datasets—so large that they’re almost incomprehensible in scale. These datasets contain text from websites, books, news articles, academic papers, social media conversations, code repositories, and countless other sources.
For context, while a human might read hundreds of books in their lifetime, modern LLMs train on the equivalent of millions or even billions of books worth of text. This training data spans multiple languages, disciplines, and time periods, giving the models exposure to everything from scientific papers to poetry, from technical documentation to casual conversations.
This sheer size gives the model a vast amount of information to learn from and ensures that it can replicate the many ways people use language. The diversity of the training data is crucial—by seeing how language is used in formal academic writing, casual social media posts, technical documentation, creative fiction, and everything in between, the model can understand context-specific language, like technical jargon, cultural references, and idiomatic expressions. As a result, LLMs develop the ability to adapt their responses to different contexts and styles, mimicking the diversity found in human communication.
In cognitive science, we often find overlaps between human cognition and machine intelligence, and we can draw interesting parallels between how humans and LLMs learn language.
While there's no definitive answer to how humans learn language, we are remarkably adept at pattern recognition and mimicry. These abilities are hypothesized to form the foundation of our language learning process.4
Our brains employ mechanisms like Hebbian learning (“neurons that fire together, wire together”), which help us recognize and reproduce patterns in speech and behavior. When a child hears the same lexical or grammatical patterns repeatedly, neural connections strengthen, making those patterns easier to recognize and reproduce. This is somewhat analogous to how LLMs adjust their parameters through repeated exposure to patterns in their training data.
It is remarkable how children are able acquire complex grammatical rules without explicit instruction. A three-year-old who has never heard of “past participles” or “subordinate clauses” can use them correctly in speech. They absorb these rules naturally through exposure and interaction, learning from context rather than formal instruction.5
Likewise, LLMs are never explicitly taught grammatical rules, or what makes up human language. That would be inherently counterintuitive, since human language emerged organically, with grammatical rules being descriptive observations of existing patterns rather than prescriptive rules that shaped the language itself. Just as linguists developed grammatical rules by observing and describing patterns in how people naturally communicate, LLMs learn language patterns through observation of actual usage rather than through prescribed rules.
TL;DR: modern LLMs use transformer architectures that can understand complex linguistic relationships through self-attention mechanisms. They learn through error-based training on massive datasets (billions of books worth), adjusting their parameters through backpropagation and stochastic gradient descent to minimize prediction errors. LLMs learn language similarly to humans—through pattern recognition and exposure rather than explicit grammatical rules.
We now have a solid grasp on how LLMs learn and reproduce language. There’s still something missing for a holistic understanding of how LLMs work, though: what are LLMs actually learning? Yes, we know that they are learning language, but what does it mean to “understand” language?
In the next article, we’ll dig deeper into the linguistic implications of LLMs to truly comprehend how LLMs produce such uncanny human-like text.
"Stochastic" means the model learns from random small batches of data rather than the entire dataset at once, making training more efficient and helping the model generalize better.
A gradient is a vector that points in the direction of the steepest increase in a function.
Check out “Early language acquisition: cracking the speech code” written by Patricia K. Kuhl for a deep dive into how babies learn statistical associations from ambient language.
This observation has important implications for language education—it's often why traditional second-language teaching methods, which focus heavily on explicit grammar rules, can be less effective than immersion-based approaches that mirror natural language acquisition.
No posts

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.