← 开源
dvgodoy

FineTuningLLMs

Official repository of my book "A Hands-On Guide to Fine-Tuning LLMs with PyTorch and Hugging Face"

TutorialsLLM fundamentalsJupyter Notebook
在 GitHub 打开
增长势头
+124 小时新增 Star+0.1%
874
Star
120
Fork
+3
本周
1
贡献者
创建于 2024-08-15 · 更新于 2026-10-16 · 今日第 6115 名
主要开发者

dvgodoy/FineTuningLLMs 排名第 6,115,有 874 个星标。

同类别比较

dvgodoy/FineTuningLLMs 排名第 6,115,此处有 8 个同类条目;miguelgfierro/ai_projects 排名第 6,121。

同类别比较
名称排名指标
Ryota-Kawamura/Mathematics-for-Machine-Learning-and-Data-Science-Specialization6,089
语言:
Jupyter Notebook
星标数:
887
分叉数:
345
简介:
Master the Toolkit of AI and Machine Learning. Mathematics for Machine Learning and Data Science is a beginner-friendly Specialization where you’ll learn the fundamental mathematics toolkit of machine learning: calculus, linear algebra, statistics, and probability.
6551Team/claude-code-design-guide6,100
语言:
JavaScript
星标数:
880
分叉数:
279
boyboi86/AFML6,104
语言:
Jupyter Notebook
星标数:
879
分叉数:
205
简介:
All the answers for exercises from Advances in Financial Machine Learning by Dr Marco Lopez de Parodo.
limouren2000/llms-dev-study6,108
语言:
Jupyter Notebook
星标数:
878
分叉数:
72
简介:
小李的大模型应用开发学习路线,涵盖 RAG、Agent、面试八股与论文速读。
miguelgfierro/ai_projects6,121
语言:
Jupyter Notebook
星标数:
870
分叉数:
196
简介:
AI projects
optuna/optuna-examples6,127
语言:
Python
星标数:
865
分叉数:
200
简介:
Examples for https://github.com/optuna/optuna
PacktPublishing/30-Agents-Every-AI-Engineer-Must-Build6,131
语言:
Jupyter Notebook
星标数:
860
分叉数:
374
简介:
30 Agents Every AI Engineer Must Build, published by Packt
langchain-ai/deep-agents-from-scratch6,155
语言:
Jupyter Notebook
星标数:
848
分叉数:
333
关键参数与规格
关键参数与规格
参数值
语言Jupyter Notebook
类别Tutorials
子类别LLM fundamentals
关键词PEFT
星标数874
分叉数120
贡献者1
创建日期2024-08-15
更新日期2026-10-16
1 天星标数1
7 天星标数3
排名6,115
上次排名18,881
排名变化12,766
7 天星标排名7,178
上次 7 天星标排名8,487
7 天星标排名变化1,309
总星标排名12,388
上次总星标排名12,387
总星标排名变化-1
国家Portugal
README 摘录

A Hands-On Guide to Fine-Tuning LLMs with PyTorch and Hugging Face Kindle | Paperback | PDF [Leanpub] | PDF [Gumroad] Setup FAQ Appendix A - Setting Up Your GPU Pod Google Colab You can easily **load the notebooks directly from GitHub** using Colab and run them using a **GPU** provided by Google. You need to be logged in a Google Account of your own. You can go through the chapters already using the links below: Chapter 0 - TL;DR Chapter 1 - Pay

Attention to LLMs Chapter 2 - Loading a Quantized Model Chapter 3 - Low-Rank Adaptation (LoRA) Chapter 4 - Formatting Your Dataset Chapter 5 - Fine-Tuning with Chapter 6 - Deploying It Locally Appendix B - Data Types' Internal Representation Preface If you’re reading this, I probably don’t need to tell you that large language models are pretty much _everywhere_, right? Since the release of ChatGPT in November 2022, it feels almost impossible to keep up with the rapid pace of developments

. Every day, there’s a new technique, a new model, or a groundbreaking announcement. I wrote this book as a tentative response to that question. It focuses on key concepts that, in my view, have proven to be stable and are likely to remain central to the fine-tuning process for the foreseeable future: quantization, low-rank adapters, and formatting templates. Mastering these concepts is crucial for understanding the current landscape and will also empower you to handle future developments

. They might also be useful to train or fine-tune a variety of large models, not just language models. They are essential tools in any data scientist's toolkit. **** **This is an intermediate-level book, so to make the most of its content, you need a solid foundation. If Transformers, attention, Adam, tokens, embeddings, and GPUs do not ring any bells, I'd suggest you to start with my beginner-friendly series, _Deep Learning with PyTorch Step-by-Step_. ** **** I chose the

Hugging Face ecosystem as the foundation for this book because it is the _de facto_ standard for working with deep learning models, whether they're language models or not. But you have to understand how to configure them effectively and what those configurations are actually doing under the hood. It wasn't easy to find out such information out there, though. I missed a comprehensive overview explaining how these techniques work together in practice, especially when fine-tuning LLMs on a single

GPU. This is the gap I aim to fill with this book. Originally, its title was "a short guide," but its scope grew so much that I eventually renamed it "a hands-on guide. " It covers a lot of ground, and I truly hope it supports you on your learning journey. There's nothing cooler than learning about something new, trying it out yourself, and watching it work just fine, don't you agree? That's what you'll do in Chapter 0, the

