Finetune LLMs to teach them ANYTHING with Huggingface and Pytorch | Step-by-step tutorial
About
No channel description available.
Video Description
This in-depth tutorial is about fine-tuning LLMs locally with Huggingface Transformers and Pytorch. We use Meta's new Llama-3.2-1B-Instruct model and teach it to predict paper categories using LORA adapters. Along the way I break down all the major things you must know about fine-tuning, from prompting, creating datasets, generating input-output pairs, loss functions, pytorch optimizers, peft LORA adapters, and ofcourse the sweet feeling when the test accuracy goes up. :) Follow on Twitter: https://x.com/neural_avb You can study Finetuning, LORA, and LLM training on Paper Breakdown. It's a study platform I am building where the LLM will generate your study goals for each paper, answer your question instantly, highlight sections directly into the PDF, write code, and draw flowcharts and block diagrams for you. How to Train Long Context Models: https://paperbreakdown.com/abs/2410.02660 LORA: https://www.paperbreakdown.com/abs/2106.09685 QLORA: https://www.paperbreakdown.com/abs/2305.14314 Instruction Tuning: https://www.paperbreakdown.com/abs/2304.03277 All the notebooks, datasets, and python code used in this video have been uploaded to my Patreon: https://www.patreon.com/NeuralBreakdownwithAVB I upload all the code, slides, animations, write-ups etc for all my videos on my Patreon, so go check it out if you find anything interesting. Videos you might like: Llama3.2 Multimodal Application - https://youtu.be/QLUKXvHgOrI Apple Intelligence LLM Breakdown - https://youtu.be/Sah0dnu8Hxo 50 concepts to know NLP: https://youtu.be/uocYQH0cWTs Attention to Transformers playlist: https://www.youtube.com/playlist?list=PLGXWtN1HUjPfq0MSqD5dX8V7Gx5ow4QYW Notes on Hardware and Quantization: I didn't go over quantization in this video, coz I'm on a Macbook and bitsandbytes don't work outside NVIDIA gpus. :) Hopefully, I'll make a separate video one day about quantization. The system I am using is a MacBook Pro M2 16GB ram. If you have nvidia gpus, you could leverage better quantization. For my machine, I was able to train with batch size of 8 in float32… the sequence lengths were around 250 on average for this task. If I were working on a product, I’d rent cloud gpu servers and fine tune over there on large datasets. For a YT video with an educational intent, I decided to limit the scope to local machines. #ai #deeplearning #machinelearning 0:00 - Intro 2:04 - Huggingface Transformers Basics 4:49 - Tokenizers 8:39 - Instruction Prompts and Chat Templates 12:35 - Dataset creation 15:54 - Next word prediction 20:52 - Loss functions on sequences 28:28 - Complete finetuning with Pytorch 31:38 - LORA Finetuning with PEFT 35:38 - Results
Master LLM Fine-Tuning: Essentials Within Reach
AI-recommended products based on this video

Seasonic Focus V4 GX-1000 (ATX3) - 1000W - 80+ Gold - ATX 3.0 & PCIe 5.1 Ready -Full-Modular -ATX Form Factor -Premium Japanese Capacitor -10 Year Warranty -Nvidia RTX 30/40 Super & AMD GPU Compatible

tomtoc 360° Protective Laptop Sleeve for 15-inch MacBook Air M4/A3241 2025, M3/A3114 2024, M2/A2941 2023, 15-inch MacBook Pro A1990 A1707, Dell XPS 15 Plus Laptop, Water-Resistant Computer Case Bag Global Recycled Standard

Replacement for Dell 130W Laptop Charger USB C - XPS 17 15 7590 9700 9500 9510 Precision 5560 3560 5540 5570 5550 3561 3550 5510 5520 Latitude 7410 7310 7210 Type C Computer AC Adapter Power Cord

MOSISO 360 Protective Laptop Bag 15 inch, 15 inch Computer Shoulder Bag Compatible with MacBook Air 15 M4 M3 M2 2025-2023, Dell XPS 15, Side Open Messenger Case &4 Zipper Pockets&Handle, Black Global Recycled Standard

