데이터 분포가 중요하다: LLM Context Compression의 Data-Centric 관점
Data Distribution Matters: A Data-Centric Perspective on Context Compression for Large Language Model
TL;DR Highlight
LLM context 압축 성능은 모델 구조보다 데이터 분포가 결정하며, encoder보다 decoder의 학습 데이터가 압축 품질을 지배한다.
Who Should Read
RAG 파이프라인이나 long-context 처리에서 context 압축 기법(LLMLingua, ICAE 등)을 도입하거나 커스터마이징하려는 ML 엔지니어. encoder-decoder 기반 압축 시스템을 설계하거나 도메인 특화 LLM을 압축 모듈로 활용하려는 개발자.
Core Mechanics
- 입력 텍스트의 entropy(정보 복잡도)가 높을수록 압축 품질이 떨어진다 — 수학/코드 같은 고밀도 텍스트는 일반 웹 텍스트보다 압축이 훨씬 어렵다
- encoder와 decoder가 서로 다른 데이터로 사전학습되면 압축 품질이 크게 하락한다 — Qwen2.5-Base + Qwen2.5-Coder 조합 시 BLEU가 80.02 → 64.61로 급락
- 압축 품질은 encoder보다 decoder의 학습 데이터 분포가 결정한다 — encoder를 바꾸는 것보다 decoder 분포를 맞추는 게 훨씬 효과적
- 모델 크기를 키우는 것(scaling)으로 분포 불일치를 완전히 극복할 수 없다 — 분포를 맞춘 500M+500M 쌍이 불일치 상태의 500M+1B 쌍보다 성능이 좋거나 비슷
- 극단적인 분포 불일치(decoder가 랜덤 텍스트로 학습된 경우) 시 압축 결과가 완전히 무의미한 노이즈가 된다
- compute 효율을 위해서는 작은 encoder + 큰 decoder 조합이 최적이다 — encoder 크기 증가는 압축 latency를 크게 올리지만 성능 향상은 미미
Evidence
- encoder-decoder 분포 일치 시 F1 96.96%, BLEU 80.02% vs 불일치(Base+Coder) 시 F1 92.15%, BLEU 64.61%로 BLEU 19% 하락
- decoder 분포 불일치가 심할수록(D1→D6) F1이 81.57% → 69.44%로 단조 감소, BLEU는 42.12% → 27.02%로 급락
- 분포 불일치 상태에서 decoder를 키웠을 때(500M→1B) F1이 75.86%→82.87%로 개선되지만, 분포 일치된 500M+500M(81.57%)과 비슷한 수준에 불과
- encoder 압축 latency: 200M→1B로 키울 때 1.4ms→7.4ms(5배 증가), decoder 압축 latency는 4.7ms→5.5ms(17% 증가)로 encoder 확장이 latency 부담이 훨씬 큼
How to Apply
- RAG에서 외부 압축 모듈(encoder)을 붙일 때, encoder보다 실제 답변을 생성하는 LLM(decoder)의 학습 도메인에 맞는 데이터로 fine-tuning 하면 더 효과적이다
- 도메인 특화 압축이 필요한 경우(코드, 수학 문서 등), 범용 web text로 학습된 압축 모델 대신 해당 도메인 데이터로 사전학습된 모델을 decoder로 선택하라 — encoder 교체보다 우선순위가 높다
- 압축 시스템 설계 시 encoder는 작게, decoder는 크게 배분하는 게 FLOPs 대비 성능이 좋다 — encoder를 키워봤자 latency만 늘고 성능 향상이 적다
Code Example
# 압축 모듈 선택 체크리스트 (pseudo-code)
# 핵심 원칙: decoder 분포 우선 맞추기
# 1. 처리할 도메인 파악
domain = 'code' # or 'math', 'general', 'legal'
# 2. decoder(생성 LLM)의 학습 도메인 확인
decoder_model = 'Qwen2.5-Coder-7B' # 코드 특화
# 3. encoder(압축기) 선택: decoder 도메인에 맞춰야 함
# Bad: encoder=general_model, decoder=code_model → BLEU 급락
# Good: encoder=code_model, decoder=code_model → 최적
# Acceptable: encoder=general, decoder=general → 일관성 유지
# 4. fine-tuning 데이터도 decoder 도메인 기준으로 선택
finetune_data = load_domain_data(decoder_model.training_domain)
# 5. 크기 배분: encoder < decoder 권장
encoder_size = '500M' # 작게
decoder_size = '7B' # 크게
# encoder를 1B로 키워도 latency만 늘고 성능 향상 미미Terminology
Related Resources
Original Abstract (Expand)
The deployment of Large Language Models (LLMs) in long-context scenarios is hindered by computational inefficiency and significant information redundancy. Although recent advancements have widely adopted context compression to address these challenges, existing research only focus on model-side improvements, the impact of the data distribution itself on context compression remains largely unexplored. To bridge this gap, we are the first to adopt a data-centric perspective to systematically investigate how data distribution impacts compression quality, including two dimensions: input data and intrinsic data (i.e., the model's internal pretrained knowledge). We evaluate the semantic integrity of compressed representations using an autoencoder-based framework to systematically investigate it. Our experimental results reveal that: (1) encoder-measured input entropy negatively correlates with compression quality, while decoder-measured entropy shows no significant relationship under a frozen-decoder setting; and (2) the gap between intrinsic data of the encoder and decoder significantly diminishes compression gains, which is hard to mitigate. Based on these findings, we further present practical guidelines to optimize compression gains.