# Attention in Natural Language Processing

자연어 처리에서의 어텐션

Andrea Galassi, Marco Lippi, Paolo Torroni · arXiv · 2019년 2월 4일

- **연구 문제** 어텐션은 입력 원소의 관련도를 학습하는 신경망 메커니즘이지만 구현 방식이 매우 다양하여, 이 논문은 이를 하나의 일반 모델과 네 차원의 분류 체계로 정리합니다.
- **연구 방법** RNNsearch의 정렬 점수와 softmax 가중치를 출발점으로, 키·질의·값·호환 함수·분포 함수로 이루어진 일반 어텐션 모델을 정의합니다.
- **주요 결과** 이 논문은 어텐션 모델을 입력 표현, 호환 함수, 분포 함수, 다중성의 네 차원으로 체계화하며, 경험적 성능 비교는 제시하지 않습니다.

## 어텐션이 필요한 이유와 연구 범위

많은 자연어 처리 문제에서 입력 원소는 과제에 대한 관련도가 서로 다릅니다. 감성 분석에서는 특정 측면을 설명하는 단어만 중요하고, 기계 번역에서는 다음 단어를 만들 때 원문의 일부 단어만 필요합니다. 이러한 문제를 해결하려면 입력의 관련도를 모델이 스스로 학습하고 계산 자원을 중요한 원소에 집중시킬 수 있어야 합니다. 이 논문은 이 메커니즘인 어텐션을 자연어 처리 관점에서 하나의 일반 모델로 정리하고, 벡터 표현을 입력으로 하는 어텐션 구조를 대상으로 삼습니다. 원문은 어텐션의 실험적 성능 비교를 목적으로 하지 않으며, 여러 과제와 데이터셋을 하나의 표준으로 평가하는 경험적 비교는 범위 밖이라고 밝힙니다.

## RNNsearch 예시로 본 어텐션의 동작

RNNsearch는 어텐션을 기계 번역에 적용한 대표 구조입니다. 양방향 RNN 인코더가 입력 x의 각 원소마다 주석 h\_i를 계산하고, 디코더는 매 시점 t마다 이전 은닉 상태 s\_(t-1)과 주석들을 정렬 모델에 넣어 점수 e\_ti를 얻습니다. 이 점수는 softmax로 정규화되어 a\_ti = exp(e\_ti) / Σ\_j exp(e\_tj) 형태의 가중치가 됩니다. 마지막으로 문맥 벡터 c\_t = Σ\_i a\_ti h\_i가 계산되며, 이 벡터가 디코더 RNN의 다음 출력 분포 계산에 쓰입니다. 즉 고정 길이 벡터 하나에 전체 원문을 압축하지 않고, 주석 전체에서 필요한 정보를 시점마다 선택해 가져오는 방식입니다.

