인공지능/논문 리뷰 or 진행

Adapting Language Models to Compress Contexts

이게될까 2026. 5. 10. 01:27
728x90
728x90

https://arxiv.org/abs/2305.14788

 

Adapting Language Models to Compress Contexts

Transformer-based language models (LMs) are powerful and widely-applicable tools, but their usefulness is constrained by a finite context window and the expensive computational cost of processing long text documents. We propose to adapt pre-trained LMs int

arxiv.org

 

이 논문도 llm의 제한된 context window, long context 리소스가 많이 드는 것을 말한다. 그리고 같은 문서나 페세지를 여러 번 쓸 때 전체 텍스트를 다시 attention 하는 것도 비효율로 본다.

그래서 긴 텍스트를 짧은 softprompt 형태의 summary vector로 압축하는 방식으로 해결하려고 함. 

긴 문서를 여러 segment로 나누고, 각 segment를 처리한 뒤 summary token 위치의 hidden state를 summary vector 로 활용해 이 것을 soft prompt 처럼 사용함 

이 것을 다 이어 붙여서 활용하네요 

  Recurrent Memory Transformer AutoCompressor
메모리 전달 직전 segment summary만 전달 모든 이전 segment의 summary를 누적
정보 경로 (S_{i-1} → S_i) 중심 (S_1, ..., S_{i-1} →S_i) 직접 접근
긴 문맥 유지 장거리 정보 손실 가능 summary accumulation으로 장거리 정보 유지 강화
학습 segment 고정 segment 위주 randomized segmenting 사용

잘 보이진 않는데 Auto compressor가 ppl도 낮은 장점을 가지고 있네요 

 

 

 

 

핵심 문제 Transformer LM은 context window가 제한되어 있고, 긴 문서를 full attention으로 처리하면 계산/메모리 비용이 큼. 따라서 긴 문맥을 더 짧고 재사용 가능한 형태로 압축할 필요가 있음.
핵심 아이디어 사전학습 LM을 AutoCompressor로 fine-tuning하여 긴 문맥을 summary vectors라는 짧은 continuous soft prompt로 압축함. 이 summary vectors는 이후 segment나 downstream task에서 문맥 대체재처럼 사용됨.
방법론 긴 문서를 여러 segment로 나눈 뒤, 각 segment 뒤에 <Sum> token을 붙임. 모델은 <Sum> 위치의 hidden state를 summary vector로 만들고, 다음 segment 입력 앞에 이 vector들을 soft prompt처럼 붙여 다음 토큰을 예측함.
기존 RMT와 차이 기존 RMT는 주로 직전 segment의 memory만 넘기는 구조인 반면, AutoCompressor는 summary accumulation을 통해 이전 모든 segment의 summary vectors를 누적하여 다음 segment에 제공함. 이로써 장거리 정보 보존이 더 좋아짐.
학습 objective 별도 human summary나 supervised label 없이 language modeling loss만 사용함. 즉, 이전 segment summary가 다음 segment 토큰 예측에 도움이 되도록 학습됨.
추가 학습 기법 Randomized segmenting으로 다양한 길이의 문맥 압축에 강건하게 만들고, stop-gradient를 사용해 2 compression step 이후 gradient를 끊어 GPU 메모리 사용량을 줄임. Llama-2 실험에서는 LoRA를 활용함.
실험 모델 OPT-1.3B, OPT-2.7B, Llama-2-7B 기반 AutoCompressor를 학습함. OPT는 최대 30,720-token sequence까지, Llama-2는 6,144-token sequence까지 실험함.
Long-context LM 결과 AutoCompressor는 6,144 tokens를 150 summary vectors로 압축해 perplexity를 개선했고, RMT보다 일관되게 좋은 성능을 보임. 30K-token 실험에서도 28K context를 활용해 perplexity를 낮춤.
Llama-2 결과 Llama-2-7B AutoCompressor는 4,096-token context를 100 summary vectors로 압축했을 때 Extended Full Attention의 512-token plain text context와 유사한 perplexity를 달성함. 다만 full attention보다 완전한 정보 보존은 부족함.
In-context Learning 결과 Demonstration을 summary vectors로 압축해 ICL에 사용했을 때, 11개 task 중 8개에서 150-token plain-text ICL보다 높은 성능을 보임. 일부 task에서는 750-token plain-text demonstration보다도 좋은 결과를 보임.
Retrieval 활용 대규모 corpus의 passage를 미리 summary vectors로 압축해 저장한 뒤 retrieval-augmented LM과 passage re-ranking에 사용함. Fused summary vectors는 효율성과 성능의 trade-off에서 좋은 결과를 보임.
주요 공헌 ① 사전학습 LM을 context compressor로 변환하는 방법 제안 ② summary accumulation으로 장거리 정보 유지 개선 ③ LM loss만으로 unsupervised compression 학습 ④ ICL, RAG, re-ranking에서 summary vectors의 활용 가능성 입증
핵심 한계 Summary vectors가 full attention이 접근하는 원문 정보를 완전히 보존하지 못함. 모델 규모도 OPT-2.7B, Llama-2-7B 수준에 제한됨. summary vector 수를 늘려도 항상 성능이 좋아지지 않음.
연구적 의미 이 논문은 long-context 문제를 단순히 attention 구조 확장으로 해결하지 않고, 문맥을 continuous memory로 압축해 재사용하는 방향을 제시함. Long-CoT compression, memory-augmented LM, efficient RAG, privacy-preserving representation 연구와 연결 가능성이 큼.
한 줄 평가 AutoCompressor는 긴 문맥을 latent soft prompt로 압축하여 context window 확장과 inference 비용 절감을 동시에 노린 실용적 long-context adaptation 방법이다.
728x90