Learn / Lessons

Hugging Face, Unsloth and friends

Where do all these models come from? And what are people doing with them? Today: where models come from. Say hello to the Hugging Face Hub. It hosts models,

Chapters

  1. 0:00Introduction
  2. 0:05Where this fits: The AI stack
  3. 0:09Hugging Face: The big library
  4. 0:17Go there: Find a model
  5. 0:30A model repo: What's inside
  6. 0:47Getting one: Two commands
  7. 1:05Fine-tuning: Teach it your thing
  8. 1:20Unsloth: Train and run locally
  9. 1:40The friends: Who else is about?
  10. 1:56Wrap up
Read the transcript

Introduction

Where do all these models come from? And what are people doing with them?

Where this fits: The AI stack

Today: where models come from.

Hugging Face: The big library

Say hello to the Hugging Face Hub. It hosts models, datasets, and Spaces, which are apps you can try.

Go there: Find a model

In a web browser, go to huggingface.co, and open Models. Search by name or by job, and open a model's page. Many models download without signing in. Gated ones need an account.

A model repo: What's inside

Each model lives in a repository, with versions. You'll often find a model card, settings, a tokenizer, and the weights: tensors, which are blocks of numbers, often stored as safetensors. Unlike Python's pickle, that holds no code.

Getting one: Two commands

To get the HF tool, type this in a Terminal: pip install -U huggingface_hub. Then one command downloads a model, here a small old one called GPT-2. It's saved in a folder called the cache. To chat with a model, you still need a model server.

pip install -U huggingface_hub
hf download gpt2

Fine-tuning: Teach it your thing

Fine tuning teaches a model from your examples. Retraining everything is costly. So LoRA freezes the original model, and trains a small add on instead. QLoRA also shrinks the base to 4 bits.

Unsloth: Train and run locally

Unsloth is an open project for running and training models on your own hardware. It supports LoRA and QLoRA, and can export to formats such as GGUF. The project claims big speed and memory savings, so test that on your own job. It also publishes a guide for the DGX Spark.

The friends: Who else is about?

Axolotl and LLaMA Factory are other open fine tuning tools. ModelScope is another model platform. Ollama has its own model library. And NVIDIA's NGC catalog offers containers and models.

Wrap up

Browse, read the card, check the licence, and try it.

Sources

More lessons