# What Is Pretraining?

> What pretraining is, why it is so costly, what a base model can and cannot do, explained simply for your AI interview.

**In short:** Pretraining is the first, huge training run, in which a model learns language by predicting the next word in a vast pile of unlabelled text. The result is a base model, which is then fine-tuned, meaning trained further on a smaller set of examples, for real jobs.

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

## Say it in 30 seconds

Pretraining is the first, big training run. The model reads a huge amount of text that nobody labelled, and it learns by guessing the next word, again and again. The result is a base model. It knows language well, but it doesn't follow orders yet. Google's course says you probably will never train an LLM from scratch, so you start from a base model, then add your own data and tests.

## Say it in 2 minutes

Pretraining is the first stage of building a language model, and it is very expensive. The model reads a huge amount of text that nobody has labelled. It is shown a sentence with the next word hidden, guesses it, and adjusts itself when it is wrong. Repeat that over an enormous pile of text, and the model picks up grammar, style and a lot of general knowledge.

I think of it like a new analyst at a bank. Before touching a real customer file, they read years of policy documents, filings and manuals. That reading gives them the basics of the job, but it does not teach them this month's refund rules. In an AI product, a base model from pretraining can write clear English, yet it has never seen the bank's own fee table.

So the usual next step is fine-tuning. We train the base model further on examples of good answers. Fine-tuning and RLHF then refine it to be more useful as an assistant. Google's course says training an industrial-strength LLM requires enormous amounts of ML expertise, computational resources, and time.

For the bank's support bot, I would not pretrain. I would start from a good base or chat model, keep the fee table in a search the bot reads at answer time, and test the answers against real tickets.

## What is pretraining, in plain words?

Pretraining is the first big training run of a language model. Before the model can answer questions or follow instructions, it learns the basics of language from a huge amount of text.

Nobody labels that text, and there is no answer key. The task is simple: hide the next word, guess it, check the guess, and nudge the model so the next guess is a little better. Because the text comes from the world, the model picks up grammar, style and general facts along the way.

The analogy I use is a new analyst at a bank. Before touching a real customer file, they read years of policy documents, filings and manuals. That reading gives them the basics of the job. It does not teach them this month's refund rules. A real AI case works the same way: a base model from pretraining can write clear English, but it has never seen the bank's own fee table.

- **Pretraining:** The first, big training run on a huge pile of text, with no labels.
- **Base model:** What pretraining produces: good with language, not yet good at following orders.
- **Unlabelled text:** Text with no answer key attached, such as web pages and books.
- **Next-word prediction:** The simple task the model practises: guess the next word, check it, adjust.

## How does pretraining work, step by step?

The loop is simple. The scale is what makes it hard.

1. **Gather the text:** Collect a very large amount of text. Google's course says this training text is typically somewhat filtered.
2. **Hide the next word:** Show the model some text and ask it to guess what comes next.
3. **Score the guess:** Compare the guess with the real word. A wrong guess counts as an error the model must reduce.
4. **Adjust and repeat:** Nudge the model's numbers, its weights, the numbers inside the model, so the error is smaller next time. Keep going for a very long run.

*Diagram, From raw text to an assistant: Raw text goes into pretraining, which yields a base model. Fine-tuning and RLHF then refine it to be more useful as an assistant. The first step needs no labels, which is why the text can be so large.*
1. Huge piles of text go in, with no labels attached.
2. The model guesses each next word, and adjusts when it is wrong.
3. The base model is then fine-tuned on examples of good answers.
4. The result is an assistant that follows instructions.

Here is a tiny version of the first idea. It counts which word follows which, and it adjusts no weights, so it is not real training.

```python
# A tiny version of next-word prediction: count which word follows which.
# Real models learn these patterns with a neural network, from far more text.
from collections import Counter, defaultdict

corpus = [
    "the refund is sent within five working days",
    "the refund is not sent to closed accounts",
    "the fee is waived for premium accounts",
    "the fee is charged on late payment",
    "the card is blocked after three wrong pins",
]

counts = defaultdict(Counter)
for line in corpus:
    words = line.split()
    for word, nxt in zip(words, words[1:]):
        counts[word][nxt] += 1

for word in ["the", "refund", "fee"]:
    best, n = counts[word].most_common(1)[0]
    total = sum(counts[word].values())
    print(f"after '{word}': most likely '{best}' ({n} of {total})")
```

Output:

```text
after 'the': most likely 'refund' (2 of 5)
after 'refund': most likely 'is' (2 of 2)
after 'fee': most likely 'is' (2 of 2)
```

Google's course calls this first phase unsupervised learning, meaning learning with no answer key. Some setups hide words in the middle of the text and ask the model to fill them in. BERT, a 2018 paper, is built to pre-train on unlabelled text by reading the context on both sides of a word.

Research from 2020 found that the loss, a score for how wrong the model is, falls in a steady pattern as the model, the data and the compute grow.

## Why is pretraining so costly, and who actually does it?

Pretraining needs a huge amount of text, a large set of computers running for a long time, and specialist skill. Google's course tells learners that they will probably never train an LLM from scratch.

