
{"id":3526,"date":"2024-10-24T19:26:39","date_gmt":"2024-10-24T11:26:39","guid":{"rendered":"https:\/\/infernews.com\/?p=3526"},"modified":"2024-10-24T19:26:41","modified_gmt":"2024-10-24T11:26:41","slug":"finetune-llm-like-a-pro","status":"publish","type":"post","link":"https:\/\/infernews.com\/blog\/finetune-llm-like-a-pro\/","title":{"rendered":"Finetune LLM like a Pro"},"content":{"rendered":"<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"lyte-wrapper\" title=\"Finetune LLMs to teach them ANYTHING with Huggingface and Pytorch | Step-by-step tutorial\" style=\"width:853px;max-width:100%;margin:5px auto;\"><div class=\"lyMe\" id=\"WYL_bZcKYiwtw1I\" itemprop=\"video\" itemscope itemtype=\"https:\/\/schema.org\/VideoObject\"><div><meta itemprop=\"thumbnailUrl\" content=\"https:\/\/infernews.com\/blog\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2FbZcKYiwtw1I%2Fhqdefault.jpg\" \/><meta itemprop=\"embedURL\" content=\"https:\/\/www.youtube.com\/embed\/bZcKYiwtw1I\" \/><meta itemprop=\"duration\" content=\"PT38M55S\" \/><meta itemprop=\"uploadDate\" content=\"2024-10-15T19:39:52Z\" \/><\/div><div id=\"lyte_bZcKYiwtw1I\" data-src=\"https:\/\/infernews.com\/blog\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2FbZcKYiwtw1I%2Fhqdefault.jpg\" class=\"pL\"><div class=\"tC\"><div class=\"tT\" itemprop=\"name\">Finetune LLMs to teach them ANYTHING with Huggingface and Pytorch | Step-by-step tutorial<\/div><\/div><div class=\"play\"><\/div><div class=\"ctrl\"><div class=\"Lctrl\"><\/div><div class=\"Rctrl\"><\/div><\/div><\/div><noscript><a href=\"https:\/\/youtu.be\/bZcKYiwtw1I\" rel=\"nofollow\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/infernews.com\/blog\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2FbZcKYiwtw1I%2F0.jpg\" alt=\"Finetune LLMs to teach them ANYTHING with Huggingface and Pytorch | Step-by-step tutorial\" width=\"853\" height=\"460\" \/><br \/>Watch this video on YouTube<\/a><\/noscript><meta itemprop=\"description\" content=\"This in-depth tutorial is about fine-tuning LLMs locally with Huggingface Transformers and Pytorch. We use Meta&#039;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&#039;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&#039;t go over quantization in this video, coz I&#039;m on a Macbook and bitsandbytes don&#039;t work outside NVIDIA gpus. :) Hopefully, I&#039;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\u2026 the sequence lengths were around 250 on average for this task. If I were working on a product, I\u2019d 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\"><\/div><\/div><div class=\"lL\" style=\"max-width:100%;width:853px;margin:5px auto;\"><\/div><figcaption><\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowvqSiDA:productID":"","footnotes":""},"categories":[27],"tags":[59],"class_list":["post-3526","post","type-post","status-publish","format-standard","hentry","category-paper","tag-llm"],"_links":{"self":[{"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/posts\/3526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/comments?post=3526"}],"version-history":[{"count":0,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/posts\/3526\/revisions"}],"wp:attachment":[{"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/media?parent=3526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/categories?post=3526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/tags?post=3526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}