Skip to main content

Chapter 1: What Are LLMs?

Imagine you're typing on your phone, and before even finishing a sentence, your phone suggests the next word. You type "I'm running late for." and your phone readily suggests "work," "dinner," or "the meeting." This everyday technology that saves seconds from your day is actually a window into one of the most significant developments in artificial intelligence: Large Language Models, or LLMs.


Auto Complete

LLMs are like autocomplete on steroids. While your phone's autocomplete may provide some words in anticipation that are pulled from your recent messages and trending phrases, LLMs are working with an entirely different order of knowledge and sophistication. They're like having an autocomplete function that's read nearly everything human beings have ever written and can predict not just the next word, but entire paragraphs, stories, code, and intricate explanations.


From Basic Autocomplete to AI Powerhouses


To understand LLMs, start with something you know. When you type "I am hungry" on your phone, the autocomplete function might suggest "for pizza" or "let's eat" based on patterns it has learned from your previous messages or overall text patterns. This works because the system has learned that certain words come after others.


Now consider doing this on a vastly larger scale. Instead of training on just your text messages or a small corpus of catchphrases, imagine an autocomplete system that has trained on millions of books, web pages, articles, and conversations. Imagine that it is able to consider not just the last few words you've typed, but entire paragraphs of context in which to make its predictions.


This is roughly what an LLM does. When you are typing "I am feeling." to an LLM, it doesn't just read the final three words. It reads the entire conversation, the context you've provided, patterns from millions of similar conversations it was trained on, and then predicts the next item. The response might be "overwhelmed by all the information I'm trying to process" or "excited about this new project" or any one of a number of contextually appropriate responses.


Takeaway: LLMs are really sophisticated autocomplete systems that can consider immense amounts of context to make predictions, far more than regular autocomplete can handle. For instance, while your phone might suggest the word "pizza" after "I want," an LLM can create an entire reflective response about food cravings based on your conversation history.


Understanding Models as Pattern Machines


Before we proceed, let's clarify what we mean by "model." An LLM is akin to a system that gets better at predicting what's next by learning how words and phrases prefer to group together in sentences. This system does not see words like we do but is actually very good at predicting what should come next based on these patterns.


LLMs learn by being trained on huge amounts of text data-books, articles, websites, and more-in order to find patterns in language. Language models work by recognizing these patterns in text. They learn that certain words frequently appear together, that questions typically start with certain words, that formal writing takes on different patterns than everyday conversation, and thousands of other linguistic patterns that humans use naturally but rarely think about explicitly.


The "Large" in Large Language Models is a nod to the scale of this pattern recognition. We're discussing models trained on billions-sometimes trillions-of words from diverse sources. This vast dataset allows them to discover incredibly subtle patterns about how language works in different contexts.


Takeaway: LLMs are recognition systems based on patterns that learn from huge amounts of text data to predict which words need to come next in any given context. Think of a writing assistant that has read millions of books and not only can predict the next word, but also the optimum style and tone for your specific request.


The Power of Context and Prediction


This is where LLMs get really interesting: when you type text into an LLM, it doesn't take wild stabs at what you might mean-it predicts the next most likely word in a string of text based on patterns it's found in millions of texts. Context, like what you've typed already, has a big impact on that prediction.


These predictions aren't random-they're based on the patterns the model encountered during training. If the model has encountered phrases like "I am hungry for pizza" or "I am hungry for something sweet" a million times in its training data, it learns that these are normal and probable patterns.


Context Gradation

But the thing that makes LLMs powerful is that they're extremely capable of context-awareness-that is, they take all of the text you've typed in thus far and use that to craft suitable responses. So, for example, "I am hungry" would have a different response if you're coming home late from work or deciding what to eat after a big meal.


It's this contextual awareness that allows LLMs to chat, produce coherent essays, and help with multi-step tasks rather than simply predicting individual words.


Takeaway: Context is everything-LLMs make far more accurate and applicable predictions based on the whole picture of what you've written. That's why "What should I cook?" gets a generic response, but "I'm tired after work and have chicken and rice at home-what should I cook?" gets a far more helpful one.


Beyond Simple Prediction


While the autocomplete analogy is helpful for understanding the mechanism behind it, LLMs can do far more than complete sentences-they infer your intent, keep conversational threads consistent, and even vary their tone based on the tone of your request.


It's all done through the same fundamental process: predicting what text is most likely to come next based on patterns in vast training data.


