Recommended resources
The freely available resources this lesson will direct you to.
Introduction
Over the past several lessons, we have constructed a solid foundation for understanding Large Language Models. We began with the Transformer architecture and the self-attention mechanism, moved through the massive pre-training process, and then explored how models are aligned with human intent through Supervised Fine-Tuning and Reinforcement Learning from Human Feedback (RLHF). As we concluded in our discussion of RLHF, even these sophisticated alignment techniques cannot create a flawless model.
This lesson marks the culmination of our foundational module. Here, we pivot from how LLMs are built to a critical examination of what they can and cannot do. Your goal is to identify the key capabilities and, more importantly, the inherent limitations of current models. Understanding these boundaries—including hallucinations, context window constraints, and reasoning failures—is not an academic exercise. For an experienced software professional like yourself, this knowledge is the bedrock for effectively using AI in developer workflows and, crucially, for designing robust, reliable AI-powered features.
The Fundamental Limits: A Theoretical Ceiling
It is tempting to view the current shortcomings of LLMs as mere engineering challenges that will be solved with more data, compute, and architectural tweaks. However, a growing body of research suggests that some of these limitations are fundamental, arising from the very mathematical principles upon which these models are based.
A recent paper outlines five such limitations, arguing they are as intrinsic to LLMs as the impossibility of a perpetual motion machine is to physics.

