ladderlore
请求新指南
  • 输入服务名称,例如 S3 或 IAM。

概念

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
Three ways to fine-tune, by memory need.
JumpStart and AutoML
Fine-tuning job
SageMaker hostingS3 as the ML data lakePick modelTraining dataDeploy
Fine-tune from JumpStart and deploy.

是什么

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.