While LLMs can give incredibly accurate responses, they are not without their limitations. For one, they sometimes "hallucinate"-give information that is not true with certainty. This is because they don't actually have knowledge of the world and their predictions are based on patterns they've seen in their training data. For instance, if you ask an LLM for the capital of a country that is poorly represented in its training data, it will give you the incorrect answer with confidence. They can also be poor at very niche topics that were poorly covered in their training data. Understanding these limitations is as important as understanding their capabilities.


Why This Matters for Prompt Engineering


It is helpful to consider LLMs as sophisticated prediction machines if you want to work successfully with them. When you craft prompts-the questions or instructions that you give to an LLM-you are really designing the context upon which the model will make its predictions.


Keep this in mind: if you're aware that an LLM is trying to guess the most probable and appropriate response based on the context you provide it with, you can frame your prompts in a way to direct those guesses in your preferred manner.


For example, if you require a formal business email, you can start your prompt with "Please write a professional email to." rather than "Write an email." The former provides context that increases the probability of formal linguistic structures.


If you would prefer a step-by-step explanation, you might include phrases like "Please explain step by step" or provide an example of your preferred structure. You are not creating strict rules for the LLM to follow-you are influencing the probability distribution of its predictions.


This also accounts for some of the quirks you will see in interacting with LLMs. They will, on occasion, give different responses to the same question, or their response will go astray in longer conversations. This is because they are always predicting from local context, and small differences in context can change their predictions.


Takeaway: LLMs work by predicting what's next given context-understanding this allows you to craft effective prompts and have appropriate expectations of what they're capable of doing. Just as understanding a car engine makes you a better driver, understanding LLM prediction makes you a more effective prompt engineer.


The Foundation for Everything That Follows


This predictive, pattern-based nature of LLMs is the foundation of everything else you will learn about prompt engineering. Whether you are trying to get better creative writing, more accurate analysis, clearer explanations, or more consistent code generation, you are fundamentally running this prediction engine.


The art and science of prompt engineering involve understanding how to provide context, structure, and guidance that will steer the LLM's predictions toward your target outcomes. By learning the predictive nature of LLMs, you will know how to make good prompts-ones that are contextualized and set up to get the desired response you want. It is not a matter of ordering the model to do this or that-it is a matter of setting up conditions such that the most likely prediction is what you want.


The journey from knowing what LLMs are to knowing how to properly operate with them starts here: they're not rule-following machines, but very sophisticated pattern-recognizing systems that are great at predicting what must come next in any given context.


Now that you know how LLMs predict text, you're ready to learn how to guide these predictions to do precisely what you want. In the next chapter, we'll break down the nitty-gritty specifics on how to turn this knowledge into crafting specific, effective prompts. You'll learn how subtle variations in wording, format, and context can dramatically improve your results with an LLM.



Comments

Popular posts from this blog

Chapter 4: Evaluate and Iterate

  Chapter 4: Evaluate and Iterate You've learned to structure clear prompts using the TIP framework—defining your Task, providing necessary Information, and specifying your desired Product. That's the foundation. But effective prompt engineers don't expect perfection on the first try—they iterate,  just like how we take several photos from different angles before picking the best one. This chapter will teach you how to systematically evaluate outputs and refine your prompts to get consistently better results. Why Outputs Vary: The Probabilistic Nature of LLMs Remember the autocomplete analogy from Chapter 1? LLMs make probabilistic predictions—they don't pick the single "correct" next word, but calculate probabilities for thousands of options and sample from those possibilities. This means even identical prompts might yield slightly different responses. One time an LLM might say "Remote work has revolutionized workplace dynamics," another time ...

Chapter 2: What is Prompt Engineering?

For most of computer history, people had to speak the machine’s language to get anything done. We had to adapt to computers—not the other way around. But that’s changed. Now, you can achieve complex tasks just by telling the computer what you want—in plain English. This is one of the biggest leaps in how humans interact with technology since the graphical user interface. The Evolution of Human-Computer Communication To understand how we got here, let’s take a quick journey through how people have talked to computers—starting with the classic example: “Hello, World!” Back in the 1940s, programmers had to write in pure binary—long strings of ones and zeros. To make the computer display “Hello, World!” meant manually translating each letter into machine code. Then in the 1950s, assembly language arrived, giving us slightly easier commands like MOV and INT . They were more human-readable but still required  deep understanding of computer architecture. Later, high-level programming lan...