티스토리 뷰

본 포스팅은 edwith에서 제공되는 딥러닝을 이용한 자연어처리 강좌를 참고하여 만들어졌습니다.
https://www.edwith.org/deepnlp/joinLectures/17363

 

1. How to represent sentence & token?

  • A sentence is a variable sequence of tokens 
  • Each token could be any one from a vocabulary
  • Once the vocabulary is fixed and edcoding is done, a sentence or text is just a sequence of 'integer indices'.

1) one-hot encoding

해당 token에 해당하는 index만 1로 설정되고 나머지 index는 모두 0으로 설정되는 vector로 token을 표현한다.

하지만, 모든 token의 euclidean distance가 같기 때문에 token이 가지고 있는 의미를 전혀 표현하지 못 함.

ex. '개와 늑대'의 거리도 1이고 '개와 사과'의 거리도 1이다.

또한, 저장공간의 낭비가 심하다!

 

2) table lookup index

one-hot encoding vector에 weight metrix를 곱해서 각 token의 가중치를 놓고 의미가 유사한 token끼리 가까운 거리를 유지하게 함.

 

3) Continuous bag-of-words(CBoW)

 

  • 단어장을 단어 주머니로 보게되고, 이에 따라 단어의 순서는 무시합니다. 
  • 문장에 대한 표현은 단어 벡터들을 평균시킨 벡터로 구합니다.
  • 효과가 좋기 때문에 제일 먼저 시도해봐야합니다. (Baseline 모델)
  • 공간상에서 가까우면 비슷한 의미, 아니면 멀리 떨어져 있을 것입니다.

https://www.edwith.org/downloadFile/fileDownload?attachmentId=49655&autoClose=true

 

 

fastText

Library for efficient text classification and representation learning

fasttext.cc

4) Relation Network(Skip-Bigram)

  • 문장안에 있는 모든 토큰 쌍(pairs)을 보고, 각 쌍에 대해서 신경망을 만들어서 문장표현을 찾습니다.
  • 장점: 여러 단어로 된 표현을 탐지 할 수 있습니다.
  • 단점: 모든 단어간의 관계를 보기 때문에, 전혀 연관이 없는 단어도 보게 됩니다.

https://www.edwith.org/downloadFile/fileDownload?attachmentId=49655&autoClose=true

 

 

5) Convolution Nerual Network (CNN)

  • 특징:
    • k-gram을 계층적으로(hierachically) 보게 됩니다.
    • Layer 를 쌓을 때 마다, 점진 적으로 넓은 범위를 보기 때문에, "단어> 다중 단어 표현> 구절 > 문장"순으로 보는 인간의 인식과도 알맞습니다. 
    • 1차원의 Convolutional Network 입니다.
  • 장점: 좁은 지역간 단어의 관계를 볼수 있습니다.
  • 단점: Layer가 아주 크지 않은 이상 멀리 떨어진 token(문장의 앞과 뒤)의 관계를 찾기가 어려움
    • Relation Network에서는 아주 멀리 떨어진 관계라도 고려 할 수 있음! CNN과 RN의 차이

6) Self-Attention

  • 모든 조합을 동등한 가중치를 주어 고려하는 RN과 가까운 token에 큰 가중치를 두어 고려하는 CNN의 특징을 조합해자! 
  • t번째 token을 뽑을 때 모든 조합을 고려하지만, 모든 조합의 가중치를 두고, 가중치를 hyper-parameter로 고정시키는 것이 아니라 가중치 역시 Neural Network에서 training시키자!
 

Attention Is All You Need

The dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new

arxiv.org

 

7) RNN

 

    • 문장의 정보를 시간의 순서에 따라 압축 할 수 있습니다.
    • 메모리를 가지고 있어서 현재까지 읽는 정보를 저장 할 수 있습니다.
    • 단점:
      • 문장이 많이 길어질 수록 고정된 메모리에 압축된 정보를 담아야 하기 때문에, 앞에서 학습한 정보를 잊습니다. 이는 곧 정보의 손실을 뜻합니다. 
      • 토큰을 순차적으로 하나씩 읽어야 하기 때문에, 훈련 할때 속도가 기타 네트워크 보다 느립니다.
    • Long Term Dependency 해결방법:
      • bidirectional network를 쓰게됩니다.
      • LSTM, GRU 등 RNN의 변형을 사용합니다.
 

Long short-term memory - Wikipedia

The Long Short-Term Memory (LSTM) cell can process data sequentially and keep its hidden state through time. Long short-term memory (LSTM) is an artificial recurrent neural network (RNN) architecture[1] used in the field of deep learning. Unlike standard f

en.wikipedia.org

 

 

Gated recurrent unit - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search Long short-term memory (LSTM) with a forget gate but not an output gate, used in recurrent nueral networks Gated recurrent units (GRUs) are a gating mechanism in recurrent neural netwo

en.wikipedia.org

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함