Fine-tuning Llama 2 for Tone or Style

Опубликовано: 29 Март 2026
на канале: Trelis Research
2,446
47

Fine-tune Llama 2 (or any huggingface model!) for tone or style using a custom dataset - here, Shakespeare!

Fine-tuning for structured responses, e.g. function calling?    • Fine-tuning Language Models for Structured...  

Free Resources
Simple fine-tuning Colab Notebook: https://colab.research.google.com/dri...

Embedding Notebook - see    • Embeddings vs Fine Tuning  - Part 1, Embed...  
1. Create Embeddings with OpenAI, marco, or Llama 2.
2. Run inference with injected embeddings
Buy Access Here: https://buy.stripe.com/eVa5l6cWh0zpg7...

Supervised Fine-tuning Notebook - see    • Embeddings vs Fine Tuning  - Part 2, Super...  
Run fine-tuning using a Q&A dataset.
Buy Access Here: https://buy.stripe.com/4gw6pag8t5TJ9I...

Fine-tuning Repository Access
1. Supervised Fine-tuning Notebook
2. Q&A Dataset Preparation Scripts
3. Embedding Notebook (Scripts to create and use Embeddings)
4. Notebook to fine-tune for Tone or Style
5. Forum Support
Learn More: https://trelis.com/advanced-fine-tuni...

Shakespeare Dataset on HuggingFace: https://huggingface.co/datasets/Treli...

Karpathy's nanoGPT repo (where he trains a model from scratch on Shakespeare): https://github.com/karpathy/nanoGPT

Chapters:
0:00 How to fine tune on a custom dataset
0:15 What dataset should I use for fine-tuning?
0:50 Fine-tuning in Google Colab
2:45 Loading Llama 2 with bitsandbytes
3:15 Fine-tuning with LoRA
3:50 Target modules for fine-tuning
4:15 Loading data for fine-tuning
5:30 Training Llama 2 with a validation set
6:30 Setting training parameters for fine-tuning
7:50 Choosing batch size for training
8:15 Setting gradient accumulation for training
9:25 Using an eval dataset for training
9:50 Setting warm-up parameters for training
10:50 Using AdamW for optimisation
13:20 Fix for when commands don't work in Colab
15:00 Evaluating training loss
16:20 Running inference after training