# What Is a Large Language Model?

> What an LLM is, how it writes one token at a time, how it is trained, and where it goes wrong, explained simply for your AI interview.

**In short:** A large language model (LLM) is an AI model with a very large number of parameters, trained on huge amounts of text to predict the next token. It writes one small piece at a time, so it can sound fluent while being wrong.

AI and LLM interview question Q001, LLM fundamentals. Beginner, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-a-large-language-model

## Say it in 30 seconds

A large language model is an AI model with a very large number of parameters, which are the numbers it learns during training. It is trained on huge amounts of text to predict the next token, a small piece of text such as a word or part of a word. It writes a reply one token at a time, so it can sound fluent and still be wrong. It predicts text and does not check facts on its own. So in a real product I give it the facts it needs, check its output, and keep the important decisions in code.

## Say it in 2 minutes

A large language model, or LLM, is a neural network, a type of software that learns patterns from examples, with a very large number of parameters. Parameters are the numbers the model adjusts during training. Google's definition is short: at a minimum, a language model with a very high number of parameters. More informally, Google's glossary uses the term for any Transformer-based language model. A Transformer is a design that uses attention, a way of weighing which words matter most to each other.

Training works by prediction. The model reads a huge amount of text and repeatedly guesses the next token, which is a word or part of a word. Each wrong guess nudges the parameters a little. After a very large number of these nudges, it has learned grammar, facts about the world and patterns that look like reasoning, all stored in its parameters.

Writing is the same loop. Given your prompt, the model scores every possible next token, picks one, adds it to the text, and repeats. Its working memory for one conversation is the context window, the number of tokens it can read at once.

The limits follow from this design. Its knowledge comes from training and from whatever you put in the prompt, so it needs tools to look anything up live. Because it predicts plausible text, it can hallucinate, which means it states false things in a fluent, sure tone. In a real product I supply the facts, check the output and keep the decisions in code.

## What is a large language model, in plain words?

Picture a claims handler at an insurance company who has read thousands of policy wordings. Asked to finish a sentence in a customer letter, they write from the pattern of policy language they have absorbed. Most of the time it is right. Sometimes it sounds right and is wrong, because they remembered the pattern instead of checking the policy on file.

A large language model, or LLM, does the same thing with text. It has absorbed patterns from a very large amount of writing, and it predicts what comes next. Chat assistants such as Claude are built on this kind of model.

> "At a minimum, a language model having a very high number of parameters." (Google, machine learning glossary)
>
> "Large language models (LLMs) are AI language models with many parameters that are capable of performing a variety of surprisingly useful tasks." (Anthropic, glossary)

- **Parameter:** A number inside the model that training adjusts. A large model has a very great many of them.
- **Token:** A small piece of text the model reads or writes: a word, part of a word, or a single character.
- **Pretraining:** The first, general training pass on a huge pile of text.
- **Context window:** How many tokens the model can read at once. Its working memory for one conversation.

## How does an LLM write a reply, one token at a time?

An LLM does not write whole sentences in one go. It writes tokens. Google's crash course puts it simply: LLMs predict a token or sequence of tokens. A token can be a word, part of a word or a single character.

1. **Read the text so far:** Your prompt and the reply so far, cut into tokens.
2. **Score every next token:** The model gives each possible next token a chance of coming next.
3. **Pick one:** Pick one token from those chances. Temperature, a setting, controls how much the choice varies.
4. **Add it and repeat:** The new token joins the text, and the loop runs until the reply ends.

*Diagram, How one reply is built: How one reply is built. The model scores every possible next token, one is picked and added to the text, and the loop repeats until the reply stops.*
1. Your prompt and the reply so far are cut into tokens.
2. The model gives every possible next token a chance.
3. The chances across all the options add up to 100%.
4. The model takes one token, based on those chances.
5. The token joins the text, and the loop repeats until the reply ends.

Google's glossary adds that, more informally, the term covers any Transformer-based language model. The Transformer is a design "based solely on attention mechanisms": as it reads, each token weighs how much the other tokens in the text matter to it.

> **Tip:** Say the loop out loud: read, score, pick, add, repeat. It shows you know the mechanics, not just the buzzwords.

## How is an LLM trained?

Training has two big passes. The first is pretraining, the general step on a huge pile of text. The second is fine-tuning, which teaches a specific job or behaviour.

- **Pretraining: General language.** The model predicts the next token across a huge pile of text. This builds broad language skill.
- **Fine-tuning: One job, one style.** A second training run on examples of one task, such as answering questions in a chat format.

*Diagram, Two training passes: Two training passes. Pretraining teaches general language from a huge pile of text. Fine-tuning then teaches a job from examples. Chat assistants add further tuning, such as RLHF, on top.*
1. Pretraining reads a huge pile of text and predicts the next token.
2. Fine-tuning is a second pass on examples of one job.
3. The tuned model follows instructions in a chat, which pretraining alone does not teach well.

Pretrained models are not built to chat. Anthropic's glossary says they are not inherently good at answering questions or following instructions, which is why the second pass matters.

Chat assistants add further tuning. Anthropic's glossary says fine-tuning and RLHF are used to refine these pretrained models, making them more useful for a wide range of tasks.

## Why can a fluent answer still be wrong?

Because the model predicts plausible text, it can produce an answer that sounds sure and is false. The field has a name for this: hallucination.

