Mục lục
- Mục tiêu bài học
- Hai hướng fine-tune
- Full fine-tuning — cơ chế
- VRAM cho Full fine-tuning
- PEFT — ý tưởng chung
- Các method PEFT
- VRAM Llama 3 8B — so sánh thực tế
- Quality — Full vs PEFT
- Catastrophic forgetting
- Storage và versioning
- Multi-adapter pattern
- Library 2024-2026
- Code preview — PEFT với LoRA
- Workflow tổng quát
- Hardware reality check
- Cost ước tính cloud
- SFT framework so sánh
- Inference với adapter
- Quantization — preview QLoRA
- Limitations của PEFT
- Recommendation 2024-2026
- Bài tập
Mục tiêu bài học
Sau bài này, bạn cần:
- Giải thích được khác biệt giữa Full fine-tuning (update toàn bộ weight) và PEFT (update < 1% weight).
- Ước lượng được VRAM cần cho Llama 3 8B với từng method.
- Liệt kê các method PEFT phổ biến: LoRA, QLoRA, Adapter Layers, Prefix Tuning, Prompt Tuning, IA³.
- Hiểu trade-off quality vs hiệu quả tài nguyên, catastrophic forgetting, storage.
- Biết khi nào chọn Full, khi nào chọn LoRA / QLoRA.
- Biết các library 2024-2026 để fine-tune (PEFT, trl, axolotl, LLaMA-Factory, Unsloth).
- Hiểu pattern multi-adapter cho SaaS phục vụ nhiều khách hàng / nhiều task.
Bài này là "bản đồ" cho cả nhóm Fine-tuning. Bài 49 (LoRA) và Bài 50 (QLoRA) sẽ deep dive cụ thể.
Hai hướng fine-tune
FULL FINE-TUNING
─────────────────────────────────────────────────────────
Update TẤT CẢ tham số của model.
Llama 3 8B → update 8 tỷ tham số.
Cần lưu gradient + optimizer state cho mọi tham số.
VRAM ~3-4× param size (FP16).
PEFT (Parameter-Efficient Fine-Tuning)
─────────────────────────────────────────────────────────
Đóng băng (freeze) base model.
Thêm một subset tham số nhỏ MỚI (adapter, prefix, low-rank).
Chỉ tham số mới được update.
Số tham số train: thường < 1% của model.
VRAM giảm đáng kể.
Từ ~2022, PEFT trở thành default cho fine-tune LLM open-weight (Llama, Mistral, Qwen, Gemma...) vì hai lý do: hardware giới hạn (consumer GPU) và chi phí cloud cao. Full fine-tuning vẫn dùng nhưng chủ yếu cho team có budget GPU lớn hoặc khi PEFT không đủ chất lượng.
Full fine-tuning — cơ chế
Full fine-tuning chạy chính xác như pretraining, chỉ khác dataset và learning rate:
- Load model với weight pretrained (Llama 3 8B từ Hugging Face).
- Mọi tham số
requires_grad=True. - Forward + loss + backward + optimizer step trên TOÀN bộ weight.
- Sau train, lưu lại full model (8B param).
Learning rate cho full fine-tune nhỏ hơn pretrain rất nhiều (1e-5 đến 5e-5) để không "phá" pretrain knowledge. Số epoch thường ít (1-3 epoch trên SFT dataset).
Trade-off: chất lượng có thể nhỉnh hơn PEFT vài %, nhưng cost gấp nhiều lần.
VRAM cho Full fine-tuning
Bộ nhớ cần (FP16 / mixed precision) cho 1 tham số P:
─────────────────────────────────────────────────────────
Weight (FP16) : 2 bytes
Gradient (FP16) : 2 bytes
Optimizer state (Adam, FP32):
- momentum : 4 bytes
- variance : 4 bytes
(Adam giữ master weight FP32: + 4 bytes)
─────────────────────────────────────────────────────
Tổng : ~16 bytes / tham số (FP16 + Adam FP32)
~10-12 bytes nếu optimizer cũng FP16
Llama 3 8B (8e9 tham số):
─────────────────────────────────────────────────────────
Weight : 16 GB
Gradient : 16 GB
Optimizer (Adam FP32) : 64 GB (8 byte master + 8 byte mom/var)
Activation (batch nhỏ): 4-10 GB
─────────────────────────────────────────────────────
Tổng : ~80-100 GB VRAM nếu naive
~60 GB nếu dùng AdamW 8-bit / ZeRO
Nghĩa là: full fine-tune Llama 3 8B với 1 GPU đơn (A100 40GB) không khả thi nếu naive. Cần:
- A100 80GB / H100 80GB / MI300X 192GB (1 GPU), hoặc
- Multi-GPU với DeepSpeed ZeRO-3 (chia optimizer state, gradient, weight), hoặc
- FSDP (Fully Sharded Data Parallel) của PyTorch, hoặc
- CPU offload (chậm hơn).
Với model lớn hơn (Llama 3 70B), full fine-tune cần ít nhất 4-8 GPU A100/H100 80GB.
PEFT — ý tưởng chung
PEFT cơ bản:
─────────────────────────────────────────────────────────
Base model (8B param) → FREEZE (requires_grad = False)
Thêm module MỚI nhỏ → TRAIN
Số param train: 0.1-1% của model
→ gradient + optimizer state CHỈ cho param mới
→ tiết kiệm VRAM 80-95%
Cơ sở lý thuyết (intrinsic dimension hypothesis): khi adapt model lớn xuống một task cụ thể, hướng cập nhật weight nằm trên một subspace chiều thấp. Aghajanyan et al. 2020 (arXiv 2012.13255) chỉ ra fine-tune BERT/RoBERTa chỉ cần vài trăm chiều intrinsic là đủ. Đây là motivation chính cho LoRA.
Hệ quả: train một module nhỏ song song với weight đông cứng có thể đạt chất lượng gần bằng full fine-tune.
Các method PEFT
Method Cơ chế (ngắn) Ghi chú
─────────────────────────────────────────────────────────────────
LoRA Thêm 2 ma trận low-rank A, B vào Default 2024-2026.
Linear layer (W' = W + B·A). Bài 49 deep dive.
Rank r nhỏ (4-64).
QLoRA LoRA + quantize base 4-bit VRAM thấp nhất.
(NF4). Train adapter trên base Bài 50.
đã quantize.
Adapter Layers Insert bottleneck MLP module Houlsby 2019 — bản
giữa các layer transformer. gốc adapter.
Prefix Tuning Thêm "virtual token" trainable Li & Liang 2021.
vào key/value của mỗi layer. Không thay weight gốc.
Prompt Tuning Thêm "soft prompt" (embedding Lester 2021. Đơn giản
trainable) chỉ ở input layer. nhất, hiệu quả kém hơn
với model nhỏ.
P-Tuning v2 Prefix tuning áp cho mọi layer, Liu 2021. Tương đương
cải tiến của Prompt Tuning. prefix về sức mạnh.
IA³ Scale activation bằng vector học Liu 2022. Rất ít param,
được (element-wise multiply). chất lượng tương đối.
(IA)³ + LoRA, BitFit (chỉ train bias), DoRA (LoRA variant)... — variants liên tục ra đời.
Trong 6+ method trên, LoRA và QLoRA chiếm ~80% use case fine-tune LLM 2024-2026. Adapter Layers và Prefix Tuning còn dùng trong research; Prompt Tuning chủ yếu cho model rất lớn (175B+).
VRAM Llama 3 8B — so sánh thực tế
Method VRAM (Llama 3 8B, batch=1)
─────────────────────────────────────────────────────────
Full fine-tune (FP16+Adam) ~60-80 GB (single GPU không khả thi
trên consumer)
Full + ZeRO-3 (4× A100) ~20 GB / GPU
LoRA (rank 16, FP16) ~24 GB (A100 40GB / 3090 / 4090)
LoRA + gradient checkpoint ~16-20 GB
QLoRA (NF4, rank 64) ~12-16 GB (RTX 3090 / 4090 / A4000)
QLoRA (NF4, batch=1, ctx 2k) ~10-12 GB (RTX 3060 12GB cũng chạy)
Llama 3 70B
─────────────────────────────────────────────────────────
Full fine-tune ~600 GB (multi-node)
LoRA (FP16) ~160 GB (2× A100 80GB)
QLoRA (NF4) ~48 GB (single A100 80GB)
Con số phụ thuộc batch size, sequence length, rank LoRA, tool. Unsloth claim giảm thêm 30-60% VRAM cho cùng setup.
Quy tắc nhanh: với GPU consumer (16-24GB VRAM) → QLoRA cho model < 13B, LoRA cho model < 8B. Với A100 80GB → LoRA cho 70B, QLoRA cho 70B+ thoải mái.
Quality — Full vs PEFT
Benchmark phổ biến (SFT, instruction following):
─────────────────────────────────────────────────────────
Full FT : 100% (baseline)
LoRA (rank 64) : 95-100% (thường ngang Full)
QLoRA (NF4) : 95-99% (gần LoRA, đôi khi nhỉnh hơn
do quantization noise hoạt động như regularize)
Prefix Tuning : 85-95% (kém hơn rõ ở task khó)
Prompt Tuning : 70-90% (chỉ tốt với model rất lớn)
Quan sát thực tế:
- LoRA với rank đủ (16-64) thường khớp Full fine-tune trên SFT instruction-following.
- QLoRA gần như không thua LoRA; quantization 4-bit base model giữ được hầu hết capability.
- Full FT lợi rõ khi: dataset rất lớn (> 100K example), task xa pretrain distribution, hoặc cần inject lượng knowledge lớn.
- Với dataset nhỏ (< 10K), LoRA thường tốt hơn Full vì ít overfit.
Tham khảo: Dettmers et al. 2023 (QLoRA: Efficient Finetuning of Quantized LLMs, arXiv 2305.14314) — show QLoRA đạt ngang Full FT trên Vicuna benchmark.
Catastrophic forgetting
Catastrophic forgetting: khi fine-tune trên task A, model "quên" capability chung (general knowledge, multilingual, code...).
Full FT PEFT (LoRA/QLoRA)
─────────────────────────────────────────────────────────
General benchmarks Drop 5-15% Drop 1-5%
(MMLU, HellaSwag)
Multilingual Có thể drop Ít hơn
Code (HumanEval) Drop nếu data Drop ít vì base
SFT không code vẫn frozen
Lý do: Full FT thay đổi mọi weight, có thể overwrite circuit đã học trong pretrain. PEFT để base frozen, chỉ "thêm hướng" → ít destructive.
Cách giảm forgetting với Full FT: trộn dataset general vào SFT data (replay buffer), dùng learning rate rất nhỏ, regularization như EWC.
Storage và versioning
Sản phẩm sau khi train:
─────────────────────────────────────────────────────────
Full FT Llama 3 8B FP16 : ~16 GB (toàn bộ weight)
LoRA adapter (rank 16) : ~30-100 MB
LoRA adapter (rank 64) : ~80-200 MB
QLoRA adapter : ~80-200 MB (adapter là FP16
kể cả khi base 4-bit)
Prefix / Prompt tuning : vài MB
Hệ quả storage:
- Full FT 10 phiên bản → 160 GB.
- LoRA 10 phiên bản → 1-2 GB (chia sẻ chung 1 base).
- Push HF Hub: adapter LoRA gọn nhẹ, tiện share.
Pattern phổ biến: lưu base model một lần ở object storage, lưu nhiều adapter cho nhiều task / nhiều khách hàng / nhiều phiên bản. Inference load base + swap adapter runtime.
Multi-adapter pattern
SaaS với multi-tenant — ví dụ trợ lý CSKH cho 50 doanh nghiệp:
─────────────────────────────────────────────────────────
┌─ Base Llama 3 8B (1 bản, 16GB GPU)
│
├─ Adapter customer A (100MB) → tone bán hàng, FAQ A
├─ Adapter customer B (100MB) → domain y tế, FAQ B
├─ Adapter customer C (100MB) → domain pháp lý, FAQ C
│ ...
└─ Adapter customer Z (100MB)
Request từ customer X:
→ load base (giữ sẵn trong GPU)
→ swap / merge adapter X
→ infer
→ swap adapter khác cho request kế tiếp
Các serving framework hỗ trợ multi-adapter:
- vLLM: hỗ trợ multi-LoRA serving với
--enable-lora, switch adapter per request. - TGI (Text Generation Inference): hỗ trợ load nhiều adapter.
- Punica / S-LoRA: framework chuyên cho serving hàng nghìn adapter cùng lúc.
Pattern này không khả thi với Full FT: mỗi customer cần 16GB → 50 customer = 800GB lưu trữ + cost load model mỗi lần switch.
Library 2024-2026
Library Vai trò
─────────────────────────────────────────────────────────
peft (Hugging Face) Implement LoRA, QLoRA, Prefix, Prompt,
IA³, AdaLoRA, DoRA. Tích hợp transformers.
trl (Hugging Face) SFTTrainer, DPOTrainer, RewardTrainer.
Lớp trên transformers + peft.
bitsandbytes 4-bit / 8-bit quantization (NF4, INT8).
QLoRA dùng cái này.
accelerate Multi-GPU, mixed precision, ZeRO/FSDP.
Framework cấp cao (build trên các thư viện trên):
─────────────────────────────────────────────────────────
axolotl YAML config — fine-tune phổ biến trong
OSS community.
LLaMA-Factory GUI + CLI, hỗ trợ >100 model, UI Gradio.
Unsloth Tối ưu kernel, 2× faster, ~60% less VRAM
so với baseline (Llama, Mistral, Gemma).
TorchTune Official PyTorch fine-tune library (2024+).
Stack thực tế phổ biến:
- Người mới → LLaMA-Factory (UI) hoặc Unsloth (Colab notebook).
- Production → axolotl + accelerate, hoặc viết script với
trl+peft. - Research / custom → trực tiếp
transformers+peft+accelerate.
Code preview — PEFT với LoRA
pip install transformers peft trl bitsandbytes accelerate
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import LoraConfig, get_peft_model, TaskType
from trl import SFTTrainer, SFTConfig
from datasets import load_dataset
model_id = "meta-llama/Meta-Llama-3-8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="bfloat16")
# 1. Định nghĩa LoRA config
lora_cfg = LoraConfig(
task_type=TaskType.CAUSAL_LM,
r=16, # rank
lora_alpha=32, # scale
lora_dropout=0.05,
target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
)
# 2. Wrap model bằng PEFT
model = get_peft_model(model, lora_cfg)
model.print_trainable_parameters()
# trainable params: 41M (~0.5% of 8B)
# 3. Train với SFTTrainer
ds = load_dataset("yahma/alpaca-cleaned", split="train[:5000]")
trainer = SFTTrainer(
model=model,
train_dataset=ds,
args=SFTConfig(
output_dir="./llama3-lora-alpaca",
per_device_train_batch_size=2,
gradient_accumulation_steps=4,
num_train_epochs=1,
learning_rate=2e-4,
bf16=True,
max_seq_length=1024,
),
)
trainer.train()
trainer.save_model() # chỉ lưu adapter (~100MB)
Bài 49 sẽ giải thích chi tiết r, lora_alpha, target_modules. Bài 50 sẽ thêm BitsAndBytesConfig cho QLoRA.
Workflow tổng quát
1. Choose base model
- Llama 3 8B/70B, Mistral 7B, Qwen 2.5, Gemma 2...
2. Prepare dataset
- Format SFT (instruction, input, output) — Bài 51.
3. Select method
- QLoRA nếu VRAM < 24GB
- LoRA nếu VRAM ≥ 24GB
- Full FT nếu có ≥ 4× A100 80GB + data lớn
4. Configure hyperparam
- LR (1e-4 đến 5e-4 cho LoRA, 1e-5 đến 5e-5 cho Full)
- Rank LoRA (16-64)
- Batch size, gradient accumulation
- Epoch (1-3)
5. Train (Bài 52)
6. Evaluate
- Held-out test set + LLM-as-judge / Recall@K / domain metric
7. Merge (optional)
- peft.PeftModel.merge_and_unload() → standalone model
- Hoặc giữ adapter để serve multi-task
Mỗi bước phía sau sẽ được deep-dive trong nhóm Fine-tuning (Bài 49-54).
Hardware reality check
Hardware Khả năng fine-tune
─────────────────────────────────────────────────────────
CPU only Không thực tế. Cho học chỉ với
model < 200M (toy).
RTX 3060 12GB / 4060 QLoRA 7B (Mistral 7B, Llama 3 8B)
context ngắn.
RTX 3090 / 4090 24GB QLoRA tới 13B thoải mái.
LoRA Llama 3 8B.
A100 40GB LoRA tới 13B. Full FT 7-8B với
gradient checkpoint.
A100 80GB Full FT 8B. LoRA 70B.
QLoRA 70B.
2-4× A100 80GB Full FT 70B với ZeRO-3.
8× H100 80GB Full FT Mixtral 8x22B, Llama 3 405B
với QLoRA.
Cloud GPU (rent theo giờ, 2024-2026):
─────────────────────────────────────────────────────────
Google Colab Pro+ T4 / A100 — $50/tháng, có time limit.
RunPod A100 40/80GB ~$1-2/h, H100 ~$2-3/h.
Lambda Labs A100 ~$1.10/h on-demand.
AWS p4d / p5 A100/H100 đắt hơn nhưng enterprise-grade.
GCP A2 / A3 A100/H100 với preemptible giá tốt.
Vast.ai Marketplace consumer GPU, rẻ nhưng bất ổn.
Cost ước tính cloud
Task Ước tính (RunPod / Lambda, 2026)
─────────────────────────────────────────────────────────────────
QLoRA Llama 3 8B, 10K SFT, 1 epoch 1-3 giờ × $1.5 ≈ $1.5-5
LoRA Llama 3 8B, 10K SFT, 1 epoch 2-4 giờ × $1.5 ≈ $3-6
Full FT Llama 3 8B, 10K SFT, 16-32 giờ × $4-8 (multi-GPU)
1 epoch (4× A100 80GB) ≈ $80-250
LoRA Llama 3 70B, 10K SFT 8-16 giờ × $2 (A100 80GB)
≈ $16-32
QLoRA Llama 3 70B, 10K SFT 6-12 giờ × $2 ≈ $12-24
Quy tắc: PEFT trên model nhỏ rẻ tới mức không phải nghĩ. Full FT trên model lớn dễ tốn vài trăm USD / lần thử. Vì vậy quyết định thử method nào trước rất quan trọng.
SFT framework so sánh
Framework Interface Đặc điểm
─────────────────────────────────────────────────────────────
trl Python API HF official. Flexible, viết
script là chính. Tốt cho custom.
axolotl YAML config Phổ biến trong OSS LLM
community. Reproducibility tốt.
Support nhiều model architecture.
LLaMA-Factory UI + YAML + UI Gradio thân thiện. Hỗ trợ
CLI >100 model. Tốt cho người mới.
Unsloth Python API Kernel tối ưu (Triton). 2× faster,
60% less VRAM. Llama/Mistral/Gemma
family. Hạn chế: chỉ single GPU.
TorchTune Python / PyTorch official. Recipe-based.
recipe yaml Multi-node support.
Lựa chọn nhanh:
- Mới học, GPU đơn → Unsloth trong Colab.
- Production OSS team → axolotl.
- Người không biết code → LLaMA-Factory UI.
- Cần custom trainer (DPO, GRPO, custom loss) → trl trực tiếp.
- Multi-node training, official PyTorch → TorchTune.
Inference với adapter
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained(
"meta-llama/Meta-Llama-3-8B", torch_dtype="bfloat16"
)
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B")
# Cách 1: apply adapter tại runtime (chậm hơn ~5-10% mỗi forward)
model = PeftModel.from_pretrained(base, "./llama3-lora-alpaca")
model.eval()
# Cách 2: merge adapter vào base (chỉ làm 1 lần) — standalone model
merged = model.merge_and_unload()
merged.save_pretrained("./llama3-merged") # giờ là full model FP16
Hai cách trade-off:
- Apply runtime: giữ adapter tách rời → multi-adapter pattern, switch nhanh. Inference chậm hơn chút.
- Merge: model thành "standalone" như Full FT → infer nhanh nhất, nhưng mất khả năng swap adapter và lưu 16GB thay vì 100MB.
Production phổ biến: merge nếu chỉ phục vụ 1 task; giữ tách nếu multi-tenant / nhiều task.
Quantization — preview QLoRA
QLoRA = LoRA + base model quantize xuống 4-bit:
Base Llama 3 8B FP16 : 16 GB
Base Llama 3 8B NF4 : ~4.5 GB (quantize 4-bit)
+ LoRA adapter FP16 : ~80 MB
Train: forward qua base 4-bit (dequant on-the-fly),
gradient chỉ chảy vào adapter FP16.
Save: chỉ adapter (~80MB).
Inference: load base NF4 + apply adapter.
Ý nghĩa: với QLoRA, RTX 3090/4090 24GB fine-tune được Llama 3 8B; RTX 3060 12GB cũng fine-tune được 7B với context ngắn.
Trade-off: quantization noise có thể ảnh hưởng vài % accuracy. Trong paper QLoRA, chênh lệch với LoRA FP16 không đáng kể trên SFT benchmark.
Bài 50 deep dive cơ chế NF4, double quantization, paged optimizer.
Limitations của PEFT
- Knowledge injection kém — fine-tune (cả Full lẫn PEFT) không phải cách tốt để "nhồi" hàng nghìn fact mới vào model. Knowledge stick lại không đáng tin. Dùng RAG cho fact (Bài 32-41 đã cover).
- Task xa pretrain distribution — code → audio, text → robotics control. PEFT có thể không đủ "không gian" cập nhật, Full FT có thể tốt hơn.
- Dataset rất lớn (> 100K-1M) — Full FT thường khai thác hết signal trong data; PEFT có thể saturate trước.
- Continued pretraining — extend tokenizer cho ngôn ngữ mới (Việt, Thái, Ả Rập...): Full FT hoặc LoRA rank cao + nhiều target module.
- Layer chọn target — chọn sai target module (chỉ attention không có MLP) có thể giảm chất lượng. Default tốt: q/k/v/o + gate/up/down MLP (cho Llama 3).
- Hyperparam nhạy — LoRA rank, alpha, learning rate cần tune. Một số config chạy được nhưng converge kém.
Recommendation 2024-2026
Tình huống Method khuyến nghị
─────────────────────────────────────────────────────────────
Default cho 90% case LoRA hoặc QLoRA
Consumer GPU (12-24GB), <13B model QLoRA
A100 40GB, model 7-13B LoRA
A100 80GB, model 70B LoRA hoặc QLoRA
Dataset < 10K example LoRA (ít overfit)
Dataset > 100K example, đủ GPU Full FT (nếu PEFT
saturate)
Cần serve multi-tenant LoRA + merge optional
(adapter swap)
Continued pretraining (extend LoRA rank cao (>128)
ngôn ngữ / domain shift lớn) hoặc Full FT
Research, quality benchmark Full FT làm baseline,
so với LoRA
Quy trình thực tế đề xuất:
- Bắt đầu QLoRA (rẻ, nhanh, ít VRAM). Đo metric.
- Nếu chất lượng đủ → dừng.
- Nếu chưa đủ → thử LoRA FP16 với rank cao hơn.
- Nếu vẫn chưa đủ + có data và GPU → thử Full FT.
Bài tập
- Tính bằng tay (giấy bút) VRAM cần cho Full fine-tune, LoRA rank 16, và QLoRA cho Llama 3 8B (FP16 base, Adam optimizer). Note giả định và bước tính.
- Chọn method (Full / LoRA / QLoRA / Prefix / Prompt) cho 3 use case sau và giải thích:
- (a) Trợ lý CSKH cho 30 doanh nghiệp, mỗi DN có 500-2000 cặp Q&A riêng.
- (b) Mở rộng Llama 3 8B sang khả năng hiểu tiếng Việt code-mixed, có 200K example mixed Việt-Anh.
- (c) Style transfer: viết caption ảnh theo phong cách 1 nhà văn cụ thể, dataset 800 cặp ảnh-caption.
- Compute size adapter LoRA rank 16, target
q_proj, k_proj, v_proj, o_projcho Llama 3 8B (hidden_size = 4096, 32 layer). So với full model 16GB FP16. - Trên Colab (T4 hoặc A100) chạy code preview ở bước 13 với dataset nhỏ (200 example). Kiểm tra
print_trainable_parametersvà VRAM thực tếnvidia-smi. - Load adapter đã train: dùng
PeftModel.from_pretrainedapply runtime, rồimerge_and_unload. So sánh latency 1 lần generate giữa hai cách. - (Tùy chọn) Train cùng 1 dataset bằng
peftrank 8 và rank 64, so sánh quality bằng LLM-as-judge.
- Hu et al. — LoRA: Low-Rank Adaptation of Large Language Models (arXiv 2106.09685)
- Dettmers et al. — QLoRA: Efficient Finetuning of Quantized LLMs (arXiv 2305.14314)
- Houlsby et al. — Parameter-Efficient Transfer Learning for NLP (Adapter, arXiv 1902.00751)
- Li & Liang — Prefix-Tuning: Optimizing Continuous Prompts for Generation (arXiv 2101.00190)
- Lester et al. — The Power of Scale for Parameter-Efficient Prompt Tuning (arXiv 2104.08691)
- Liu et al. — P-Tuning v2 (arXiv 2110.07602)
- Liu et al. — Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learning (IA³, arXiv 2205.05638)
- Aghajanyan et al. — Intrinsic Dimensionality Explains the Effectiveness of Language Model Fine-Tuning (arXiv 2012.13255)
- Liu et al. — DoRA: Weight-Decomposed Low-Rank Adaptation (arXiv 2402.09353)
- Hugging Face — PEFT library documentation
- Hugging Face — TRL (Transformer Reinforcement Learning) library
- axolotl — Fine-tuning framework
- LLaMA-Factory — Unified fine-tuning UI
- Unsloth — 2x faster fine-tuning
- TorchTune — PyTorch native fine-tuning
- bitsandbytes — 8-bit / 4-bit quantization
- vLLM — Multi-LoRA serving
- Sheng et al. — S-LoRA: Serving Thousands of Concurrent LoRA Adapters (arXiv 2311.03285)
