单词用向量表示,包含句法(即词性)和语义(即意义)结构。

CBOW模型continuous bag of words

在CBOW建模中,我们试图通过给定几个上下文单词(中心词周围的单词)来预测中心词。

例如,选择一个 C = 2 C=2 C=2的上下文,预测中间的单词happy,则上下文包含中心单词前面的两个单词和之后的两个单词:

C C C个单词前:【我,是】
C C C个单词后:【因为,我】

换句话说:

c o n t e x t = [ I , a m , b e c a u s e , I ] context=[I,am,because,I] context=[IambecauseI] t a r g e t = h a p p y target=happy target=happy

模型结构如下:

NLP-C2-W4-词嵌入CBOW模型

NLP-C2-W4-词嵌入CBOW模型

softmax function:

softmax ( z i ) = e z i ∑ i = 0 V − 1 e z i (5) \text{softmax}(z_i) = \frac{e^{z_i} }{\sum_{i=0}^{V-1} e^{z_i} } \tag{5} softmax(zi)=i=0V1eziezi(5)

Array indexing in code starts at 0.
V V V is the number of words in the vocabulary (which is also the number of rows of z z z).
i i i goes from 0 to |V| - 1.

the Rectified Linear Unit (ReLU):

f ( h ) = max ⁡ ( 0 , h ) (6) f(h)=\max (0,h) \tag{6} f(h)=max(0,h)(6)

x ˉ \bar x xˉ是上下文单词所有one-hot向量的平均。

NLP-C2-W4-词嵌入CBOW模型

一旦编码了所有上下文单词,就可以使用 x ˉ \bar x xˉ作为模型的输入。

相关文章:

  • 2021-11-29
  • 2022-12-23
  • 2021-07-17
  • 2021-11-05
  • 2022-01-23
  • 2021-05-22
  • 2021-10-27
  • 2021-08-01
猜你喜欢
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2021-09-07
  • 2021-07-16
  • 2021-10-30
相关资源
相似解决方案