သဘောတရား
PEFT, LoRA and fine-tuning on SageMaker
Train a small share of weights with LoRA or QLoRA, on instances sized to the model.
ဒီသင်ခန်းစာကို မြန်မာဘာသာ မပြန်ရသေးလို့ အင်္ဂလိပ်လို ပြထားပါတယ်။
Full fine-tuning
- Trains
- All weights
- Memory need
- Highest
LoRA
- Trains
- Small adapters
- Memory need
- Weights plus a little
QLoRA
- Trains
- Adapters on a 4-bit base
- Memory need
- Lowest
| Method | Trains | Memory need |
|---|---|---|
| Full fine-tuning | All weights | Highest |
| LoRA | Small adapters | Weights plus a little |
| QLoRA | Adapters on a 4-bit base | Lowest |
ဘာလဲ
Full fine-tuning updates every weight of a large model, so you need memory for the weights, the gradients and the optimizer state, several times the model size. Parameter-efficient fine-tuning (PEFT) freezes the base model and trains only a small number of extra weights. Low-Rank Adaptation (LoRA) adds small low-rank adapter matrices to some layers and trains only those, a small fraction of all the weights. The adapter is a small file you can swap or merge into the base.
QLoRA goes further: it loads the frozen base model in 4-bit quantized form and trains LoRA adapters on top, so a large model fits on a single GPU. The price is a little quality and slower steps.
ဘာလဲ
On SageMaker AI you can fine-tune from JumpStart, which offers instruction fine-tuning for many open models: pick the model, point to training data in S3 (instruction and response examples with a prompt template), set hyperparameters and run. Or write a training script with the Hugging Face libraries (Transformers and PEFT) and run it in script mode on the Hugging Face container. Instruction fine-tuning teaches the model to follow requests, using prompt and response pairs.
ဘာလဲ
Plan instance memory. The weights alone need about the parameter count times the bytes per weight: a 7 billion parameter model in 16-bit needs about 14 GB. Full fine-tuning needs several times that. LoRA needs little more than the weights. QLoRA cuts the weights to about a quarter. Choose a GPU instance with enough memory, or add GPUs with a distributed strategy.
မှတ်ထားရန်
- PEFT freezes the base model and trains a small adapter.
- LoRA: low-rank adapters. QLoRA: LoRA on a 4-bit base model.
- Adapters are small files, easy to store and swap.
- JumpStart gives instruction fine-tuning with S3 data and a few settings.
- Weights need about parameters times bytes. 7 billion parameters at 16-bit is about 14 GB.
မှတ်ထားရန်
- Less memory than full fine-tuning, and less risk of forgetting.
စာမေးပွဲမှာ
- “Fine-tune a 70-billion parameter model on limited GPU memory” points to QLoRA.
- “Keep the base model unchanged and train only a small adapter” points to LoRA.
- “Fine-tune an open source model through a guided workflow in SageMaker” points to JumpStart.
ဒီ task ထဲမှာ · 2.2
- Built-in algorithms for tabular data
- Built-in algorithms: clustering, dimensionality reduction, anomaly
- Built-in algorithms: text, sequence and forecasting
- Built-in algorithms: image and video
- Training jobs, script mode and ML libraries
SageMaker AMT
- Reducing training time
- Distributed training and HyperPod
- Overfitting, underfitting and catastrophic forgetting
- Combining models
- Epochs, steps, batch size and learning rate
- Task-specific prompt engineering
- Fine-tuning and continued pre-training in Bedrock
- PEFT, LoRA and fine-tuning on SageMaker
- Model distillation
- Optimizing retrieval and embedding models