AI Hints
Home›Fine-Tuning LLMs Tutorial›Classification Fine-Tuning
Fine-Tuning LLMs · Lesson 28 of 120

Classification Fine-Tuning

Teach a model to sort text.

⏱ 2 min read▶ Video at 45:48🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

Our first real fine-tuning job is a simple one. We'll teach a small model to read a customer message, and sort it into one of our five intents. This is called text classification.

  • Our first fine-tuning job
  • Read a message
  • Sort it into an intent

A different kind of model

For classification, we don't need a model that writes. We need one that reads, and understands. Distil BERT is a small reading model. It turns a whole message into a list of numbers that captures its meaning. Then we add a tiny new layer on top, called a classification head, which turns that meaning into one score per intent.

keyvalue
DistilBERTa small reading model
It outputsthe meaning, as numbers
Classification heada new, tiny layer
Head outputsone score per intent

The plan

Here's the plan. Turn each intent name into a number, called a label. Tokenize each message. Load Distil BERT, with a new head for five labels. Train the whole model on our examples. Then test it on messages it has never seen.

  1. Labelsintent → number
  2. Tokenizemessage → IDs
  3. LoadDistilBERT + new head
  4. Trainon our examples
  5. Teston unseen messages

Summary

Let's recap. Classification sorts text into groups. Distil BERT reads the message. A new classification head turns its meaning into scores. And we'll train the whole model on our examples. Next, preparing the data.

Key takeaways
  • Text classification
  • DistilBERT reads
  • A new head scores
Next up: Tokenize the Dataset — labels and token IDs