[ICLR 2020] On Identifiability in Transformers 논문 정리
ICLR 2020 NLP 논문 읽기(6)
Abstract만 읽고 정리해보기
- 이 논문에서는 Transformer의 핵심 구성요소인 self-attention과 contextual embeddings을 조사하여 깊게 파고듦
- 특히, attention weights와 token embedding의 identifiability (식별 가능성), hidden token에 대한 context의 aggregation에 대해서 다룸
- attention head dimension보다 긴 sequences의 경우, attention weight는 식별할 수 없음을 보임 → attention 기반의 설명할 수 있는 해석을 개선하는 보충 tool로 ‘effective attention’을 제안 → 입력 토큰이 모델 전체를 걸쳐 그들의 identity를 큰 부분 유지하는 것을 보임
- identity information이 주로 embedding의 각도로 encode되어 있고, 깊이에 따라 점차적으로 감소하는 것을 암시하는 증거를 발견
- gradient attribution 기반의 새로운 quantification 방법을 통해 contextual embedding 생성 시 입력 정보가 강하게 혼합되는 것을 보임
- self-attention 분포를 직접적으로 해석할 수 없기에, 이 Transformer 모델을 보다 잘 이해하고 조사할 수 있는 tool을 제시
Introduction
identifiability는 안정된 representaiton을 배우는 모델의 능력이고, 모델의 예측의 복제 가능성과 해석 가능성에 영향을 주기 때문에 중요한 성질
Two aspects of Identifiability
- Structural Identifiability
- 통계적 모델의 고유한 최적의 매개변수화를 배우는 이론적인 확률
- 이 관점에서 대해 transformer의 self-attention 구성요소의 attention weights의 identifiability를 분석 (attention identifiability)
2. Token Identifiability
- 모델에 의해 생성된 입력과 출력 사이의 word-level mappings
- input-output mappings을 복구하는 수단으로의 attention의 role과 다양한 유형의 설명할 수 있는 insight는 현재 많은 연구에 초점이 맞추어져 있음 (두 유형의 identifiability에 상당 부분 의존적)
Attention Identifiability
multi-head attention의 output은 h개의 single head outputs에 대한 합이다. 즉, matrix H에 의해 곱해지는 결과이다.
AV는 Transformer의 self-attention 식이고, VH를 T로 보았는데,
sequence length (d_s)가 attention head(value vector)의 dimension (d_v)보다 클 때, T가 non-trivial (left) null space를 가진다.
이는 같은 출력 값을 생성하는 무한대 급의 서로 다른 attention weights가 있다는 것을 암시한다.
→ non-identifiable
Effective Attention
결국 이러한 문제를 해결하기 위한 대책이 필요한데, 여기서 attention weights A를 다음과 같이 분리할 수 있다.
null space 위에 있는 A 와 그와 직교하는 A로 나눌 수 있고, 여기서 null space와 직교하는 A를 effective attention으로 사용할 것이다. A에 A를 T의 left null space에 대하여 projection한 값을 빼면 effective attention을 구할 수 있다.
모델의 예측에 영향을 주지 않는 weight 요소 (left null space 위에 있는 A)를 지워 attention weight를 모델에 대한 설명으로 조사할 수 있다.
Token Identifiability
contextual word embedding이 연속적인 (여러) Transformer layer를 통과할 때, 그들만의 identify를 유지한다는 가설이 있는데, 현재 대부분의 연구에서 하고 있는 가정이지만 clear한 validation은 없었다.
따라서 이에 대한 실험할 수 있는 환경을 구축하였다.
i번째 embedding에 대하여 i번째 token을 출력하는 classification function이존재하면 embedding이 identifiable하다고 말할 수 있다.
이러한 함수를 근사하는 function approximator ‘g’를 embedding과 token을 pair로 하는 데이터셋으로 학습을 하고, g`에 1- nearest neighbor lookup을 해서 그 값이 올바른 token인지를 검증한다. (token identifiability rate)
결론: 대부분의 token이 identifiable하게 유지된다 (하지만, 항상 later layers에서 유지되는 것은 아니다)
Hidden Token Attribution
hidden embedding에 있는 input token의 양은?
token 정보과 context 정보의 mixing에 대한 양을 알기 위해 contextual embedding을 만들 때 모든 input token의 contribution을 조사하였다.
gradient attribution 기반의 수량화 방법인 Hidden Token Attribution이다
self-attention이 강력하게 context 분포와 token 분포를 섞는 것을 발견하였다.
token contribution은 layer의 깊이에 따라 단조롭게 감소하지만, 해당 토큰은 가장 큰 개별적인 contributor로 남아있다.
(첫 layer를 통과한 input token의 contribution은 약 30%)
Conclusion (in presentations)
- Attention is not identifiable → Effective Attention
- Token remain largely identifiable
- Hidden Token Attribution → Tokens mix heavily
My Discussion
identifiability에 대해서 처음 접해보았다. 통계 쪽 수업을 들어보지 않아서 처음에 이를 이해하는데 오랜 시간이 걸렸다. Transformer 모델이 자연어에서 핵심적인 역할을 하는 만큼 identifiability에 대한 조사는 확실히 필요했다고 생각한다. 이전까지는 Abstract만 읽어도 논문에 대한 이해가 얼추 되었는데, 이번에는 정리를 하고 나서 내가 기록한 ‘Abstract만 읽고 정리해보기’를 읽어보았는데 제대로 감을 못잡은 상태에서 읽었던 것 같다.
All figure (pictures) I used in this post is from “ICLR: On Identifiability in Transformers” presentations