본문 바로가기

강의/Text-Analytics

05-03: Text Representation 2 - Distributed Representation Part4 (Doc2Vec)

<목차>

01. Word-level:NNLM

02. Word-level:Word2Vec

03. Word-level:GloVe

04. Word-level:Fasttext

05.Sentence/Paragraph/Document-level

06.More Things to Embed?

 

<Document Embedding?>

* If we can embed words, why not senteces, phrases, or documents?

* 단어 임베딩의 확장으로 문서 임베딩은 왜 안나오느냐에서 시작한 것이 문서 임베딩이다.

 

<Paragraph Vector Model - Distributed Memory (PV-DM) model>

* Paragraph Vector도 Word2Vec의 CBOW와 Skip-gram처럼 두가지로 나눌 수 있다. 첫번째가 Distrubuted Memory (PV-DM) model이다.

* paragraph마다 각각이 id를 가지고 있고, 입력으로 함께 단어가 들어간다. (몇 개의 단어가 들어갈 지는 window size에 해당하는 하이퍼 파라미터이다) 그러면 다음번에 sequence에 해당하는 단어가 무엇인지 예측하는 것이 PV-DM model이다.

예를 들어서 The cat sat on the table이라는 문장이 있을 때, 처음에는 the cat sat이 들어간다. 두번째에는 cat sat on이 들어가고, 세번째는 sat on the가 들어가서 table을 예측하게 된다.

* 예제를 생각하면 이전의 모델과 뭐가 달라?라고 생각이 드는데, 여기서 중요한 것은 "동일한 paragraph id"가 들어간다는 점이다. (Paragraph vector are shared for all windows generated from the same paragraph, but not across prargraphs)

 

<Paragraph Vector Model - Distributed Bag of Words (PV-DBOW)>

* 입력은 paragraph id embedding 하나만 들어간다. 무엇을 예측하느냐?-> paragraph에 존재하는 일정 개수의 단어를 예측한다.

* PV-DM은 일련의 몇개의 단어를 통해서 다음 단어를 예측하는 반면에, PV-DBOW는 순서를 바꿔 예측할 수도 있다.(Ignore the context words in the input, and force the model to predict words randomly sampled from the paragraph in the output)

* 그러면 PV-DM과 PV-DBOW 중에 뭐가 더 좋을까 하는 질문에는 대체로 PV-DM이 좋지만, PV-DM과 PV-DBOW를 함께 사용하는 것이 더 좋다고 말할 수 있다. (PV-DM alone usually works well for most tasks, but the combination of PV-DM and PV-DBOW are recommended)

 

<Class Embedding>

* 앞서서 단어도 임베딩하고, 문서도 임베딩하는 모습을 보면 뭐든 임베딩할 수 있을것만 같은 생각이 들 수 있다. Class Embedding도 동일한 생각에서 시작하였다.