AI Hints
Home›Fine-Tuning LLMs Tutorial›When to Fine-Tune
Fine-Tuning LLMs · Lesson 6 of 120

The Tools: Transformers, PEFT, TRL

The Hugging Face toolkit.

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

In this course, we'll use free, open source tools, from a company called Hugging Face. They're the most popular tools for fine-tuning in the world. Let's meet each one.

  • Free and open source
  • From Hugging Face
  • The most popular toolkit

The toolkit

Here's how the tools fit together. At the bottom is PyTorch, which does the maths. On top of it, Transformers loads models, and tokenizers. Datasets loads, and prepares, our training data. PEFT adds memory saving methods, like LoRA. And TRL gives us ready made trainers, for fine-tuning language models.

  1. TRLtrainers for LLM fine-tuning
  2. PEFTLoRA and friends
  3. Datasetstraining data
  4. Transformersmodels and tokenizers
  5. PyTorchthe maths underneath

The Hugging Face Hub

Hugging Face also runs the Hub. It's a website, like a library, with over a million free models, and datasets. You can download a model with one line of code. And later, you can share your own fine-tuned model there too.

keyvalue
The Hubhuggingface.co
Modelsover a million
Datasetsfree to download
Shareyour own models too

Our models

We'll use small models, so everything runs on a normal laptop. Small LM two, with one hundred and thirty five million parameters, is our main language model. Distil BERT is a small model for sorting text into groups. And Qwen two point five, with half a billion parameters, will be our bigger model. The same code works on huge models, with a bigger computer.

keyvalue
SmolLM2-135Mour main LLM
DistilBERTfor classification
Qwen2.5-0.5Ba bigger model
Same codeworks on huge models

Summary

Let's recap. Transformers loads models. Datasets prepares data. PEFT adds LoRA. And TRL trains language models. We'll use small models, so it all runs on a laptop. Next, let's set everything up.

Key takeaways
  • Transformers + Datasets
  • PEFT + TRL
  • Small models, same code
Next up: Setting Up — install and check