> "Pretraining is the initial process of training language models on a large unlabeled corpus of text" (Anthropic glossary)
>
> "You probably will never train an LLM from scratch." (Google, LLM course)
>
> "first we train a transformer model on a very large amount of data in an unsupervised manner" (OpenAI, 2018)

OpenAI's 2018 post on this approach said its pre-training step was expensive, about one month on 8 GPUs, the chips that do this maths.

- **Costly: Pretrain from scratch.** Huge data, a long run and expert staff. Google's course says learners probably never will train one.
- **Practical: Start from a base model.** Someone else already did the big run. You add your data and tests on top.

## What does pretraining give a model, and what does it miss?

Take a mid-size bank's support bot, built on a base model. A customer asks what the premium card charges for a late payment. The bot writes a clear, polite reply, and that part comes from pretraining. But the reply quotes a fee from a different card's public page, because the bank's own fee table was never in its training.

Pretraining gives the model language and general knowledge. It does not give the model your bank's current rules, and general knowledge can be old or thin for your case. The fix is to let the bot read the live fee table when it answers. The cost is a search index to run and a set of real customer questions to test against.

*Diagram, What pretraining gives, and what it misses: Pretraining gives the model its language and general knowledge. The bank's live fee table is missing from it, so the bot searches that table before it answers. The answer then quotes the table, not memory.*
1. Pretraining gave the model its language and its general knowledge.
2. The bot searches the bank's own fee table when the question arrives.
3. The answer is built from the table it just found, not from memory.

### How would you decide whether your team needs pretraining?

1. **Test a base or chat model first:** Run it on about 200 real support tickets and mark each answer right or wrong.
2. **Name the gap:** Wrong facts point to retrieval, because the model needs the current documents. Wrong tone or format points to fine-tuning. Neither points to pretraining.
3. **Weigh the cost last:** Pretraining means a long, costly run with its own team and risk. A fee table is never a reason to start a pretraining run.

> **Tip:** Say the order out loud: test, find the gap, then pick the fix. That sounds like a plan to an interviewer.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: a big first training run on unlabelled text that teaches the model language.
- [ ] The task: predict the next word, check the guess, adjust.
- [ ] The output: a base model, which still needs fine-tuning to follow orders.
- [ ] Why it is costly: data, computing power, time and specialists.
- [ ] Google's course says you probably will never train an LLM from scratch, so start from a base model.
- [ ] Where it stops: general knowledge, not your private rules or this month's changes.

**Common traps**

- Trap: "The model was trained on our data, so it knows our policies." Better: Pretraining is a general training run. Your rules come from retrieval or fine-tuning, plus tests.
- Trap: "Pretraining is just fine-tuning with more data." Better: Pretraining is the big first run on unlabelled text. Fine-tuning is a smaller, later run on examples.
- Trap: "A bigger pretraining run always makes a better product." Better: Model quality helps, but the product also needs good data, retrieval and tests.

## Can you spot the mistake?

**Spot the mistake:** Which of these claims about pretraining is wrong?

A. Pretraining learns from a huge amount of unlabelled text.
B. The training task is to predict the next word.
C. Its output is a base model that follows orders out of the box.
D. Fine-tuning refines a pretrained model using additional data.

**Answer:** C. A base model is good with language but not inherently good at following instructions. Fine-tuning and RLHF then refine it to be more useful as an assistant.

**Quick check:** A bank wants its bot to follow this month's refund rules. What is the best first move?

A. Start a new pretraining run on the bank's documents
B. Put the current rules in a searchable source the bot reads at answer time
C. Raise the temperature so the bot guesses better
D. Wait for the next model release

**Answer:** B. Rules change every month, and a pretraining run is too slow and costly to follow them. A search over the current documents keeps each answer tied to today's rule. Temperature only changes how randomly the model picks words.

## Can you answer these from memory?

**Flash cards**

- **What is pretraining?** The first big training run: the model learns language from huge unlabelled text by predicting words.
- **What does it produce?** A base model: good with language, not yet good at following instructions.
- **What task does it train on?** Predicting the next word, then adjusting when the guess is wrong.
- **How is it different from fine-tuning?** Pretraining is the big first run on unlabelled text. Fine-tuning is a smaller, later run on examples.
- **Is it cheap?** No. It needs huge data, lots of computing power, time and specialist staff.
- **Does it teach your private rules?** No. Those come from retrieval, fine-tuning and tests, not the pretraining run.

## Likely follow-up questions

- Q016 Pretraining vs fine-tuning vs instruction tuning? https://designervenkat.online/interview/ai/pretraining-vs-fine-tuning-vs-instruction-tuning
- Q017 Base model vs chat/instruct model? https://designervenkat.online/interview/ai/base-model-vs-chat-instruct-model
- Q018 What are parameters (weights)? https://designervenkat.online/interview/ai/what-are-parameters-weights
- Q019 What are scaling laws? https://designervenkat.online/interview/ai/what-are-scaling-laws
- Q020 What is compute-optimal (Chinchilla-style) training? (full answer coming)

## Learn it in depth

- [Fine-tuning](https://designervenkat.online/learn/ai-engineering/fine-tuning)
- [RAG vs Fine-tuning](https://designervenkat.online/learn/ai-engineering/rag-vs-fine-tuning)
- [Retrieval-augmented generation](https://designervenkat.online/learn/ai-engineering/rags)