We will focus on the three most critical limitations for your goals: hallucination, context window constraints (or context compression), and reasoning boundaries.
1. Hallucination: The Inevitability of Fabrication
The term "hallucination" refers to an LLM generating text that is plausible-sounding but factually incorrect, nonsensical, or disconnected from the provided context. It is perhaps the most well-known and consequential failure mode.
To start, let's get a clear definition and see some examples of different types of hallucinations.
Why Large Language Models Hallucinate
This IBM Technology video provides a concise and clear introduction to the concept of LLM hallucinations, categorizing them in a way that is easy to grasp.
Watch the first two sections of the video, from the beginning to what a hallucination is. Pay attention to the four categories presented: sentence contradiction, prompt contradiction, factual contradiction, and nonsensical information.
Why Do Hallucinations Happen?
The video you just watched hints at several causes. Let's formalize them, combining practical observations with the deeper theoretical underpinning.
Why Large Language Models Hallucinate
The same video now explains some of the primary reasons for these hallucinations.
Please watch the next segment from why they happen. Note the three main causes discussed: data quality, the generation method itself, and the input context.
As the video explains, hallucinations can be traced back to:
- Data Quality: Models are trained on vast, unfiltered internet text, which is rife with errors, biases, and contradictions. The model learns to replicate these imperfections.
- Generation Method: The probabilistic nature of token generation involves a trade-off. Optimizing for fluency and coherence can sometimes come at the cost of factual accuracy. A model may favor a word that creates a natural-sounding sentence, even if that word renders the statement false.
- Input Context: Ambiguous or insufficient prompts can lead the model down an incorrect path.
However, there is a more profound reason. Some researchers argue that hallucinations are a mathematically guaranteed outcome of how LLMs work.
The Five Fundamental Limitations of LLMs at Scale - The Turning Mind
This article from The Turning Mind digs into the theoretical inevitability of hallucinations and discusses their practical product implications.
Read the section titled "1. Hallucination". Focus on the core argument that hallucination is not just a training flaw but a guaranteed failure mode, and note the mitigation strategies mentioned, such as Retrieval-Augmented Generation (RAG).
The key takeaway is that for any given model, there will always exist inputs that cause it to fail. No amount of scaling or fine-tuning can completely eliminate this. This has significant implications for you as a builder: you cannot assume an LLM will be truthful. Systems built with LLMs must include mechanisms for verification, citation, or operate in low-stakes domains where falsehoods are tolerable. We will explore one such mechanism, RAG, in a later module.
2. Context Window Constraints: More Than Just Size
The context window is the LLM's working memory. It defines the amount of information (both input and output, measured in tokens) the model can consider at any one time. While context windows have expanded dramatically, from a few thousand to over a million tokens, this raw number hides crucial limitations.
The following video provides an excellent primer on what a context window is, how it's measured in tokens, and the surprising challenges that come with making it larger.
What is a Context Window? Unlocking LLM Secrets
This IBM Technology video breaks down the concept of the context window, tokenization, and the non-obvious problems associated with very large context windows.
Please watch the entire video from start to finish. As you watch, pay close attention to: The definition of the context window as working memory. The explanation of tokens and tokenization. The challenges of large context windows, especially the quadratic scaling of compute and the performance degradation known as the "lost in the middle" problem.
The video highlights several critical points for a system designer:
- Quadratic Complexity: The self-attention mechanism, which you'll recall from our first lesson, has a computational cost that scales quadratically () with the sequence length (number of tokens). Doubling the context window size quadruples the processing power required, making extremely large contexts expensive and slow.
- Performance Degradation: Bigger is not always better. Research shows that models tend to pay more attention to information at the very beginning and very end of a long context, often ignoring or misinterpreting crucial details "lost in the middle."
- Security Risks: A longer context provides a larger "attack surface" for malicious prompts designed to jailbreak the model or subvert its safety filters.
This "lost in the middle" phenomenon is a symptom of a more fundamental issue the LINK article calls "Context Compression."
The Five Fundamental Limitations of LLMs at Scale - The Turning Mind
This section explains why an LLM's effective context is much smaller than its nominal context window.
Now, read the section "2. Context Compression". This will connect the practical issues from the video to the underlying architectural limitations.
The attention mechanism, despite its power, causes information to blur and dilute over long distances. This means that simply providing a massive document to an LLM does not guarantee it will be able to use all the information effectively. As a developer, this implies you must be strategic, placing key instructions at the start or end of a prompt and breaking down tasks that require large contexts into smaller, more manageable chunks—a theme we will return to in the next module on prompting.
3. Reasoning Boundaries: Pattern Matchers, Not Logicians
Perhaps the most subtle but profound limitation is that of reasoning. LLMs excel at recognizing and completing patterns learned from their training data. However, their training objective—next-token prediction—is fundamentally different from genuine logical reasoning, which involves abstraction, deduction, and hypothesis testing.
The Five Fundamental Limitations of LLMs at Scale - The Turning Mind
This final reading selection addresses the core mismatch between an LLM's training and the act of reasoning.
Please read the section titled "3. Reasoning Degradation". Focus on the distinction between pattern completion and genuine inference.
As the article argues, LLMs are "language machines, not reasoning machines." They generate plausible-sounding text, but this can break down when faced with novel problems that require multi-step logical deduction rather than recalling a familiar pattern. This limitation is directly relevant to your goal of using AI in complex developer workflows.
How These Limitations Manifest in Software Engineering
These theoretical limits are not just abstract concerns; they manifest as concrete, often frustrating, failures in day-to-day software engineering tasks. A recent study observed developers using ChatGPT for a web development project and systematically categorized the types of failures they encountered.
Should I Give Up Now?” Investigating LLM Pitfalls in Software ... - arXiv
This research paper provides a taxonomy of LLM failure modes specifically within a software development context. It offers a powerful bridge between the fundamental limitations we've discussed and their real-world impact.
First, read section 4. RQ1: Failures during ChatGPT Interaction, focusing on Table 5, which summarizes the failures. This table lists nine distinct failure types grouped into three categories. Next, read section 5. RQ2: Contributing Mechanisms of the Failures Observed, paying close attention to Table 6. This table details the causes, separating them into "User Miscommunication" and "ChatGPT’s Technical Limitations."
Let's connect these documented failures back to the fundamental limitations:
- Incomplete or Incorrect Responses (F1, F3, F7): An "erroneous answer" (F7) is a direct example of a hallucination. An "incomplete answer" (F1) or "missing preconditions" (F3) often stems from a failure in reasoning—the model follows a familiar pattern for code generation but fails to logically deduce all the necessary components or setup steps for the specific request.
- Cognitive Overload (F2, F4): An "overcomplicated answer" (F4) is another symptom of weak reasoning. The model provides a complex solution it has seen before, rather than reasoning from first principles to find the simplest effective approach. An "overwhelming answer" (F2) that regenerates the entire codebase instead of making a small edit shows a failure to manage context and reason about the user's specific intent.
- Context Loss & Redundant Effort (F5, F6, F9): "Lacks context" (F5) is a classic manifestation of context window constraints and the "lost in the middle" problem. The model forgets earlier parts of the conversation. "Unresponsive to prompt changes" (F9), where the model gets stuck in a loop, also points to poor context tracking and an inability to reason its way out of a repetitive pattern.
This study validates that even as models improve, these core interactional breakdowns persist because they are tied to the fundamental limitations of the technology. Understanding this allows you to anticipate these failures and develop strategies to mitigate them, which is the entire goal of prompt engineering and agentic system design.
Conclusion
In this final lesson of our foundational module, we've established a realistic perspective on the capabilities of modern LLMs. While powerful, they are constrained by deep, inherent limitations.
Here are your key takeaways:
- Hallucinations are Inevitable: Models are mathematically guaranteed to generate plausible but false information. This necessitates a "trust but verify" approach and designing systems with human oversight or external verification (like RAG).
- Context Windows are Deceptive: The effective context is smaller than the advertised size due to computational costs and performance degradation ("lost in the middle"). This requires you to be strategic in how you present information to the model.
- LLMs are Pattern Matchers, Not Reasoners: Their ability to solve complex, multi-step logical problems is brittle. They excel at recalling and adapting familiar patterns, not at true symbolic reasoning.
- Limitations Impact Practice: These theoretical limits directly cause the common failures seen in AI-assisted software development, such as incomplete code, context loss, and overcomplicated solutions.
By understanding these boundaries, you are now perfectly positioned to move from theory to application. You know the machine's weaknesses. The next module, Advanced Prompting Techniques, is all about the art of working around these weaknesses. You will learn how to structure your instructions, provide examples, and guide the model's "thinking" process to elicit more reliable and useful outputs.