Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jayarnim committed Jan 30, 2025
1 parent 111e0b9 commit 1d1cfd0
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions _posts/TextAnalytics/2024-08-08-BERT.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,6 @@ image:
| Attention Heads | 12 | 16 |
| Total Parameter | 110M | 340M |

## Pre-Training for Transfer Learning
-----

![03](/_post_refer_img/TextAnalytics/11-03.jpg){: width="100%"}

- **Data Set** : 관측치 하나당 최대 두 가지 시퀀스로 구성할 수 있음

> **`CLS` `my` `dog` `is` `cute` `SEP` `he` `likes` `play` `##ing` `SEP`**
- `CLS` : 입력 정보를 종합하여 대표하는 벡터
- `SEP` : 문장 구분자

- **MLM(`M`asked `L`anguage `M`odel)** : 입력 문장에서 일부는 `MASK` 로 가리고, 일부는 다른 단어로 무작위 변경한 후(10%), 원래 단어를 예측하도록 양방향 학습함으로써 일반화된 언어 패턴을 학습하고 문맥을 이해하는 능력을 강화함

| 역할 | 처리 방법 | 비중 |
|---|---|---|
| CONTEXT | 변경하지 않음 | 85% |
| PREDICTION | MASK | 12% |
| PREDICTION |무작위 변경 | 1.5% |
| PREDICTION | 변경하지 않음 | 1.5% |

- **Bidirection** : 트랜스포머 디코더가 단방향 예측($t-1$ 시점까지 정보를 기반으로 $t$ 시점을 예측)을 수행했던 것과 달리, 버트는 양방향 예측(이전 시점과 이후 시점의 정보를 종합하여 $t$ 시점을 예측)을 수행하므로, 문맥 벡터 생성 시 미래 순번 정보를 모두 마스킹 처리하지 않음

- **NSP(`N`ext `S`entence `P`rediction)** : `CLS` 토큰을 기반으로 두 문장이 연속된 문장인지 아닌지 예측하도록 학습함으로써 문장 간 관계를 학습함

![06](/_post_refer_img/TextAnalytics/11-06.jpg){: width="100%"}

## Word Representation
-----

Expand All @@ -72,6 +45,13 @@ $$\begin{aligned}
| Max Seq | 512 |
| Max Sentence | 2 |

- **Each observation can contain up to two sequences**

> **`CLS` `my` `dog` `is` `cute` `SEP` `he` `likes` `play` `##ing` `SEP`**
- `CLS` : 입력 정보를 종합하여 대표하는 벡터
- `SEP` : 문장 구분자

- **Word-Piece Embedding** : 토큰 임베딩 벡터를 생성함
- **OOV(`O`ut `o`f `V`ocabulary)** : 단어 사전에 존재하는 단어들로 쪼개어 임베딩 벡터를 생성하고, 이때 Sub-Word 는 앞에 `##` 을 표기하여 온전한 단어가 아님을 나타냄
- Here is the sentence I want **embeddings** for. <br> → [`here`, `is`, `the`, `sentence`, `i`, `want`, `em`, `##bed`, `##ding`, `##s`, `for`, `.`]
Expand Down Expand Up @@ -120,6 +100,26 @@ $$\begin{aligned}
- $\mathbf{W}^{(k)}_{1} \in \mathbb{R}^{M \times 4d}$ : **Dimension Expansion** to four times the Dimension of the Embedding Vector
- $\mathbf{W}^{(k)}_{2} \in \mathbb{R}^{M \times d}$ : **Dimension Reduction** to Embedding Vector Dimension

## Pre-Training for Transfer Learning
-----

![03](/_post_refer_img/TextAnalytics/11-03.jpg){: width="100%"}

- **MLM(`M`asked `L`anguage `M`odel)** : 입력 문장에서 일부는 `MASK` 로 가리고, 일부는 다른 단어로 무작위 변경한 후(10%), 원래 단어를 예측하도록 양방향 학습함으로써 일반화된 언어 패턴을 학습하고 문맥을 이해하는 능력을 강화함

| 역할 | 처리 방법 | 비중 |
|---|---|---|
| CONTEXT | 변경하지 않음 | 85% |
| PREDICTION | MASK | 12% |
| PREDICTION |무작위 변경 | 1.5% |
| PREDICTION | 변경하지 않음 | 1.5% |

- **Bidirection** : 트랜스포머 디코더가 단방향 예측($t-1$ 시점까지 정보를 기반으로 $t$ 시점을 예측)을 수행했던 것과 달리, 버트는 양방향 예측(이전 시점과 이후 시점의 정보를 종합하여 $t$ 시점을 예측)을 수행하므로, 문맥 벡터 생성 시 미래 순번 정보를 모두 마스킹 처리하지 않음

- **NSP(`N`ext `S`entence `P`rediction)** : `CLS` 토큰을 기반으로 두 문장이 연속된 문장인지 아닌지 예측하도록 학습함으로써 문장 간 관계를 학습함

![06](/_post_refer_img/TextAnalytics/11-06.jpg){: width="100%"}

-----

### Reference
Expand Down

0 comments on commit 1d1cfd0

Please sign in to comment.