![Figure 2: Architecture of RNNsearch \[2\] ( left) and its attention model (right)](https://refivu.com/papers/256bf9a6-8f17-4632-954e-011dbadca408/figures/figure-74448dd22ae9e59ea6673a5d6d28eb46.png?thumb=512)

**Fig. 2** . Architecture of RNNsearch \[2\] ( left) and its attention model (right).

[원문](https://arxiv.org/abs/1902.02181v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Andrea Galassi, Marco Lippi, Paolo Torroni · Attention in Natural Language Processing · 원문 그림 인용 · 원본 PDF 3쪽에서 그림 영역을 추출했습니다.

## 키, 질의, 값으로 나눈 일반 어텐션 모델

논문은 RNNsearch의 구조를 일반화하여 키 K, 질의 q, 값 V, 호환 함수 f, 분포 함수 g로 구성된 모델을 제시합니다. 키 K는 어텐션 분포를 계산하는 데이터 특징이고, 질의 q는 선택적으로 쓰이는 기준 원소입니다. 호환 함수는 e = f(q, K)로 에너지 점수를 만들고, 분포 함수는 a = g(e)로 이를 가중치로 바꿉니다. 값 V가 있으면 Z\_i = a\_i v\_i 형태로 값을 가중하고, c = Σ z\_i로 문맥 벡터를 얻습니다. 논문은 질의가 어텐션의 기준을 제공하는 일반 구조이며 질문 응답·정보 검색의 질의와는 다른 개념이라고 구분합니다.

![Figure 3: Core attention model](https://refivu.com/papers/256bf9a6-8f17-4632-954e-011dbadca408/figures/figure-a7b346fa9e3957c31c632957e73184c9.png?thumb=512)

**Fig. 3** . Core attention model.

[원문](https://arxiv.org/abs/1902.02181v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Andrea Galassi, Marco Lippi, Paolo Torroni · Attention in Natural Language Processing · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.

## 네 가지 차원으로 나눈 어텐션 분류

논문은 어텐션 모델을 입력 표현, 호환 함수, 분포 함수, 입출력 다중성이라는 네 차원으로 분류합니다. 입력 표현에서는 문맥 인코딩을 쓰는 방식과 원자료 임베딩에 직접 적용하는 inner attention, 자기 자신을 질의로 쓰는 self-attention, 계층 구조를 쓰는 hierarchical-input 방식을 구분합니다. 호환 함수에서는 유사도 기반의 내적 계열, 질의를 키 공간으로 바꾸는 general attention, 결합 표현을 쓰는 additive·concat attention, 합성곱 기반 방식을 다룹니다. 분포 함수에서는 softmax와 sigmoid, sparsemax, 위치 제약, 하드 어텐션과 지역 어텐션을 비교합니다.

다중성에서는 multihead, multidimensional, coattention을 설명합니다.

![Figure 4: General attention model](https://refivu.com/papers/256bf9a6-8f17-4632-954e-011dbadca408/figures/figure-2c10fd6c76ce33ab64e4de9e0757ad33.png?thumb=512)

**Fig. 4** . General attention model.

[원문](https://arxiv.org/abs/1902.02181v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Andrea Galassi, Marco Lippi, Paolo Torroni · Attention in Natural Language Processing · 원문 그림 인용 · 원본 PDF 5쪽에서 그림 영역을 추출했습니다.

![Figure 6: Hierarchical input attention models deﬁned by Zhao and Zhang \[43\] (center), Yang et al. \[52\] (left), and Ma et al. \[113\] (right). The number inside t…](https://refivu.com/papers/256bf9a6-8f17-4632-954e-011dbadca408/figures/figure-5f3fcaaae7ccf81ee05661e76d79da24.png?thumb=512)

**Fig. 6** . Hierarchical input attention models deﬁned by Zhao and Zhang \[43\] (center), Yang et al. \[52\] (left), and Ma et al. \[113\] (right). The number inside the attention shapes indicates the order of application. Di fferent colors highlight different parts of the inputs.

[원문](https://arxiv.org/abs/1902.02181v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Andrea Galassi, Marco Lippi, Paolo Torroni · Attention in Natural Language Processing · 원문 그림 인용 · 원본 PDF 8쪽에서 그림 영역을 추출했습니다.

## Coattention과 집계 함수

Coattention은 질의와 키가 모두 시퀀스인 경우를 다룹니다. coarse-grained 방식은 한쪽의 압축 표현을 다른 쪽 어텐션의 질의로 사용하고, fine-grained 방식은 키 원소와 질의 원소의 모든 쌍에 대해 cocompatibility 함수로 행렬 E를 계산합니다. 이후 aggregation 함수가 E로부터 키의 가중치 a\_K와 질의의 가중치 a\_Q를 얻습니다. 예를 들어 attention pooling 방식은 행과 열의 최댓값을 취해 한 키가 적어도 하나의 질의 원소와 강하게 연결되면 높은 가중치를 받도록 합니다. 원문은 이러한 방식이 특정 과제에 적합하다고 설명하지만, 모든 질의 원소와의 관계를 함께 고려하는 방식은 계산 비용이 더 크다고 보고합니다.

## 사전 지식과 해석의 한계

논문은 어텐션 가중치가 입력의 관련도를 보여 준다는 점에서 해석 도구로 쓰일 수 있다고 설명합니다. 그러나 최근 연구들은 어텐션이 신뢰할 수 있는 설명 수단이라고 보기 어렵다는 결과를 제시했습니다. Jain과 Wallace는 어텐션이 다른 설명 지표와 일치하지 않으며 비슷한 분포에서 다른 결과를 만들 수 있음을 보였습니다. Wiegreffe와 Pinter는 어텐션 가중치가 설명 가능성을 가질 수 있지만, 그 설명은 충실한 재구성보다 그럴듯한 재구성에 가깝다고 보았습니다. 논문은 이 논쟁을 소개하면서도 어텐션 설명의 신뢰성을 결론으로 확정하지 않습니다.

![Figure 1: Example of attention visualization for an aspect-based sentiment a nalysis task, from \[1, Fig. 6\]. Words are highlighted according to attenti on scor…](https://refivu.com/papers/256bf9a6-8f17-4632-954e-011dbadca408/figures/figure-c2dc847cdfe246a73a8d0b93d84de7bc.png?thumb=512)

**Fig. 1** . Example of attention visualization for an aspect-based sentiment a nalysis task, from \[1, Fig. 6\]. Words are highlighted according to attenti on scores. Phrases in bold are the words considered relevant for the task or human rationales.

[원문](https://arxiv.org/abs/1902.02181v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Andrea Galassi, Marco Lippi, Paolo Torroni · Attention in Natural Language Processing · 원문 그림 인용 · 원본 PDF 2쪽에서 그림 영역을 추출했습니다.

## 논문 정보

- **저자**: Andrea Galassi, Marco Lippi, Paolo Torroni
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2019년 2월 4일
- **등록일**: 2026년 11월 6일
- **수정일**: 2021년 10월 11일
- **버전**: v4
- **arXiv**: 1902.02181
- **DOI**: 10.1109/tnnls.2020.3019893
- **분류**: cs.CL · cs.AI · cs.LG · stat.ML
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/1902.02181v4) · [원문 PDF ↗](https://arxiv.org/pdf/1902.02181v4)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

Attention is an increasingly popular mechanism used in a wide range of neural architectures. The mechanism itself has been realized in a variety of formats. However, because of the fast-paced advances in this domain, a systematic overview of attention is still missing. In this article, we define a unified model for attention architectures in natural language processing, with a focus on those designed to work with vector representations of the textual data. We propose a taxonomy of attention models according to four dimensions: the representation of the input, the compatibility function, the distribution function, and the multiplicity of the input and/or output. We present the examples of how prior information can be exploited in attention models and discuss ongoing research efforts and open challenges in the area, providing the first extensive categorization of the vast body of literature in this exciting domain.

## 원문 인용

Andrea Galassi, Marco Lippi, Paolo Torroni (2019). Attention in Natural Language Processing. arXiv:1902.02181v4. https://doi.org/10.1109/tnnls.2020.3019893

**BibTeX**

```
@article{galassi2019attention,
  title = {{Attention in Natural Language Processing}},
  author = {Andrea Galassi and Marco Lippi and Paolo Torroni},
  year = {2019},
  eprint = {1902.02181},
  archivePrefix = {arXiv},
  doi = {10.1109/tnnls.2020.3019893},
  url = {https://arxiv.org/abs/1902.02181v4}
}
```

## 이 논문의 용어

- [트랜스포머](https://refivu.com/terms/515e8433c447-transformer)
- [Self-attention](https://refivu.com/terms/426589b81077-self-attention)
- [어텐션](https://refivu.com/terms/28f6748abd85-attention)
- [softmax function](https://refivu.com/terms/ce0db7dbb3f0-softmax-function)
- [context vector](https://refivu.com/terms/48425b908472-context-vector)
- [soft attention](https://refivu.com/terms/273692c14df4-soft-attention)
- [RNNsearch](https://refivu.com/terms/83d9bbdf5979-rnnsearch)
- [sparsemax](https://refivu.com/terms/1e58f0a25e6f-sparsemax)
- [additive attention](https://refivu.com/terms/dc1effe7dceb-additive-attention)
- [attention weights](https://refivu.com/terms/d95d24af291e-attention-weights)

## 다른 논문 해설

- [Colors in Context: A Pragmatic Neural Model for Grounded Language Understanding](https://refivu.com/papers/148fcde3-f576-427f-9081-2cd85deb9e75-colors-in-context-a-pragmatic-neural-model-for.md)
- [Artificial intelligence for topic modelling in Hindu philosophy: mapping themes between the Upanishads and the Bhagavad Gita](https://refivu.com/papers/aecce9c4-3787-4579-a0df-84851b7e8dae-artificial-intelligence-for-topic-modelling-in-hindu.md)
- [Investigating Reasons for Disagreement in Natural Language Inference](https://refivu.com/papers/d6c693ee-1ad9-454f-8f33-d3fcb1408c3a-investigating-reasons-for-disagreement-in-natural-language.md)
- [An Explainable CNN Approach for Medical Codes Prediction from Clinical Text](https://refivu.com/papers/2e80fa24-ec99-471e-8338-d3af6d4e8122-an-explainable-cnn-approach-for-medical-codes-prediction.md)
- [Automated stance detection in complex topics and small languages: the challenging case of immigration in polarizing news media](https://refivu.com/papers/d2852de3-abf0-4dd3-b05b-947ced08925e-automated-stance-detection-in-complex-topics-and-small.md)
- [From Rule-Based Models to Deep Learning Transformers Architectures for Natural Language Processing and Sign Language Translation Systems: Survey, Taxonomy and Performance Evaluation](https://refivu.com/papers/ce85494f-1413-48ab-981f-68dc7b69122d-from-rule-based-models-to-deep-learning-transformers.md)
- [Opportunities of Federated Learning in Connected, Cooperative and Automated Industrial Systems](https://refivu.com/papers/89e8abf3-ce47-4c58-b573-96854872a424-opportunities-of-federated-learning-in-connected-cooperative.md)
- [Deep Reinforcement Learning framework for Autonomous Driving](https://refivu.com/papers/baaead94-eeef-4412-9a69-b14b7ab4fe14-deep-reinforcement-learning-framework-for-autonomous-driving.md)
- [Trust-based Multi-Robot Symbolic Motion Planning with a Human-in-the-Loop](https://refivu.com/papers/e3586fad-ef02-4544-b009-0291099ef267-trust-based-multi-robot-symbolic-motion-planning-with.md)
- [U-shape Transformer for Underwater Image Enhancement](https://refivu.com/papers/090ea979-276e-4ff3-b5ba-8d3483b8e2e8-u-shape-transformer-for-underwater-image-enhancement.md)
- [Robot Hand-Eye Calibration using Structure-from-Motion](https://refivu.com/papers/8cf8ecb1-b46a-4eb2-ac42-2e908a432755-robot-hand-eye-calibration-using-structure-from-motion.md)
- [MSRF-Net: A Multi-Scale Residual Fusion Network for Biomedical Image Segmentation](https://refivu.com/papers/6a391bec-28c7-48c8-b3ae-92ae5788cd01-msrf-net-a-multi-scale-residual-fusion-network.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/256bf9a6-8f17-4632-954e-011dbadca408-attention-in-natural-language-processing)
