Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to Generative AI Notes
Topic #204

LLM Training

Training a modern LLM is a three-stage pipeline — each stage shapes a different aspect of the model's final behavior, and skipping a stage produces a genuinely different (and generally less useful) model.

The Three Stages

StageTrains OnProduces
PretrainingMassive raw text (web pages, books, code)A "base model" — fluent, knowledgeable, but not naturally good at following instructions
Instruction Tuning(instruction, ideal response) pairsA model that follows instructions and responds in a helpful format
AlignmentHuman preference data (which response is better)A model tuned to be more helpful, honest, and to refuse harmful requests

Why a Base Model Alone Isn't Enough

Prompt to a BASE model: "Explain photosynthesis"

Likely base model behavior: continues the text as if it were
scraped from the internet — might generate a list of similar
questions, or a Wikipedia-style continuation, rather than a
direct, well-formatted answer aimed at the person asking.

A base model is trained purely to predict plausible next tokens — it has no built-in notion of "this is a question I should directly answer helpfully." Instruction tuning is specifically what teaches that behavior.

Cost Reality

Pretraining is by far the most expensive stage — large compute clusters running for weeks, processing trillions of tokens. Instruction tuning and alignment use far smaller, curated datasets and require a fraction of the compute, which is why fine-tuning an existing base/instruction-tuned model is realistic for a company, while pretraining a model from scratch generally is not, outside a handful of well-resourced labs.

Practical Use Case

Understanding this pipeline clarifies what fine-tuning (see Fine-Tuning) actually does: it's almost always an additional, smaller-scale training step applied on top of an already pretrained-and-aligned model — not training a model from zero.

Common Mistakes

  • Assuming "training an LLM" always means pretraining from scratch — in practice, most teams that "train" a model are fine-tuning an existing one
  • Skipping alignment considerations when fine-tuning a base model directly — can reintroduce unhelpful or unsafe behaviors the original alignment stage addressed

Interview Relevance

"Walk me through how an LLM like a chat assistant is trained, end to end" — the three-stage pipeline above, explained in order with what each stage fixes, is exactly the expected answer.

Practice Question

Explain why a base model (pretrained only, no instruction tuning) would likely respond poorly to "Write a professional email declining a meeting."

Related Notes

Want to go beyond the notes?

Join CodingNow's Generative AI course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →