
Learn to create and manage Hugging Face access tokens, copy and save them, and request model access for Llama models, then download and quantize models from onslaught for use.
Explore how quantization reduces model size by lowering parameter precision from 32-bit to 4-bit, cutting memory usage while noting a slight performance trade-off.
Create a Colab notebook, install transformers, datasets, bits and bytes, TRL, DPO, and LoRA tools, then log into the Hugging Face hub to access models and tokenizers.
Download model tokenizer and set up eight-bit quantization with bits and bytes, using auto model for causal lm and auto tokenizer; use llama 3.21b and compare instruct and base models.
Explore how base models differ from instruct models, and learn how to fine-tune both using chat templates, tokenizers, and instruction methods for accurate responses.
Download the docker nl comments dataset from Hugging Face, load it with the datasets library, and split into train and validation using train_test_split with 0.2 test size and seed 42.
Prepare and format your dataset for fine tuning using a chat template. Align system, user, and assistant messages with model-specific tokens and tokenizers.
Apply the chat template to the full dataset and tokenize the text into input ids and attention masks, then create a tokenized data set for model fine-tuning.
The lecture explains how a data collator pads sequences to uniform length within each batch, and why padding is left-aligned for decoder models, using practical examples.
Discover how LoRA enables parameter-efficient fine-tuning by adding small trainable matrices to a model. Train only a fraction of weights and merge them with the original weights for efficient adaptation.
Integrate LoRa matrices into a llama model with the Peft library for parameter efficient fine tuning. Adjust rank and alpha, set target modules, and observe trainable parameter reductions.
Set and configure training arguments and hyperparameters for supervised LLM fine-tuning using the TRL library, including batch sizes, evaluation, saving, learning rate, gradient accumulation, and reporting.
Set up a supervised trainer with model, train and eval datasets, args, data collator, and tokenizer; start training and track losses and checkpoints every 20 steps up to 60.
Merge eight-bit quantized model weights with 32-bit Laura adapters using the Peft library, then prepare and deploy the final model for Huggingface.
Upload your fine-tuned model to Hugging Face and push both the model and tokenizer to the hub, then download or run it locally in Colab using the examples.
Explore how temperature, top p, top k, do sample, and repetition penalty guide output selection and tuning.
Integrate custom tokens into the base model's tokenizer, create a chat template, and prepare data for efficient processing using a four-bit quantized Mistral base model.
Add custom tokens to the tokenizer, including system, user, assistant, and pad tokens, then resize model embeddings to match the expanded tokenizer size.
Define a new chat template using the tokenizer's begin and end of sentence tokens, then integrate system, user, and model messages with data into a formatted dataset for consistent fine-tuning.
Unpack direct preference optimization (DPO) and its required data format—prompt, chosen, and rejected columns—showing how tokenization and a data collator prepare the human-like DPO dataset for fine-tuning.
Download Quinn 2.5b model with 1.5 billion parameters and enable eight-bit quantization. The DPO data collator pads the prompt on the left and chosen and rejected columns on the right.
Prepare the dataset for dpo by formatting prompt, chosen, and rejected columns into a chat template with system and assistant messages, ready for fine-tuning.
Integrate LoRA matrices into an eight-bit model by configuring rank 32 and alpha 32, targeting attention and MLP layers (q projection, k projection), training ~37 million (2.33%) with Getpath model.
Configure dpo training arguments with the dpo config and trl, detailing output directory, batch size, max steps, learning rate, scheduler, optimizer, warm up steps, logging, beta, and reference model alignment.
Train a model with the DPO trainer, set model and reference, prepare the formatted dataset and tokenizer, then merge trained LoRA adapters with the base model and push to hub.
Explore how thinking models perform chain-of-thought reasoning using think tags, tokens, and a final answer, as demonstrated with deep seq models.
Explore group relative policy optimization (grpo), its reward function driven training with multiple model responses, normalization, and log-probability adjustments to steer learning while controlling deviations via kl divergence.
Train a reinforcement learning setup with gRPC that generates multiple outputs per prompt and uses reward signals to optimize the model, using Onslaught AI and VLM to improve speed.
Examine the OpenAI grade school math dataset, convert questions to prompts, extract numeric answers after hashtags, and prepare a training workflow using load_dataset and a main English train split.
Explore how to extract specific data with regex and group operations and design multiple reward functions for reinforcement learning, using think tag, pattern matching, and text extraction.
Learn how to format model outputs for reward functions, including nested responses and chat template formats, and design prompts that enforce exact answers with text and units.
Write and test a reward function that processes completions, extracts the numeric answer, compares it to the dataset value, and uses a for loop to validate the 'answer equals' pattern.
Design a second reward function from a template that prompts thinking inside think tags, then provides the answer, using pattern matching and regex to reward the process and output.
Design a third reward function that rewards longer or bounded reasoning length, using character-based length ranges and token-aware adjustments, with examples and patterns.
Define the fourth reward function, the explanation length reward, by measuring final answer length with a flexible pattern around the think tag, and prepare training arguments.
Tune training parameters with a GRPO config, covering batch size, gradient accumulation, num generations, token-based length limits, learning rate, steps, and FP16 options for efficient training and inference.
Configure a GRP trainer with the model and tokenizer as a processing class, define four reward functions, set training args and dataset, then start training and assess results.
Review rewards across reward functions and examine four sample outputs to observe how formatting, length, and prompts influence rewards as the model trains over steps.
In this course, you will step into the world of Large Language Models (LLMs) and learn both fundamental and advanced end-to-end optimization methods. You’ll begin with the SFT (Supervised Fine-Tuning) approach, where you’ll discover how to properly prepare your data and create customized datasets using tokenizers and data collators through practical examples. During the SFT process, you’ll learn the key techniques for making large models lighter and more efficient with LoRA (Low-Rank Adaptation) and quantization, and explore step by step how to integrate them into your projects.
After solidifying the basics of SFT, we will move on to DPO (Direct Preference Optimization). DPO allows you to obtain user-focused results by directly reflecting user feedback in the model. You’ll learn how to format your data for this method, how to design a reward mechanism, and how to share models trained on popular platforms such as Hugging Face. Additionally, you’ll gain a deeper understanding of how data collators work in DPO processes, learning practical techniques for preparing and transforming datasets in various scenarios.
The most significant phase of the course is GRPO (Group Relative Policy Optimization), which has been gaining popularity for producing strong results. With GRPO, you will learn methods to optimize model behavior not only at the individual level but also within communities or across different user groups. This makes it more systematic and effective for large language models to serve diverse audiences or purposes. In this course, you’ll learn the fundamental principles of GRPO, and then solidify your knowledge by applying this technique with real-world datasets.
Throughout the training, we will cover key topics—LoRA, quantization, SFT, DPO, and especially GRPO—together, supporting each topic with project-oriented applications. By the end of this course, you will be fully equipped to manage every stage with confidence, from end-to-end data preparation to fine-tuning and group-based policy optimization. Developing modern and competitive LLM solutions that focus on both performance and user satisfaction in your own projects will become much easier.