Introduction to Mechanistic Interpretability (기계적 해석의 전반적인 설명)
Last updated
Last updated
Hi there! We're a small group from South Korea diving into the fascinating field of mechanistic interpretability (MI). As we explore this area, we thought it would be a great idea to translate key papers, including articles from the Transformer Circuits Thread and LessWrong, into Korean. Our aim for this project is to spark some interest and (hopefully) expand the audience in Korea, which is currently quite small. Keep in mind, our translations might have minor errors as we're still learning the field, and we always respect the original authors' work.
딥러닝 모델의 용도가 더 다양해지고 강력해짐에 따라, 이런 AI 모델에 대한 설명 가능성 (eXaplainable AI; XAI)에 대한 목소리도 높아지고 있다. AI 모델의 성능이 폭발적으로 증가하기 이전 (ChatGPT 이전) 당시 XAI 연구는, 이러한 딥러닝 모델을 이해하기 위한 도구로 해석 가능성을 접근하는 경우가 많았다. 하지만 LLM (Large Language Models)과 강력한 이미지 및 비디오 생성모델 등이 현실 서비스로 다가온 현 시대에는 이러한 모델들이 인간 생활에 유의미한 위협을 가할 수 있음을 인지하는 추세이며, 이에 따라 XAI의 중요성 또한 강조되고 있다.
비교적 최근까지 XAI 연구는 behavioral (LIME, Shapley 등) 및 attributional (GradCAM, LRP 등) 와 같은 방법론에 의존하였다 (물론 concept-based 및 counterfactual 등 다른 갈래 또한 존재한다). 하지만 이런 방법론들은 모두 이 gitbook이 소개하는 mechanistic interpretability (MI)와 비교했을 때 추상적인 단계에서 모델 해석을 제공한다. 비교적 최근에 주목받기 시작한 MI는 모델에 대한 해석을 제공하는 방법론 중 가장 low-level이며, 수많은 parameter들 사이에서 우리가 이해할만한 작동 부품을 골라내려고 노력한다. 이런 접근법 때문에 이 gitbook 저자들은 XAI의 미래가 MI에 있다고 설득되었으며, MI를 이해하고 공부하는 일종의 과정으로 주요 논문, article 등을 번역/요약하여 이 곳에 정리하려고 한다.
ChatGPT와 같은 general AI가 발전하면서, AI를 decision making 도구로 활용하는 사례가 늘고 있다. 이렇듯 모델 고도화를 위한 연구 분야가 있는 반면, AI의 투명성과 신뢰성을 강조하는 AI-Safety 분야도 존재한다. 이러한 두 분야를 지속적으로 발전시키기 위해 모델 내부의 매커니즘에 대해 이해할 필요가 있으며, 이를 위한 핵심 연구가 바로 Explainable AI(XAI)이다.
Interpretability Paradigms
(Bereska & Gavves, 2024)에 의하면, 현재까지 XAI는 크게 네 개의 분야로 나눌 수 있다:
Behavioral Interpretability
모델을 black box (내부 구조를 전혀 알 수 없는 상태)로 간주하고, input과 output의 relation을 통한 해석
ex) LIME, Shapley values etc.
Attributional Interpretability
모델 output에 input의 각 feature가 얼만큼 기여를 했는지를 통한 해석 (일종의 '중요도' 점수를 매기는 방식)
ex) GradGAM, LRP, Gradient, Deep Taylor Decomposition, Integrated Gradient etc.
Concept-based Interpretability
모델의 learned or latent representation을 중심으로 분석하는 top-down approach
ex) Supervised Auxiliary Classifiers
Mechanistic Interpretability (reverse-engineering; 역설계)
Output을 만들어내기 위한 핵심적인 구성요소 (ex. neurons, layers, circuit 등)들 및 그들 사이의 구동 방식을 찾아내는 bottom-up approach
Bottom-up 기반의 reverse engineering (역설계) 해석 방식
Mechanistic Interpretability (MI)는 XAI의 여러 패러다임 중 모델의 내부 메커니즘(internal cognition)을 가장 디테일한 수준으로 이해하는 것을 목표로 한다. 구체적으로, 대부분의 XAI가 intermediate representation (혹은 input)과 model이 만들어낸 결과값 간의 상관관계를 파악하는데에 집중을 하는 것과 달리, MI는 그 결과값을 만들어내기까지의 일련의 과정에 기여하는 정확한 내부 메커니즘을 파악하려고 한다. 이러한 과정은 비유하자면 complied binary로부터 source code를 역으로 디코딩하는 것과 유사하다고 하여, MI는 reverse-engineering으로도 불리기도 한다.
최근 Mechanistic Interpretability에 대한 다양한 연구가 진행되고 있으며, 몇 가지 예시들을 들자면:
Universality (보편성 관련)
같은 문제를 푸는 다른 모델들 사이에 공통적인 특징들이 발현되기도 하는가?
비슷한 문제들을 푸는 모델의 핵심 알고리즘은 서로 같은가?
In-context learning에 기여하는 핵심 뉴런이 존재하는가?
Features (내부 특정 관련)
모델에 fine-tuning을 하면 어떤 내부적인 변화가 일어나는가?
모델들은 superposition을 사용하는가? 즉, 뉴런 하나가 한 가지, 혹은 여러 일을 도맡아 하는가?
Circuits (모델 내부 부품들간의 메커니즘 관련)
레이어들의 역할이 같은가?
Attention layer의 역할은 비슷한가?
Attention head끼리 역할은 구분되어있는가?
이처럼, MI는 circuit (coarse-grained; 전반적인 수준)에서 neuron 단위 (fine-grained; 디테일한 수준)까지의 핵심 역할을 파악하고자 한다. 모델이 단순 통계적인 상관관계를 기반으로 문제를 푸는 것이 아니라, 프로세스를 “이해하고” 알고리즘을 학습한다는 것이 많은 연구에서 증명되고 있다. 그리고 이러한 연구 결과는 large language models (LLM)과 같이 인간이 이해하기 어려운 복잡한 연산을 가지고 있는 모델들의 reverse-engineering (역설계)가 가능하다는 것을 시사한다.
Polysemantic
MI의 목표 중 하나는 특정하고 뚜렷한 패턴이나 입력 유형에 일관되게 반응하는 뉴런 집합을 찾는 것 또한 포함되어있다. 다만, 일반적인 신경망에서는 개별 neuron이 다양한 입력에 다의적(polysemantic)으로 반응하는 경우가 많은 것으로 보인다. 이로 인해 각 neuron이 정확히 무엇을 나타내거나 반응하는지 이해하는 것이 어렵기도 하다.
Non-Linear Interactions
Neural network들은 ReLU, Sigmoid와 같은 non-linear function에 크게 의존하고, 이러한 non-linearity는 입력 데이터가 각 layer를 통과할 때 어떻게 변환되는지 그 과정을 추적하기 어렵게 만든다.
Complexity of models: Scalability Issues
LLM과 같이 수십억 개의 parameter를 가진 대형 모델은 수많은 layer와 non-linear functions을 가지고 있기 때문에 내부의 interaction을 파악하는 것이 까다롭다.
이를 해결하기 위해 뚜렷하고 일관된 반응 패턴을 가진 monosemantic neuron을 만들도록 학습을 강제하거나 (polysemantic의 반대되는 개념), 이러한 neuron 혹은 circuit을 찾아내는 것을 자동화하는 연구 등이 활발히 이루어지고 있다. 이렇듯 모델 내부의 특성을 하나하나 분리함으로써 모델이 동작하는 메커니즘에 대해 조금 더 명확한 이해를 가능하게 한다.
예를 들어, Anthropic의 sparse autoencoders를 활용하여 complex layer들의 monosemantic features 추출하는 연구가 있다: Towards Monosemanticity: Decomposing Language Models With Dictionary Learning
경량화: 불필요한 뉴런과 layer를 파악하고 제거하는 연구
마치 프로그램의 특성을 변형시키기 위해 decompiling을 하는것과 비슷하게, 모델을 사람이 의도한 대로 행동하도록 학습하도록 만드는 강력한 방법론으로 활용하는 연구
Trust & Safe AI
Model debugging
Bias 완화
Currently, we are just beginning to explore the field of mechanistic interpretability and have much to learn. As we delve deeper into this area, we will continue to share our findings and insights through regular blog updates. If you're interested in following our journey and staying informed about our progress, please follow this blog for future posts!
Also, check these useful references!
We share our thoughts on mechanistic interpretability once a week and plan to regularly post about what we've discussed.
Hello! I am a Ph.D candidate in Yonsei University, South Korea. My primary interest is eXplainable AI (XAI) and graph learning. Recently, I am shifting my focus to learning about mechanistic interpretability, which seems to be the future of XAI.
Hi! I work in recommendation systems and I'm eager to explore how mechanistic interpretability can be applied to enhance our system while ensuring a safe environment. If you're also interested in recsys and mechanistic interpretability, feel free to email us.