본문 바로가기
Study/Deep Learning

Word2Vec: Efficient Estimation of Word Representations in Vector Space, Distributed Representations of Words and Phrases and their Compositionality

by 들숨날숨흡 2022. 12. 1.
728x90

Word2Vec REVIEW

구현 과제하다가 모르겠어서 정리할겸 내 맘대로 끄적끄적 거려보기:)

 

Efficient Estimation of Word Representations in Vector Space

We propose two novel model architectures for computing continuous vector representations of words from very large data sets. The quality of these representations is measured in a word similarity task, and the results are compared to the previously best per

arxiv.org

 

Distributed Representations of Words and Phrases and their Compositionality

The recently introduced continuous Skip-gram model is an efficient method for learning high-quality distributed vector representations that capture a large number of precise syntactic and semantic word relationships. In this paper we present several extens

arxiv.org


How does Word2Vec work?

Word2Vec는 Skip-gram과 Common Bag of Words(CBOW) 두 가지를 이용하여 embedding을 생성하는 method이다.

 

CBOW Model

그 중 CBOW는 context word가 주어졌을 때, 이를 input으로 받아들여 center(target) word를 예측하도록 하는 방법이다.

Neural network의 input이 "great"일 때, 우리가 예측해야 하는 target word가 "day"라고 가정하자. 우리는 이를 위해 input word의 one hot vector를 사용하여 우리가 예측해야 하는 target word인 day의 one hot encoding과 예측값의 output error를 구한다. 이렇게 target word를 예측하는 과정에서 우리는 target word의 vector representation을 얻을 수 있게 도니다.

그림 (1)

그림을 보면 알 수 있듯이 input은 context word의 one hot vector이다. 이때 $W_{V\times N}$는 input들을 weighted sum해여 다음 layer로 보내는 역할을 한다. 여기서는 sigmoid, tanh, ReLU등과 같은 activation function이 존재하지 않는다. 미리 말하자면 activation function은 output layer에서 softmax를 할 때만 non-linearity를 주기 위해 사용한다. 

그림(2)

다음과 같이 input인 context words들이 hidedn layer를 거침으로써 weighted sum이 되고 $W^'_{N\times V}$와 activation function을 거친 후 output이 나옴을 알 수 있다. (참고로 그림에는 activation function에 대한 표시가 없다.)

 

Skip-Gram Model

이거는 이제 CBOW와는 반대로 target word가 주어졌을 때 context word를 예측하도록 하여 representation을 얻는 방법이다.

그림(3)

자세한 설명은.. 다음에 기회가 된다면.. CBOW와 거의 유사하다.

 

 

728x90