C.W.K.
Stream
Lesson 03 of 05 · published

Sparse 와 Sliding Window Attention

~13 min · longformer, bigbird, sliding-window, mistral

Level 0Observer
0 XP0/50 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

근사하지 마 — 그냥 덜 attend 해

Softmax 근사가 어려우면, 대안은 softmax 를 정확히 두고 그냥 더 적은 토큰에 attend. 두 초기 production 승자는 Longformer (Beltagy et al., 2020) 와 BigBird. 둘 다 이 조합 사용: local sliding window (각 토큰이 w 이웃에 attend), global token (어디든 attend 하고 어디서든 attend 받는 작은 designated 토큰 set), BigBird 의 경우 추가 random 연결.

Cost 는 O(n·w), w 는 window size. w 가 fixed 일 때 sequence length 에 linear. 가정은 관련 정보 대부분이 local, global token 이 드문 long-range dependency 처리. 문서에는 잘 작동; 임의 long-range dependency 가진 task 에는 정보 잃어.

Production 의 sliding window: Mistral 과 Griffin

실제 widely ship 한 버전은 sliding-window attention, Mistral 7B (window 4096), Mistral Large, Google 의 Griffin family 에서 사용. 각 layer 가 최근 토큰 window 에만 attend; 모델의 stack-of-layers 구조가 의미 정보가 window 너머 propagate 가능 — 각 layer output 이 다음 layer 의 window 에 feed 하니까.

Mistral 의 architecture 선택 — sliding window 4096 에 모델은 더 높은 context length 에서 학습 — 이 이 아이디어의 productionization 이고, Mistral 모델이 long context 에서 parameter count 위로 punch 한 큰 이유. Griffin (Google, 2024) 이 sliding-window attention 을 recurrent linear-RNN component 와 결합, 비교 가능 scale 의 Gemma 의 ~2K 대비 6K tok/s hit 한 hybrid.

학습된 sparsity — NSA 와 MoBA

2025 generation 의 sparse attention 이 더 흥미로워졌어. NSA (Native Sparse Attention) 와 MoBA (Mixture of Block Attention), 둘 다 ACL 2025 논문, 학습된 sparsity 패턴 사용: 모델이 query 마다 어떤 토큰에 attend 가치 있는지 결정, hardware efficiency 위해 sparsity 제약이 kernel 안에 baked in.

학습된 sparsity 가 fixed sparsity 보다 full-attention quality 에 훨씬 가깝게 수렴. Cost: kernel 이 sliding window 보다 더 복잡, 패턴이 debug 어려울 수 있어. 근데 초기 production 결과 (Moonshot 의 Kimi family 가 이거 사용) 가 NSA-style sparsity 가 2027 까지 default sparse-attention 패턴일 것 같을 만큼 강해.

External links

Exercise

Mistral 7B 를 sliding-window enabled 와 32K-token 문서로 돌려. 그 다음 답이 single window 밖 정보 retrieve 필요한 질문 (예: 맨 처음 진술된 사실, 맨 끝에 대해 물어봄). 저하되지만 catastrophic 하지 않은 performance 봐야 — multi-layer stack 이 window-overlap 통해 정보 propagate 시키지만, 모델이 명확히 full context 를 한 번에 안 보고 있어. 이게 모델 level 에서 sliding window 의 실용 한계.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.