Finetune LLMs to teach them ANYTHING with Huggingface and Pytorch | Step-by-step tutorial

Neural Breakdown with AVB October 15, 2024
Video Thumbnail

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

Loading...
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

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

(22)
$423.35
FREE delivery Oct 8 - 10
Loading...
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

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

(12,968)
$39.55
FREE delivery Tue, Jun 17
Loading...
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

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

(1,131)
$45.98
FREE delivery Sun, Aug 24
100+ bought in past month
Loading...
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

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

(3,362)
$39.32
FREE delivery Tue, Jun 17
Loading...
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

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

(52)
$13.99
FREE delivery Sun, Aug 24 on your first order
100+ bought in past month
Loading...
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
Best Seller

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

(17,871)
$27.98$22.38
FREE delivery Tue, Oct 14 on your first order
500+ bought in past month
Loading...
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

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

(35,879)
$49.99$44.99
FREE delivery Mon, Jan 26
1K+ bought in past month
Loading...
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 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

(11,639)
$23.99
FREE delivery Sat, Jun 14 on your first order
1K+ bought in past month
Loading...
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

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

(698)
$39.99
FREE delivery Wed, Mar 4
1K+ bought in past month
Loading...
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

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

(13)
$309.99$297.59
FREE delivery Tue, Oct 7
200+ bought in past month
Loading...
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]

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]

(16)
$569.99
FREE delivery Sun, Jun 22
Loading...
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

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

(123)
$454.99
FREE delivery Tue, Jun 17
Loading...
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 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

(77,138)
$379.99
FREE delivery Tue, Jun 17
100+ bought in past month
Loading...
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

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

(35,424)
$359.99
FREE delivery Tue, Jun 17
Loading...
Google Pixel Buds Pro 2 - Noise Canceling Earbuds - Up to 31 Hour Battery Life with Charging Case - Bluetooth Headphones - Compatible with Android - Hazel

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

(183)
199.99
PrimeFREE delivery Saturday, June 14
400+ bought in past month
Loading...
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)
Best Seller

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)

(78)
$6.99
FREE delivery Fri, Sep 5 on your first order
1K+ bought in past month
Loading...
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

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

(213)
$12.99
FREE delivery Sat, Jun 14 on your first order
100+ bought in past month
Loading...
Magnetic Nasal Strips Starter Kit: Comfortable Nasal Breathing Support for Sleep, Helps Reduce Snoring Noise, Includes 60 Tabs (30 Uses) with 4 Sizes

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

(40)
$17.99
FREE delivery Wed, Mar 18 on your first orderOnly 7 left in stock.
1K+ bought in past month
Loading...
Environet Hydroponic Growing Kit, Self-Watering Mason Jar Herb Garden Starter Kit Indoor, Windowsill Herb Garden, Grow Your Own Herbs from Organic Seeds (Basil)

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

(786)
$69.15$33.51
FREE delivery Jun 13 - 17
Loading...
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

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

(0)
$30.99
FREE delivery Jun 19 - Jul 3
Loading...
Bonsai Starter Kit – 1x Bonsai Tree | Complete Indoor Starter Kit for Growing Plants with Bonsai Seeds, Tools & Planters – Gardening Gifts for Women & Men
Best Seller

Bonsai Starter Kit – 1x Bonsai Tree | Complete Indoor Starter Kit for Growing Plants with Bonsai Seeds, Tools & Planters – Gardening Gifts for Women & Men

(243)
$19.99
FREE delivery Sat, Jun 14 on your first order
300+ bought in past month