parameter-efficient quantization llm-finetuning gsm8k low-rank-adaptation singular-value-decomposition mistral-7b llama-3-70b
Abstract
To parameter-efficiently fine-tune (PEFT) large language models (LLMs), the low-rank adaptation (LoRA) method approximates the model changes $\Delta W \in \mathbb{R}^{m \times n}$ through the product of two matrices $A \in \mathbb{R}^{m \times r}$ and $B \in \mathbb{R}^{r \times n}$, where $r \ll \min(m, n)$, $A$ is initialized with Gaussian noise, and $B$ with zeros. LoRA freezes the original model $W$ and updates the"Noise&Zero"adapter, which may lead to slow convergence. To overcome this limitation, we introduce Principal Singular values and Singular vectors Adaptation (PiSSA). PiSSA shares the same architecture as LoRA, but initializes the adaptor matrices $A$ and $B$ with the principal components of the original matrix $W$, and put the remaining components into a residual matrix $W^{res} \in \mathbb{R}^{m \times n}$ which is frozen during fine-tuning. Compared to LoRA, PiSSA updates the principal components while freezing the"residual"parts, allowing faster convergence and enhanced performance. Comparative experiments of PiSSA and LoRA across 12 different models, ranging from 184M to 70B, encompassing 5 NLG and 8 NLU tasks, reveal that PiSSA consistently outperforms LoRA under identical experimental setups. On the GSM8K benchmark, Mistral-7B fine-tuned with PiSSA achieves an accuracy of 72.86%, surpassing LoRA's 67.7% by 5.16%. Due to the same architecture, PiSSA is also compatible with quantization to further reduce the memory requirement of fine-tuning. Compared to QLoRA, QPiSSA exhibits smaller quantization errors in the initial stages. Fine-tuning LLaMA-3-70B on GSM8K, QPiSSA attains an accuracy of 86.05%, exceeding the performances of QLoRA at 81.73%. Leveraging a fast SVD technique, PiSSA can be initialized in only a few seconds, presenting a negligible cost for transitioning from LoRA to PiSSA. Code is available at https://github.com/GraphPKU/PiSSA.
한국어 요약
한 줄 요약
PiSSA는 LoRA보다 빠르고 성능이 우수한 대형 언어 모델 미세조정 기법으로, 주성분 기반 초기화와 잔여 성분 고정을 통해 70B 모델에서도 86.05% 정확도를 달성한다.
핵심 기여도
- PiSSA는 LoRA의 "Noise&Zero" 초기화 문제를 해결해, 주성분 기반의 SVD 초기화를 도입함.
- GSM8K에서 Mistral-7B 기반 PiSSA는 LoRA 대비 5.16% (72.86% vs. 67.7%) 정확도 향상.
- QPiSSA는 QLoRA 대비 초기 단계에서 86.05% (LLaMA-3-70B 기준) 정확도 달성.
- SVD 기반 초기화는 몇 초 내 수행 가능하며, LoRA 파이프라인과 호환됨.
핵심 아이디어
LoRA는 가중치 행렬 $W$의 변화 $\Delta W$를 낮은 랭크 행렬 $A$와 $B$의 곱으로 근사하지만, $A$는 가우시안 노이즈로, $B$는 0으로 초기화되어 초기 학습 속도가 느리고 수렴이 불안정하다.
PiSSA는 $W$ 자체를 SVD로 분해하고, 가장 큰 특이값과 벡터로 $A$와 $B$를 초기화함으로써, 학습 초기부터 의미 있는 변화를 유도한다. 잔여 성분 $W^{res}$는 고정되어 메모리 사용을 줄이고, 주성분 $W^{pri}$만 학습함으로써 빠른 수렴과 성능 향상을 동시에 달성한다.
이러한 초기화 전략은 LoRA의 무작위 초기화와 달리, 학습 방향이 명확해지고, 학습 속도가 향상되며, 특히 정량화(QPiSSA) 시에도 QLoRA보다 더 낮은 오차를 보인다.
기술적 접근법
- **모델 아키텍처**: LoRA와 동일한 아키텍처를 사용하며, $A \in \mathbb{R}^{m \times r}$, $B \in \mathbb{R}^{r \times n}$, $r \ll \min(m,n)$
- **초기화 방법**: $A$와 $B$는 $W$의 주성분(SVD 기반)으로 초기화, $W^{res}$는 고정
- **학습 전략**: $W^{pri}$만 학습, $W^{res}$는 동결
- **정량화 호환**: QPiSSA는 4-bit 정량화를 적용하며, $W^{res}$에만 적용하여 $W^{pri}$는 full precision 유지
- **하이퍼파라미터**: 학습률 2e-5, 배치 크기 128, AdamW 최적화, 코사인 스케줄링, warmup 0.03
주요 결과
- **GSM8K**: Mistral-7B 기반 PiSSA는 LoRA 대비 5.16% (72.86% vs. 67.7%) 정확도 향상
- **LLaMA-3-70B**: QPiSSA는 QLoRA 대비 4.32% (86.05% vs. 81.73%) 정확도 향상
- **모델 크기**: 184M~70B 크기의 12개 모델에서 PiSSA가 LoRA를 꾸준히 상회
- **랭크 비교**: PiSSA는 LoRA보다 랭크가 낮아도 동일 또는 더 높은 성능 달성
- **수렴 속도**: PiSSA는 학습 초기부터 손실 감소 및 정확도 향상이 빠르며, LoRA보다 빠르게 수렴
의의 및 한계
PiSSA는 LoRA의 초기화 문제를 해결하고, SVD 기반의 주성분 초기화를 통해 빠른 수렴과 정확도 향상을 동시에 달성함으로써, 대형 언어 모델의 효율적인 미세조정에 기여한다. 특히 QPiSSA는 정량화 오차를 줄이며 메모리 효율성을 향상시키는 데 유리하다.
하지만 PiSSA는 SVD 계산이 필요하므로, 초기화 단계에서 약간의 추가 계산 비용이 발생한다. 또한, $W^{res}$가 고정되기 때문에, 일부 경우 잔여 성분의 영향이 모델 성능에 부정적으로 작용할 수 있다.
LoRA와 동일한 아키텍처를 사용하므로, 기존 LoRA 파이프라인에 쉽게 통합할 수 있으며, 다양한 모델과 작업에서 꾸준한 성능 개선을 보인다.
실용적 활용
PiSSA는 대형 언어 모델의 메모리 효율적인 미세조정이 필요한 산업 현장, 특히 70B 이상의 초대형 모델을 활용하는 자연어 생성(NLG) 및 이해(NLU) 작업에 적합하다. QPiSSA는 정량화 기반의 저비용 학습을 필요로 하는 클라우드 서비스, 모바일 애플리케이션, 에지 기기 등에서도 유용하게 활용될 수 있다.