Big-picture understanding of modern LMs

Pretraining vs fine-tuning vs prompting

You can think of modern language models as big pattern machines. The three main ways we use and adapt them are pretraining, fine-tuning, and in-context prompting.

Pretraining: how a model like me first learns

Pretraining is the long, expensive phase where a model first learns general language patterns.

Mechanism:

  1. Start with random weights.
  2. Feed in huge amounts of text (books, code, webpages, forums, docs).
  3. Task: predict the next token given previous tokens.
  4. Compute loss = how wrong the prediction was.
  5. Backpropagate gradients, update weights.
  6. Repeat billions of times.

Over time, the model internalizes:

  • Grammar and vocabulary.
  • World facts seen in data.
  • Common reasoning patterns that show up in text.
  • Code patterns, math tricks, etc.

For a model like me:

  • Pretraining is where I picked up my general ability to speak, reason, and write across many topics.
  • I wasn’t told “this is sentiment analysis” or “this is Python” explicitly; I saw tons of examples and absorbed patterns.

Tiny runnable analogy (in PyTorch-like pseudocode):

pythonfor batch in data_loader: # billions of tokens total tokens = batch["tokens"][:-1] targets = batch["tokens"][1:] logits = model(tokens) loss = cross_entropy(logits, targets) loss.backward() optimizer.step() optimizer.zero_grad()

That loop, scaled up massively (large model, massive data, many GPUs), is the heart of pretraining.

Fine-tuning: nudging a pretrained model for a narrower job

Fine-tuning starts from a pretrained model and keeps training it on much more specific data.

Mechanism:

  1. Take pretrained weights (the “general brain”).
  2. Prepare a task-focused dataset:
    • Chat-style: user: ... assistant: ...
    • Code completion: prompt -> code
    • Classification: text -> label
  3. Keep training, but:
    • On fewer examples.
    • Often with a smaller learning rate.
  4. The model shifts to do especially well on those patterns.

For a model like me:

  • I likely went through instruction-style fine-tuning:
    • Lots of instruction → helpful answer pairs.
    • Maybe safety-oriented data: “What’s a safe reply here?”
  • This is why I answer instructions helpfully, instead of just copying internet text.

Concrete mini-example: fine-tuning for summarization

pythonfor doc, summary in summarize_dataset: inputs = tokenizer(doc + "\n\nSummary:") targets = tokenizer(summary) logits = model(inputs) loss = cross_entropy(logits, targets) loss.backward() optimizer.step() optimizer.zero_grad()

Same core training loop, but now all the examples are “document → summary,” so the model becomes very good at that task.

In-context prompting: steering at runtime

In-context prompting doesn’t change weights at all.
You just change the input text.

Mechanism for a model like me when you send a prompt:

  1. You send a text prompt: maybe with examples, instructions, constraints.
  2. I tokenize that prompt to numbers.
  3. I run the transformer forward pass over those tokens.
  4. I sample or choose likely next tokens.
  5. I repeat to generate an answer.

No gradient updates. No new weights. Just:

  • “Given this text so far, what’s the most likely continuation that follows the patterns I learned during pretraining + fine-tuning?”

This is why:

  • The same model can do Q&A, brainstorming, SQL generation, and explanations.
  • You just change how you frame the task in text.

Few-shot in-context example:

Your prompt to me might look like:

textTask: classify sentiment as Positive or Negative. Example: Text: I loved this movie Label: Positive Example: Text: This was boring and slow Label: Negative Now you: Text: The food was good but the service was terrible Label:

I see:

  • The pattern “Text: ... Label: Positive/Negative”.
  • I continue the pattern by producing one of those labels.

Weights don’t change; the context guides my behavior.

If you can change the wording, add examples, or structure input better, try prompting first. Use fine-tuning only when prompting alone can’t get stable, reliable behavior.

How they relate for my own behavior

For “me” as a model, these three stack:

  • Pretraining gave me general language and world knowledge.
  • Fine-tuning taught me to respond to instructions helpfully and safely.
  • Prompting from you, right now, tells me:
    • Focus on one LM topic.
    • Use Markdown.
    • Use a warm, concrete voice.
    • Avoid certain styles.

All three are necessary for what you’re experiencing.

1 / 4