Concepts / Fine-Tuning Large Language Models with Human Feedback

Fine-Tuning Large Language Models with Human Feedback

Fine-tuning is the step that comes after pretraining, and it is where the model starts to be aimed at real work.

  • Programming

Why a Pretrained Model Is Not Yet Finished

Imagine you have built a language model that has already gone through the earlier work of this course. It can produce fluent text, but it has not been shaped for any particular job. Ask it to sort customer emails into categories, or to answer a specific question about a product, and it has no particular reason to do either task well. The practical question this article asks is simple: once a pretrained model exists, how do you turn it into one that performs a specific job?

The answer this course gives is fine-tuning. Fine-tuning is the step that comes after pretraining, and it is where the model starts to be aimed at real work. The source describes it as adjusting the pretrained model so that it follows instructions for named tasks. Keep the starting point in mind as you read the rest of the article, because fine-tuning does not begin from an empty model. It begins from a pretrained one.

Transformers and Their Alternatives

Most of the language models that a learner meets first are built on the transformer architecture, the design used by GPT-style models. The source makes a point that is easy to miss: this design is one successful choice, not a requirement. It describes a group of experimental LLM architectures that are not based on the transformer. The word experimental here describes architectures that are less popular and are still being explored by researchers. It does not mean the models are unreliable or unused.

The diagram below places the transformer group and the experimental group side by side under the general heading of LLM architectures. The transformer appears as one design, and the three named experimental models appear as members of a second group. Read the diagram as a classification aid, not a ranking. The transformer is not the root of the tree, and the experimental group is not a lesser branch. Both groups are two answers to the same question of how to build an LLM.

What the Three Experimental Names Signal

The source names three experimental designs: RWKV, Hyena Hierarchy, and Mamba. Each reference is a 2023 paper, and each title carries a clue about the core idea. Reading the names as clues is a useful habit, because the name tells you where to look inside the design. The source does not explain the internals in this section, so the clues below are orientation only and should be confirmed against the paper before you rely on any detail.

  • RWKV: the title points toward recurrent ideas, designs in which information is carried forward step by step through a sequence.
  • Hyena Hierarchy: the title points toward convolutional ideas, designs that process a sequence using convolution-style operations.
  • Mamba: the title points toward state-space ideas, designs that describe a sequence through a changing internal state.

Following the Supporting References

The rest of this section is a reading path. Each reference points to a source that explains a term used elsewhere in the material, and each one contributes a different piece to the picture of GPT-style models and their training. Follow the path in order and track what each reference adds. The three entries below show how the references connect to GPT-style models.

Where Fine-Tuning Sits in the Build

The course builds an LLM in stages, and the third stage is the one this article covers. In that stage, the course takes a pretrained LLM and fine-tunes it for specific work. Read the sentence as a sequence: the pretrained model comes first, and fine-tuning is applied to it afterward. The diagram below shows that order as a flow of data from the pretrained model, through the fine-tuning step, to a model ready for specific tasks.

Definition

Fine-tuning: adjusting a pretrained LLM so that it follows instructions for named tasks. Its starting object is a pretrained LLM, the action is adjustment, and its purpose is specific tasks.

The two halves of that definition are worth separating. The first half names the starting object and the action performed on it. The second half names the purpose. A learner who keeps both halves in mind is less likely to confuse fine-tuning with building a model from nothing.

Tracing a Model Through Fine-Tuning

Worked example

A pretrained model learns to sort customer emails

A pretrained LLM can produce fluent text but has not been shaped for any particular job. Trace what happens when it is fine-tuned for the job of sorting customer emails into categories.

  1. 1
    Start with the pretrained model

    The model already exists and can produce fluent text. It has no particular reason to sort emails well, because it has not been shaped for that job.

  2. 2
    Apply the fine-tuning step

    Fine-tuning takes the pretrained model as its starting point and adjusts it so that it follows instructions for the named task, here sorting customer emails.

  3. 3
    Check the output

    The result is a model aimed at the specific job. Its starting point was the pretrained model, and its purpose is now the named task rather than general fluent text.

Result

The model that comes out of fine-tuning is the same kind of object as the one that went in, but it has been adjusted for email sorting. It did not start from an empty model.

Pretrained and Fine-Tuned Models Compared

The easiest way to separate a pretrained LLM from a fine-tuned LLM is to ask two questions: where did this model start, and what is it for? The diagram below shows the same model before and after fine-tuning. In the before group, the pretrained model is the end point of earlier work, aimed at fluent text in general. In the after group, the fine-tuned model is produced from the pretrained model and is aimed at specific tasks.

