대규모 언어 모델의 컨텍스트 윈도우 확장: 위치 보간법을 통한 접근
Extending Context Window of Large Language Models via Positional Interpolation
June 27, 2023
저자: Shouyuan Chen, Sherman Wong, Liangjian Chen, Yuandong Tian
cs.AI
초록
우리는 RoPE 기반으로 사전 학습된 LLaMA 모델과 같은 대형 언어 모델(LLM)의 컨텍스트 윈도우 크기를 최대 32768까지 확장하는 위치 보간법(Position Interpolation, PI)을 제안합니다. 이 방법은 최소한의 미세 조정(1000단계 이내)만으로도 패스키 검색, 언어 모델링, 긴 문서 요약 등 긴 컨텍스트가 필요한 다양한 작업에서 LLaMA 7B부터 65B까지 강력한 실험 결과를 보여줍니다. 동시에, 위치 보간법으로 확장된 모델은 원래 컨텍스트 윈도우 내의 작업에서도 상대적으로 우수한 품질을 유지합니다. 이를 달성하기 위해 위치 보간법은 입력 위치 인덱스를 선형적으로 축소하여 원래 컨텍스트 윈도우 크기에 맞추며, 훈련된 컨텍스트 길이를 초과하여 외삽(extrapolation)하는 방식과 달리 자기 주의 메커니즘을 완전히 무너뜨릴 수 있는 치명적으로 높은 주의 점수를 방지합니다. 우리의 이론적 연구는 보간법의 상한이 외삽법에 비해 최소 약 600배 작음을 보여주며, 이는 보간법의 안정성을 더욱 입증합니다. 위치 보간법으로 확장된 모델은 원래의 아키텍처를 그대로 유지하며, 대부분의 기존 최적화 및 인프라를 재사용할 수 있습니다.
English
We present Position Interpolation (PI) that extends the context window sizes
of RoPE-based pretrained LLMs such as LLaMA models to up to 32768 with minimal
fine-tuning (within 1000 steps), while demonstrating strong empirical results
on various tasks that require long context, including passkey retrieval,
language modeling, and long document summarization from LLaMA 7B to 65B.
Meanwhile, the extended model by Position Interpolation preserve quality
relatively well on tasks within its original context window. To achieve this
goal, Position Interpolation linearly down-scales the input position indices to
match the original context window size, rather than extrapolating beyond the
trained context length which may lead to catastrophically high attention scores
that completely ruin the self-attention mechanism. Our theoretical study shows
that the upper bound of interpolation is at least sim 600 times smaller
than that of extrapolation, further demonstrating its stability. Models
extended via Position Interpolation retain its original architecture and can
reuse most pre-existing optimization and infrastructure.