LLM Fine-Tuning Resources
A curated collection of notebooks, datasets, papers, tools, and communities for LLM fine-tuning.
📓 Official Course Notebooks
Module-Specific Notebooks
| Module | Notebook | Description |
|---|---|---|
| Module 4 | LoRA Training | Basic LoRA fine-tuning with PEFT |
| Module 5 | QLoRA Training | 4-bit quantized training |
| Module 6 | Data Preparation | Dataset formatting pipelines |
| Module 7 | SFTTrainer | Complete training workflow |
| Module 8 | DPO Training | Preference optimization |
| Module 10 | Deployment | Model export and serving |
🤗 Hugging Face Resources
Essential Libraries
| Library | Purpose | Install |
|---|---|---|
| transformers | Model loading and inference | pip install transformers |
| peft | Parameter-efficient fine-tuning | pip install peft |
| trl | Training with RL and SFT | pip install trl |
| datasets | Dataset loading and processing | pip install datasets |
| accelerate | Distributed training | pip install accelerate |
| bitsandbytes | Quantization | pip install bitsandbytes |
Recommended Base Models
| Model | Parameters | Use Case | HF Link |
|---|---|---|---|
| Llama-3.1 | 8B/70B | General purpose | meta-llama/Llama-3.1-8B |
| Mistral | 7B | Efficient performance | mistralai/Mistral-7B-v0.3 |
| Qwen2.5 | 0.5B-72B | Multilingual | Qwen/Qwen2.5-7B |
| Phi-3 | 3.8B | Small but capable | microsoft/Phi-3-mini-4k-instruct |
| Gemma 2 | 2B/9B/27B | Google's open model | google/gemma-2-9b |
📊 Training Datasets
Instruction Tuning Datasets
| Dataset | Size | Format | Use Case |
|---|---|---|---|
| databricks/dolly-15k | 15K | Alpaca | General instructions |
| OpenAssistant/oasst1 | 161K | Conversations | Chat models |
| teknium/OpenHermes-2.5 | 1M+ | ShareGPT | High quality |
| HuggingFaceH4/ultrachat_200k | 200K | Conversations | Chat |
| meta-math/MetaMathQA | 395K | Math | Math reasoning |
Preference/DPO Datasets
| Dataset | Pairs | Use Case |
|---|---|---|
| Anthropic/hh-rlhf | 170K | Helpfulness & Harmlessness |
| argilla/ultrafeedback-binarized | 60K | General preferences |
| Intel/orca_dpo_pairs | 12K | DPO training |
Code Datasets
| Dataset | Size | Languages |
|---|---|---|
| codeparrot/github-code | Large | Multiple |
| sahil2801/CodeAlpaca-20k | 20K | Multiple |
| iamtarun/python_code_instructions_18k | 18K | Python |
📚 Research Papers
Foundational Papers
| Paper | Year | Key Contribution |
|---|---|---|
| LoRA: Low-Rank Adaptation | 2021 | Introduced LoRA method |
| QLoRA: Efficient Finetuning | 2023 | 4-bit quantized LoRA |
| Prefix-Tuning | 2021 | Continuous prompts |
| P-Tuning v2 | 2021 | Deep prompt tuning |
| AdaLoRA | 2023 | Adaptive rank allocation |
Alignment Papers
| Paper | Year | Key Contribution |
|---|---|---|
| DPO: Direct Preference Optimization | 2023 | Simplified RLHF |
| ORPO: Monolithic Preference Optimization | 2024 | Combined SFT+alignment |
| Constitutional AI | 2022 | Principle-based alignment |
| RLHF Training at Scale | 2022 | InstructGPT paper |
Model Merging Papers
| Paper | Year | Method |
|---|---|---|
| TIES-Merging | 2023 | Conflict resolution |
| DARE | 2023 | Drop and rescale |
| Model Soups | 2022 | Weight averaging |
🛠️ Tools & Frameworks
Training Tools
| Tool | Purpose | Link |
|---|---|---|
| Axolotl | Easy fine-tuning CLI | OpenAccess-AI-Collective/axolotl |
| LLaMA-Factory | Unified fine-tuning framework | hiyouga/LLaMA-Factory |
| Unsloth | 2x faster fine-tuning | unslothai/unsloth |
| MLX | Apple Silicon training | ml-explore/mlx |
Inference & Deployment
| Tool | Purpose | Link |
|---|---|---|
| vLLM | High-throughput serving | vllm-project/vllm |
| Text Generation Inference | HuggingFace serving | huggingface/text-generation-inference |
| llama.cpp | CPU inference | ggerganov/llama.cpp |
| Ollama | Local model running | ollama/ollama |
Model Merging
| Tool | Purpose |
|---|---|
| mergekit | Model merging toolkit |
| LazyMergeKit | Colab notebook for merging |
Experiment Tracking
| Tool | Purpose |
|---|---|
| Weights & Biases | Experiment tracking |
| MLflow | ML lifecycle |
| TensorBoard | Training visualization |
☁️ Compute Resources
Cloud GPU Providers
| Provider | Best For | Pricing Model |
|---|---|---|
| Google Colab | Learning, small experiments | Free tier + Pro |
| Lambda Labs | A100/H100 access | Per-hour |
| RunPod | Flexible GPU rental | Per-hour |
| Vast.ai | Budget GPU access | Marketplace |
| AWS SageMaker | Enterprise | Per-instance |
GPU Memory Requirements
| Model Size | Full FT | QLoRA | LoRA |
|---|---|---|---|
| 7B | ~28GB | ~6GB | ~14GB |
| 13B | ~52GB | ~10GB | ~26GB |
| 70B | ~280GB | ~48GB | ~140GB |
🌐 Communities
Discord Servers
- Hugging Face - Official HF community
- EleutherAI - Open source AI research
- Unsloth - Fast fine-tuning discussions
Forums & Discussions
- Hugging Face Forums - Technical discussions
- r/LocalLLaMA - Local model running
- r/MachineLearning - ML research
Blogs & Newsletters
- Hugging Face Blog - Official tutorials
- Sebastian Raschka's Newsletter - Deep learning insights
- The Batch - AI news by Andrew Ng
📖 Books & Courses
Recommended Books
| Book | Author | Focus |
|---|---|---|
| Natural Language Processing with Transformers | Tunstall, von Werra, Wolf | Practical NLP with HF |
| Build a Large Language Model (From Scratch) | Sebastian Raschka | LLM fundamentals |
Online Courses
| Course | Platform | Focus |
|---|---|---|
| Hugging Face NLP Course | HF | Transformers & NLP |
| Full Stack LLM Bootcamp | FSDL | Production LLMs |
| Fast.ai | Fast.ai | Deep learning |
🧪 Benchmarks & Evaluation
LLM Leaderboards
- Open LLM Leaderboard - Model comparison
- LMSYS Chatbot Arena - Human evaluation
- AlpacaEval - Instruction following
Evaluation Tools
| Tool | Purpose |
|---|---|
| lm-evaluation-harness | Comprehensive benchmarks |
| HELM | Holistic evaluation |
| MT-Bench | Multi-turn conversations |
💡 Quick Start Templates
Basic QLoRA Training
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
from trl import SFTTrainer
# 4-bit quantization config
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
)
# Load model
model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.1-8B",
quantization_config=bnb_config,
)
# LoRA config
lora_config = LoraConfig(
r=16,
lora_alpha=32,
target_modules=["q_proj", "v_proj"],
lora_dropout=0.05,
task_type="CAUSAL_LM",
)
# Prepare and train
model = prepare_model_for_kbit_training(model)
model = get_peft_model(model, lora_config)
trainer = SFTTrainer(
model=model,
train_dataset=dataset,
# ... training args
)
trainer.train()