45W 65W AC Adapter Laptop Charger for Dell Inspiron 15 14 13 17 3000 5000 7000 Series 5558 5559 Charger Latitude E6440 E6430 3520 3420 XPS 13 14 9333 9350 Notebook Dell Computer Power Supply Cord

Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black

Logitech G305 Lightspeed Wireless Gaming Mouse, Hero 12K Sensor, 12,000 DPI, Lightweight, 6 Programmable Buttons, 250h Battery Life, On-Board Memory, PC/Mac - Black

Anker 332 USB-C Hub (5-in-1) with 4K HDMI Display, 5Gbps - and 2 5Gbps USB-A Data Ports and for MacBook Pro, MacBook Air, Dell XPS, Lenovo Thinkpad, HP Laptops and More

Anker Nano USB C Wall Charger,45W Fast Charging Smart Display Charger,with 180°Foldable Plug,Smart Recognition,Built-in Care Mode,for iPhone17/16/15 (Non-Battery,One USB-C Port,No Cable Included) ClimatePartner certified

Dell 27 Plus 4K Monitor - S2725QS - 27-inch 4K (3840 x 2160) 120Hz 16:9 Display, IPS Panel, AMD FreeSync Premium, sRGB 99%, Integrated Speakers, 1500:1 Contrast Ratio, Comfortview Plus - Ash White
![SanDisk Professional 4TB PRO-G40 SSD - Up to 3000MB/s, Thunderbolt 3 (40Gbps), USB-C (10Gbps), IP68 dust/Water Resistance, External Solid State Drive - SDPS31H-004T-GBC1D [exFAT Version]](https://m.media-amazon.com/images/I/619s92YP6ML._AC_UL960_FMwebp_QL65_.jpg)
SanDisk Professional 4TB PRO-G40 SSD - Up to 3000MB/s, Thunderbolt 3 (40Gbps), USB-C (10Gbps), IP68 dust/Water Resistance, External Solid State Drive - SDPS31H-004T-GBC1D [exFAT Version]

4TB SanDisk Creator Pro Portable SSD - Up to 2000MB/s - USB-C, USB 3.2 Gen 2x2, IP65 Water and Dust Resistance - External Solid State Drive - SDSSDE81C-4T00-G25

SanDisk 4TB Extreme Portable SSD - Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware - External Solid State Drive - SDSSDE61-4T00-G25

SanDisk Ultra 3D NAND 4TB Internal SSD - SATA III 6 Gb/s, 2.5 Inch /7 mm, Up to 560 MB/s - SDSSDH3-4T00-G26

Google Pixel Buds Pro 2 - Noise Canceling Earbuds - Up to 31 Hour Battery Life with Charging Case - Bluetooth Headphones - Compatible with Android - Hazel

Deeyaple USB C to Aux, 4FT/1.2M, Type C to 3.5mm Audio Cable Headphone Jack Cable for Car Mobile Phone, iPhone 16 15, iPad Pro, Samsung Galaxy S24 S23 S2010, Google Pixel,Oneplus Grey (1)

Car Carplay Woven Cable for iPhone 16 15 3.3FT USB A to USB C 3.2 Gen 2 Carplay Adapter Wire for iPhone 16 15 Pro Max, iPad Pro/Air, Samsung Galaxy S25/S24/S23/S22/S21 Google Pixel, Car Charger Cable

Magnetic Nasal Strips Starter Kit: Comfortable Nasal Breathing Support for Sleep, Helps Reduce Snoring Noise, Includes 60 Tabs (30 Uses) with 4 Sizes

Environet Hydroponic Growing Kit, Self-Watering Mason Jar Herb Garden Starter Kit Indoor, Windowsill Herb Garden, Grow Your Own Herbs from Organic Seeds (Basil)

Herb Garden Planter Indoor Kit 21Pcs Kitchen Herb Garden Starter Kit Growing Kit Including Wooden Box Burlap Pots Soil Discs Gardening Tools Unique Easter Birthday Christmas Gift Ideas for Women Mom