"TL;DR" chapter that will guide you through the entire journey of fine-tuning an LLM: quantization, low-rank adapters

常见问题

记录了多少星标和分叉?

dvgodoy/FineTuningLLMs 有 874 个星标和 120 个分叉。

仓库排名是多少?

dvgodoy/FineTuningLLMs 排名第 6,115。

记录的语言和类别是什么?

dvgodoy/FineTuningLLMs 有 874 个星标,语言为 Jupyter Notebook,类别为 Tutorials。

哪个仓库排名最接近?

dvgodoy/FineTuningLLMs 与 miguelgfierro/ai_projects 比较,后者排名第 6,121,有 870 个星标。

README

A Hands-On Guide to Fine-Tuning LLMs with PyTorch and Hugging Face

Kindle | Paperback | PDF [Leanpub] | PDF [Gumroad]

Setup

Google Colab

You can easily load the notebooks directly from GitHub using Colab and run them using a GPU provided by Google. You need to be logged in a Google Account of your own.

You can go through the chapters already using the links below:

Preface

If you’re reading this, I probably don’t need to tell you that large language models are pretty much everywhere, right?

Since the release of ChatGPT in November 2022, it feels almost impossible to keep up with the rapid pace of developments. Every day, there’s a new technique, a new model, or a groundbreaking announcement. These are surely exciting times—but they can also feel overwhelming, exhausting and, at times, frustrating.

"Where do I even begin to learn this?" is a perfectly valid question—and a tough one to answer on your own. I wrote this book as a tentative response to that question. It focuses on key concepts that, in my view, have proven to be stable and are likely to remain central to the fine-tuning process for the foreseeable future: quantization, low-rank adapters, and formatting templates.

Mastering these concepts is crucial for understanding the current landscape and will also empower you to handle future developments. They might also be useful to train or fine-tune a variety of large models, not just language models. They are essential tools in any data scientist's toolkit.


This is an intermediate-level book, so to make the most of its content, you need a solid foundation. If Transformers, attention, Adam, tokens, embeddings, and GPUs do not ring any bells, I'd suggest you to start with my beginner-friendly series, Deep Learning with PyTorch Step-by-Step.


I chose the Hugging Face ecosystem as the foundation for this book because it is the de facto standard for working with deep learning models, whether they're language models or not. The concepts I discuss—quantization, adapters, and templates—are neatly implemented and integrated into the ecosystem, making them relatively straightforward to use. But you have to understand how to configure them effectively and what those configurations are actually doing under the hood. It wasn't easy to find out such information out there, though. I missed a comprehensive overview explaining how these techniques work together in practice, especially when fine-tuning LLMs on a single GPU. This is the gap I aim to fill with this book.

Originally, its title was "a short guide," but its scope grew so much that I eventually renamed it "a hands-on guide." It covers a lot of ground, and I truly hope it supports you on your learning journey. Along the way, I've included plenty of fun examples, made-up quotes, and movie references—after all, I believe learning should be fun.

There's nothing cooler than learning about something new, trying it out yourself, and watching it work just fine, don't you agree? That's what you'll do in Chapter 0, the "TL;DR" chapter that will guide you through the entire journey of fine-tuning an LLM: quantization, low-rank adapters, dataset formatting, training, and querying the model. Next, we'll take a step back and have a brief discussion about language models, Transformers, the attention mechanism, and the different types of fine-tuning in Chapter 1.

The following chapters, two through six, correspond to the sections introduced in Chapter 0. In Chapter 2, "Loading a Quantized Model," we'll discuss 8-bit and 4-bit quantization in more detail, as well as the BitsAndBytes configuration. In Chapter 3, "Low-Rank Adaptation (LoRA)," we'll explore the role and usage of low-rank adapters, including how to configure them using the PEFT package and how to prepare the (quantized) base model to improve numerical stability during training. Then, in Chapter 4, "Formatting Your Dataset," we'll focus on data formatting, chat templates, and the role of tokenizers, padding, packing, and data collators.

The next step in our journey is Chapter 5, "Fine-Tuning with SFTTrainer," where we'll explore a wide range of configuration possibilites to maximize the performance of a consumer-grade GPU and effectively fine-tune our models. We'll also discuss different implementations of the attention mechanism—Flash Attention and PyTorch's SDPA—and compare their speed and memory requirements. Chapter 6, "Deploying It Locally," is an engineering-focused chapter. It covers the details and alternatives for converting your fine-tuned models to the GGUF format and how to serve your models using either Ollama or llama.cpp.

Every learning journey has its difficulties and pitfalls, and in our case, warnings and raised exceptions. The last chapter, Chapter -1, "Troubleshooting," serves as a reference to help you understand and solve the typical errors you may encounter.

Finally, there are also two appendices: the first one, "Appendix A: Setting Up Your GPU Pod," is a step-by-step tutorial for using a cloud provider (runpod.io, a personal favorite) to spin up a GPU-powered Jupyter Notebook; the second, "Appendix B: Data Types' Internal Representation," offers an (optional) overview of how integers and floating-point numbers are internally represented by their bits, for those interested in understanding the advantages and disadvantages of each data type in more detail.

That's it! Have fun!

排名相邻
同类项目