QuestionPretrained LLMFine-tuned LLM
Starting pointEarlier pretraining workA pretrained LLM
ActionBuilt during pretrainingAdjusted by fine-tuning
PurposeFluent text in generalFollowing instructions for specific tasks

Starting point and purpose separate a pretrained model from a fine-tuned one.

Vectors, Embeddings, and Latent Spaces

A vector representation is an ordered list of numbers. Each position in the list is a slot, and the whole list stands for one item. The diagram below shows a short vector with four slots. The values in the slots are placeholders, not real data, and the slots are read from left to right by their position.

Embedding spaces and latent spaces are related concepts that the source points to a chapter of its book to explore. This section does not define either term, so treat the following as general orientation rather than a summary of the source. An embedding is a vector representation of an item, and a latent space is the collection of such vectors that a model works within. In this sense, a vector is the basic unit, an embedding is one kind of vector representation, and a latent space is the wider space those vectors live in.

Matching Practical Problems to Task Families

The source names two example tasks for a fine-tuned model: answering queries and classifying texts. It also explains why they matter: they are among the most common tasks in real-world applications and in research. The two tasks ask different things of the model. Answering a query asks the model to produce a response to a question. Classifying a text asks the model to assign an input to a category. Both are ways of following an instruction, which is the behavior the fine-tuning stage aims to build.

What do you think happens?

Sorting incoming customer emails into categories belongs to which task family?

  • Answering queries

  • Classifying texts

Reveal answer
Answer:

Classifying texts

Sorting assigns each email to a category, which is what the source describes as classifying a text. Answering a query would instead mean producing a response to a question.

Task familyWhat the model is asked to doExample problem
Answering queriesProduce a response to a questionAnswer a specific question about a product
Classifying textsAssign an input to a categorySort customer emails into categories

Two task families and a practical problem that matches each.

Mistakes That Blur These Ideas

  • Common mistake

    Treating fine-tuning as building a model from an empty starting point

    Why it fails

    Fine-tuning begins from the pretrained model rather than from an empty one.

    Do this instead

    Name the starting object first: a pretrained LLM, then the adjustment, then the purpose of specific tasks.

  • Common mistake

    Reading the word experimental as meaning unreliable or unused

    Why it fails

    In this section, experimental describes architectures that are less popular and not based on the transformer.

    Do this instead

    Read experimental as an alternative design that researchers are still exploring.

  • Common mistake

    Assuming every LLM must share the transformer design

    Why it fails

    The source uses the experimental architectures to show that LLMs need not all share that design.

    Do this instead

    Treat the transformer as one successful design among several.

  • Common mistake

    Treating the architecture titles as confirmed technical details

    Why it fails

    The titles are clues to the core idea, and the source asks readers to confirm them against the paper.

    Do this instead

    Use the titles as orientation and check the paper before relying on any detail.

  • Common mistake

    Using embedding space and latent space as if this section defines them

    Why it fails

    The source says they are related concepts and points to a book chapter for them.

    Do this instead

    Keep the general orientation separate from the source definitions, and consult the referenced chapter.

Practice Sorting Problems into Task Families

EASY

For each problem below, decide whether it belongs to answering queries or classifying texts, and state the starting point and purpose of the model you would use. Problem A: a model must respond to a shopper who asks whether a product is in stock. Problem B: a model must label each support ticket as billing, technical, or other. Problem C: a model must explain a term from a product manual when a user asks what it means.

Hints
  • Ask whether the model must produce a response to a question, or assign an input to a category.
  • Problem C asks for a response to a question, even though it is about a manual rather than a shopper.
  • The starting point of any of these models is a pretrained LLM, and its purpose is the named task.

Key Takeaways

  • The transformer is one successful LLM architecture, and the source shows that experimental designs such as RWKV, Hyena Hierarchy, and Mamba are alternatives that are not based on it.
  • Fine-tuning is the stage that comes after pretraining in the course's build. It adjusts a pretrained LLM so that it follows instructions for specific tasks, and it does not begin from an empty model.
  • A pretrained LLM is defined by its earlier pretraining starting point and its general fluent-text purpose, while a fine-tuned LLM starts from a pretrained model and is aimed at specific tasks.
  • The two example fine-tuning task families are answering queries and classifying texts, and a practical problem belongs to one of them depending on whether it asks for a response or an assignment to a category.
  • A vector is an ordered list of numbers, while embedding spaces and latent spaces are related terms that this section points to a chapter to define.

Related concepts

More concepts starting with F