> "The production of plausible-seeming but factually incorrect output by a generative AI model that purports to be making an assertion about the real world." (Google, machine learning glossary)

- **Known from training: Learned patterns.** Its knowledge sits in its parameters. It cannot check a fact against a source unless you give it one.
- **Given in the prompt: Working memory.** Anything you paste in sits in the context window. The model reads it as it writes.

Anthropic's glossary calls the context window the model's "working memory", separate from the data it was trained on. Answers can also change between runs: temperature is a setting that controls how random the model's picks are, and Anthropic notes that even at temperature 0 the results will not be fully deterministic.

Worked example. Here is a made-up claims letter at a home insurer. The model drafts a line about a burst pipe. The chances are invented for this example, and they favour a figure that is not in the policy on file. The model cannot tell the difference, so code checks the figure before the letter goes out.

```python
# A simplified claims-letter step. The chances are invented for this example, not from a real model.
POLICY = "Water damage from a sudden pipe burst is covered up to 18,000 dollars, after a 750 dollar excess."
NEXT_OPTIONS = [("25,000", 0.46), ("18,000", 0.31), ("10,000", 0.15), ("unlimited", 0.08)]

def pick_most_likely(options):
    # Greedy choice: always take the option with the highest chance.
    return max(options, key=lambda option: option[1])

amount, chance = pick_most_likely(NEXT_OPTIONS)
draft = "Your policy covers water damage from a burst pipe up to $" + amount + "."
print("Draft:", draft)
print("Chance of that pick:", chance)

def check_against_policy(figure):
    # Code, not the model, decides whether a figure is on file.
    if " " + figure + " " in " " + POLICY + " ":
        return "OK: " + figure + " is in the policy"
    return "HOLD: " + figure + " is not in the policy, send to a claims handler"

print(check_against_policy(amount))
```

Output:

```text
Draft: Your policy covers water damage from a burst pipe up to $25,000.
Chance of that pick: 0.46
HOLD: 25,000 is not in the policy, send to a claims handler
```

> **Tip:** In an interview, lead with the fix: the figure comes from the policy document that code retrieves, and a check in code blocks any figure that is not on file. It cannot tell whether a figure on file is used correctly, so the drafting step should also name the field it fills.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: a very large model that predicts the next token.
- [ ] Parameters and training: learned from huge text by predicting tokens.
- [ ] How a reply forms: one token at a time, from the text so far.
- [ ] Pretraining vs fine-tuning, and what each one adds.
- [ ] Hallucination and the context window as the two limits to plan for.
- [ ] Honest about variation: the same prompt can give different wording.

**Common traps**

- Trap: "An LLM looks the answer up in a database." Better: It predicts text from patterns in its parameters. It only reads what is in the context window or what a tool returns.
- Trap: "It understands things the way a person does." Better: Describe what it does: it predicts tokens well, and that can look like understanding. Do not overclaim.
- Trap: "A bigger model is always the better choice for my product." Better: Size is one choice. Cost, speed and the task decide it, so test candidates on your own examples.

## Can you spot the problem?

**Spot the problem:** A claims assistant drafts a customer letter. Which line is the risk?

A. The letter quotes the cover limit from the policy file that code retrieved.
B. The model writes the cover limit from its own guess, and nothing checks it.
C. A check in code compares every amount in the letter with the policy text.
D. A claims handler spot-checks a sample of letters each month.

**Answer:** B. The model guessed the figure, and nothing in code checked it against the policy. A wrong amount could reach a customer. Take figures from the document, and check them in code.

**Quick check:** What does a large language model do when it writes a reply?

A. It looks the answer up in a database first
B. It searches the internet for each reply
C. It predicts the next token, one at a time
D. It copies a passage from its training data

**Answer:** C. It predicts one token at a time from the text so far. It only looks things up when a tool or search you give it does that.

## Can you answer these from memory?

**Flash cards**

- **What is an LLM?** A model with very many parameters, trained on huge text to predict the next token.
- **What is a token?** A small piece of text: a word, part of a word, or a single character.
- **How does a reply form?** One token at a time. Each new token joins the text, and the loop repeats.
- **Pretraining vs fine-tuning?** Pretraining learns general language. Fine-tuning teaches one job or behaviour.
- **What is hallucination?** Confident, plausible output that is factually wrong, because the model predicts text.
- **What is a context window?** How many tokens the model can read at once: its working memory for one conversation.

## Likely follow-up questions

- Q002 What does "predict the next token" mean? https://designervenkat.online/interview/ai/what-does-predict-the-next-token-mean
- Q003 What is a token, and why not whole words? https://designervenkat.online/interview/ai/what-is-a-token
- Q008 What is a context window? https://designervenkat.online/interview/ai/what-is-a-context-window
- Q016 Pretraining vs fine-tuning vs instruction tuning? https://designervenkat.online/interview/ai/pretraining-vs-fine-tuning-vs-instruction-tuning
- Q023 What is a hallucination, and why does it happen? https://designervenkat.online/interview/ai/what-is-an-ai-hallucination
- Q043 What is self-attention? https://designervenkat.online/interview/ai/what-is-self-attention

## Learn it in depth

- [How LLMs Work](https://designervenkat.online/learn/ai-engineering/how-llms-work)
- [Tokens](https://designervenkat.online/learn/ai-engineering/tokens)
- [Transformers](https://designervenkat.online/learn/machine-learning/transformers)
