吴恩达深度学习课程五:自然语言处理 第二周:词嵌入(五)GloVe 算法
<p>此分类用于记录吴恩达深度学习课程的学习笔记,目前已完结,点击进入全集目录<br>课程相关信息链接如下:</p>
<ol>
<li>原课程视频链接:[双语字幕]吴恩达深度学习deeplearning.ai</li>
<li>github课程资料,含课件与笔记:吴恩达深度学习教学资料</li>
<li>课程配套练习(中英)与答案:吴恩达深度学习课后习题与答案</li>
</ol>
<p>本篇为第五课的第二周内容,2.8的内容以及一些相关知识的补充。</p>
<hr>
<p>本周为第五课的第二周内容,与 CV 相对应的,这一课所有内容的中心只有一个:<strong>自然语言处理(Natural Language Processing,NLP)</strong>。<br>
应用在深度学习里,它是专门用来进行<strong>文本与序列信息建模</strong>的模型和技术,本质上是在全连接网络与统计语言模型基础上的一次“结构化特化”,也是人工智能中<strong>最贴近人类思维表达方式</strong>的重要研究方向之一。<br>
<strong>这一整节课同样涉及大量需要反复消化的内容,横跨机器学习、概率统计、线性代数以及语言学直觉。</strong><br>
语言不像图像那样“直观可见”,更多是抽象符号与上下文关系的组合,因此<strong>理解门槛反而更高</strong>。<br>
因此,我同样会尽量补足必要的背景知识,尽可能用比喻和实例降低理解难度。<br>
本周的内容关于词嵌入,是一种<strong>相对于独热编码,更能保留语义信息的文本编码方式</strong>。通过词嵌入,模型不再只是“记住”词本身,而是能够<strong>基于语义关系进行泛化</strong>,在一定程度上实现类似“<strong>举一反三</strong>”的效果。词嵌入是 NLP 领域中最重要的基础技术之一。</p>
<p>本篇的内容关于 <strong>GloVe 算法</strong>,是 Word2Vec 外,另一种以“全局”思想指导的词嵌入算法。</p>
<h1 id="1-glove-算法思想">1. GloVe 算法思想</h1>
<p>在前面介绍 Word2Vec 时,我们已经看到了一条非常清晰的学习路线:<strong>通过预测任务,让模型在训练中“顺便”学到词的向量表示</strong>。这种思路高效且直观,但也有一个绕不开的事实——它几乎完全依赖<strong>局部上下文</strong>。<br>
这不难理解,在 Word2Vec 中,我们每次训练,都是使用<strong>窗口内的序列信息</strong>来学习相应的语义并更新词向量,每次更新只使用窗口内的词信息,词向量是在多次局部预测中逐步学习出来的。<br>
由此,一个新的想法产生了:<strong>如果我们不只看窗口内的几步关系,而是把“整个语料里,词与词出现过多少次”都考虑进来,会发生什么?</strong></p>
<p>GloVe 正是这一想法的产物。<br>
在 2014 年,论文 GloVe: Global Vectors for Word Representation被发表,论文认为<strong>词的语义信息,本质上蕴含在词与词的全局共现统计关系中,而词向量的任务,就是用一个低维连续空间去重现这种统计结构。</strong><br>
最终,GloVe 将<strong>传统共现统计方法的全局视角</strong>,与<strong>分布式词向量的表达能力</strong>结合起来,形成了一种介于“计数方法”和“预测方法”之间的折中方案。<br>
这里要专门说明的是,相比于传统神经网络,<strong>GloVe 没有隐藏层或激活函数</strong>,更像是一条通过词向量内积加偏置构成的<strong>线性计算流水线</strong>,但它仍然使用梯度下降来更新参数,实现对共现统计信息的拟合,我们很难用模型那一套来描述它,因此也相对较难理解。<br>
下面就来分点展开 GloVe 算法的实现逻辑:</p>
<h1 id="2-glove-算法的统计部分">2. GloVe 算法的统计部分</h1>
<p>GloVe 算法 的起手其实是传统的共现统计方法,<strong>这一部分并不涉及模型训练,而是对数据进行统计和处理,得到词汇间的全局关系。</strong><br>
依旧分点来看这部分内容:</p>
<h2 id="21-统计词共现矩阵">2.1 统计词共现矩阵</h2>
<p><strong>词共现矩阵</strong> 是传统统计方法里的基础概念,顾名思义,它是用来<strong>表示词与词之间共现关系的矩阵</strong>。</p>
<p>规范一下,设词表大小为 <span class="math inline">\(V\)</span>,定义一个矩阵 <span class="math inline">\(X \in \mathbb{R}^{V \times V}\)</span>,其中:</p>
<p></p><div class="math display">\[X_{ij} = \text{词 } j \text{ 出现在词 } i \text{ 上下文中的次数}
\]</div><p></p><p>简单举个例子,假设语料只有一句话:</p>
<blockquote>
<p>I like deep learning</p>
</blockquote>
<p>显然,词表为:</p>
<p></p><div class="math display">\[\{\text{I},\ \text{like},\ \text{deep},\ \text{learning}\}
\]</div><p></p><p>现在,设定<strong>上下文窗口大小为 1</strong>,即只考虑左右各一个词。<br>
我们统计各词的共性关系如下:</p>
<ol>
<li>以 <strong>I</strong> 为中心:上下文只有 <em>like</em></li>
<li>以 <strong>like</strong> 为中心:上下文是 <em>I</em> 和 <em>deep</em></li>
<li>以 <strong>deep</strong> 为中心:上下文是 <em>like</em> 和 <em>learning</em></li>
<li>以 <strong>learning</strong> 为中心:上下文只有 <em>deep</em></li>
</ol>
<p>由此,我们可以得到完整的词共现矩阵 <span class="math inline">\(X\)</span>:</p>
<p></p><div class="math display">\[X =
\begin{array}{c|cccc}
& \text{I} & \text{like} & \text{deep} & \text{learning} \\
\hline
\text{I} & 0 & 1 & 0 & 0 \\
\text{like} & 1 & 0 & 1 & 0 \\
\text{deep} & 0 & 1 & 0 & 1 \\
\text{learning} & 0 & 0 & 1 & 0 \\
\end{array}
\]</div><p></p><p>补充几点细节:</p>
<ol>
<li>在常见的统计设定中,通常<strong>手工设定</strong>不将词与自身计入共现关系,因此<strong>共现矩阵的对角线往往为 0</strong>,但在真实语料中,若相同词在窗口范围内连续出现,则对应的对角元素也可能为非零值。</li>
<li>词共现矩阵往往是<strong>高度稀疏的</strong>,大多数词对在语料中根本不会共现。</li>
<li><strong>词共现矩阵是否对称,取决于设计的统计方式</strong>,在对称窗口下,这里的 <span class="math inline">\(X\)</span> 是对称的,若区分左右上下文,矩阵则不一定对称。</li>
</ol>
<p>由此,我们就完成了 GloVe 算法在统计部分的第一步。<br>
下一步,我们会<strong>把共现次数 <span class="math inline">\(X_{ij}\)</span> 转化为条件概率 <span class="math inline">\(P(j|i)\)</span></strong>,进一步引入向量训练的目标。</p>
<h2 id="22-统计条件概率-">2.2 统计条件概率 <span class="math inline">\(P(j \mid i)\)</span></h2>
<p>在完成共现矩阵统计后,GloVe 的下一步是把<strong>绝对共现次数</strong>转化为<strong>条件概率</strong>,从而刻画词与词之间更直观的关系。<br>
我们定义条件概率为:</p>
<p></p><div class="math display">\[P(j \mid i) = \frac{X_{ij}}{\sum_k X_{ik}}
\]</div><p></p><p>其中:</p>
<ul>
<li><span class="math inline">\(X_{ij}\)</span> 是词 <span class="math inline">\(j\)</span> 出现在词 <span class="math inline">\(i\)</span> 上下文中的次数,来自词共现矩阵。</li>
<li><span class="math inline">\(\sum_k X_{ik}\)</span> 是以词 <span class="math inline">\(i\)</span> 为中心时,所有上下文词出现次数的总和</li>
</ul>
<p><strong>最终,<span class="math inline">\(P(j \mid i)\)</span> 表示在语料库中,已知中心词为 <span class="math inline">\(i\)</span> 的前提下,上下文词为 <span class="math inline">\(j\)</span> 的经验概率。</strong></p>
<p>我们继续使用上一节中的例子,根据共现矩阵:</p>
<p></p><div class="math display">\[X =
\begin{array}{c|cccc}
& \text{I} & \text{like} & \text{deep} & \text{learning} \\
\hline
\text{I} & 0 & 1 & 0 & 0 \\
\text{like} & 1 & 0 & 1 & 0 \\
\text{deep} & 0 & 1 & 0 & 1 \\
\text{learning} & 0 & 0 & 1 & 0 \\
\end{array}
\]</div><p></p><p>我们可以计算条件概率,例如:</p>
<ol>
<li>以 <strong>like</strong> 为中心:</li>
</ol>
<p></p><div class="math display">\[\sum_k X_{\text{like},k} = 1 + 0 + 1 + 0 = 2
\]</div><p></p><p>于是:</p>
<p></p><div class="math display">\[P(\text{I} \mid \text{like}) = \frac{1}{2} = 0.5, \quad
P(\text{deep} \mid \text{like}) = \frac{1}{2} = 0.5
\]</div><p></p><ol start="2">
<li>以 <strong>I</strong> 为中心:</li>
</ol>
<p></p><div class="math display">\[\sum_k X_{\text{I},k} = 0 + 1 + 0 + 0 = 1
\]</div><p></p><p>所以:</p>
<p></p><div class="math display">\[P(\text{like} \mid \text{I}) = 1
\]</div><p></p><p><strong>最终,通过这种方式,我们就得到了语料库中每个词的上下文概率分布。</strong><br>
我们整理例子的概率分布矩阵如下:</p>
<p></p><div class="math display">\[P =
\begin{array}{c|cccc}
& \text{I} & \text{like} & \text{deep} & \text{learning} \\
\hline
\text{I} & 0 & 1 & 0 & 0 \\
\text{like} & 0.5 & 0 & 0.5 & 0 \\
\text{deep} & 0 & 0.5 & 0 & 0.5 \\
\text{learning} & 0 & 0 & 1 & 0 \\
\end{array}
\]</div><p></p><p>其中:</p>
<ul>
<li><strong>行表示中心词 <span class="math inline">\(i\)</span></strong></li>
<li><strong>列表示上下文词 <span class="math inline">\(j\)</span></strong></li>
<li><strong>每个元素 <span class="math inline">\(P_{ij}\)</span></strong> 即为 <span class="math inline">\(P(j|i)\)</span></li>
</ul>
<p>自此,我们就完成了GloVe 算法在统计部分的全部内容。<br>
下面,就是它的建模部分。</p>
<h1 id="3-glove-算法的模型部分">3. GloVe 算法的模型部分</h1>
<p>在完成统计阶段后,我们得到了全局的共现信息及概率分布。<strong>模型部分的核心任务</strong>就是:利用这些统计信息训练出词向量,使得词向量能够<strong>反映词与词之间的语义关系</strong>。</p>
<p>GloVe 的核心思想可以概括为一句话:<strong>词向量的内积应该能够拟合词与词之间的共现概率</strong>。<br>
我们依旧分点来进行这部分内容:</p>
<h2 id="31-计算概率比例">3.1 计算概率比例</h2>
<p>首先,GloVe 并不直接去拟合条件概率 <span class="math inline">\(P(j|i)\)</span>,而是利用<strong>概率比例</strong>刻画语义关系。<br>
设有中心词 <span class="math inline">\(i\)</span>,上下文词 <span class="math inline">\(j\)</span> 和 <span class="math inline">\(k\)</span>,则概率比例如下:</p>
<p></p><div class="math display">\[\frac{P(j \mid i)}{P(k \mid i)}
\]</div><p></p><p>这并不难理解:</p>
<ul>
<li>如果比例大,说明 <span class="math inline">\(i\)</span> 更倾向于与 <span class="math inline">\(j\)</span> 一起出现。</li>
<li>如果比例小,说明 <span class="math inline">\(i\)</span> 更倾向于与 <span class="math inline">\(k\)</span> 一起出现。</li>
</ul>
<p>继续使用同样的例子,我们刚刚得到条件概率矩阵如下:</p>
<p></p><div class="math display">\[P =
\begin{array}{c|cccc}
& \text{I} & \text{like} & \text{deep} & \text{learning} \\
\hline
\text{I} & 0 & 1 & 0 & 0 \\
\text{like} & 0.5 & 0 & 0.5 & 0 \\
\text{deep} & 0 & 0.5 & 0 & 0.5 \\
\text{learning} & 0 & 0 & 1 & 0 \\
\end{array}
\]</div><p></p><p>对于中心词 <strong>like</strong>,其上下文词分别为 <strong>I</strong> 和 <strong>deep</strong>,则:</p>
<p></p><div class="math display">\[\frac{P(\text{I} \mid \text{like})}{P(\text{deep} \mid \text{like})} = \frac{0.5}{0.5} = 1
\]</div><p></p><p>这个比例表示,“like”与“I”和“deep”的关系<strong>同样强</strong>。<br>
换句话说,如果模型想拟合这个关系,词向量在空间中的表现应该让 <strong>like-I</strong> 与 <strong>like-deep</strong> 的内积接近。</p>
<p>而如果概率比例不是 1,例如假设在更大语料中统计到:</p>
<p></p><div class="math display">\[P(\text{I} \mid \text{like}) = 0.3, \quad P(\text{deep} \mid \text{like}) = 0.6
\]</div><p></p><p>则比例为:</p>
<p></p><div class="math display">\[\frac{P(\text{I} \mid \text{like})}{P(\text{deep} \mid \text{like})} = \frac{0.3}{0.6} = 0.5
\]</div><p></p><p>这个比例小于 1,说明“like”<strong>更倾向于与 deep 一起出现</strong>,与 I 的关联较弱。模型训练时,GloVe 就会尝试让词向量 <strong>like-deep</strong> 的内积大于 <strong>like-I</strong> 的内积,以反映这种强弱关系。</p>
<p>这一步,我们通过比例概率实现了对语义的量化,而下一步就是 GloVe 的核心内容:</p>
<h2 id="32-构建向量关系">3.2 构建向量关系</h2>
<p>在这一步,GloVe 就可以将概率比例量化的<strong>语义偏好</strong>转化为<strong>向量空间中的相对位置</strong>,从而实现统计信息到词向量的映射。<br>
换句话说,我们希望通过训练得到的词向量,使得在向量空间中,中心词与上下文词的相对位置<strong>能够反映它们在语料中的共现强弱</strong>。<br>
来看看 GloVe 实现这一步的具体逻辑:</p>
<p>首先,设定:</p>
<ol>
<li><strong>中心词</strong> <span class="math inline">\(i\)</span> 的词向量为 <span class="math inline">\(w_i \in \mathbb{R}^d\)</span></li>
<li><strong>上下文词</strong> <span class="math inline">\(j,k\)</span> 的词向量为 <span class="math inline">\(\tilde w_j, \tilde w_k \in \mathbb{R}^d\)</span></li>
</ol>
<p>GloVe 通过以下假设将概率比例与向量联系起来:</p>
<p></p><div class="math display">\[F(w_i, \tilde w_j, \tilde w_k) = \frac{P(j \mid i)}{P(k \mid i)}
\]</div><p></p><p>其中函数 <span class="math inline">\(F\)</span> 的含义是:<strong>用向量操作去表示概率比例,模型的目标就是拟合这个函数 <span class="math inline">\(F\)</span> 。</strong></p>
<p>也就是说,我们的目标是:</p>
<p></p><div class="math display">\[\frac{P(j \mid i)}{P(k \mid i)} \approx {\text{模型预测的某个函数值}}{}
\]</div><p></p><p><strong>但是,直接拟合比例本身有几个问题</strong>:</p>
<ol>
<li><strong>比例范围广</strong>:条件概率 <span class="math inline">\(P(j|i)\)</span> 属于 <span class="math inline">\(\)</span>,两个概率比值可能非常大或非常小(比如 <span class="math inline">\(0.001/0.5 = 0.002\)</span>),直接拟合容易数值不稳定。</li>
<li><strong>向量空间线性映射困难</strong>:我们希望用向量内积(<span class="math inline">\(w_i^\top \tilde w_j\)</span>)表示关系,但向量内积是线性且可正可负,而概率比总是正且变化范围大,直接用内积去拟合会很不直观,也容易数值不稳定。</li>
</ol>
<p>所以我们需要一个<strong>桥梁函数</strong>,把比例转换成更适合线性建模的形式。</p>
<h2 id="33-转换概率比例">3.3 转换概率比例</h2>
<p>在这里,GloVe 选择了 <strong>对数函数</strong>,把比例变成 <strong>内积差</strong>:</p>
<p></p><div class="math display">\[\log \frac{P(j \mid i)}{P(k \mid i)} =\log P(j|i) - \log P(k|i) \approx (w_i^\top \tilde w_j + b_i + \tilde b_j) - (w_i^\top \tilde w_k + b_i + \tilde b_k)
\]</div><p></p><p>我们来详细解释一下这步推导的逻辑:</p>
<ol>
<li><strong>对数的作用</strong>:<br>
对数函数可以把原本范围很广的正数概率比压缩到数值更稳定的区间,并且把<strong>乘法关系转化为加法关系</strong>。数值范围收敛,更利于模型学习,同时便于线性处理。</li>
<li><strong>对映射的影响</strong>:<br>
取了对数之后,原本的比例关系就转化为“加减法”的形式,而向量内积本身就是线性可加的操作(<span class="math inline">\(w_i^\top \tilde w_j\)</span> 是实数线性组合)。对数后的比例差可以直接用 <strong>线性模型</strong>(内积加偏置)来拟合,保证概率比越大,内积差越大;概率比越小,内积差越小。</li>
<li><strong>偏置项的作用</strong> :<br>
偏置项 <span class="math inline">\(b_i, \tilde b_j\)</span> 用于<strong>捕捉词自身的出现频率差异</strong>。<br>
高频词往往在语料中出现次数多,直接用向量内积可能被整体频率影响而偏离比例。<br>
偏置项可以单独调整每个词的基准水平,让向量内积专注于<strong>词与词之间的相对关系</strong>,而不受词频本身干扰。</li>
</ol>
<p>最终,我们通过公式实现了这样的作用:</p>
<p></p><div class="math display">\[\text{概率比例(统计信息)} \xrightarrow{\log} \text{线性可加的形式} \xrightarrow{\text{内积+偏置}} \text{向量表示拟合目标}
\]</div><p></p><p>回到例子,假设在某大语料中统计到:</p>
<p></p><div class="math display">\[P(\text{I} \mid \text{like}) = 0.3, \quad P(\text{deep} \mid \text{like}) = 0.6
\]</div><p></p><p>则:</p>
<p></p><div class="math display">\[\log \frac{P(\text{I} \mid \text{like})}{P(\text{deep} \mid \text{like})} = \log 0.5 \approx -0.693
\]</div><p></p><p>因此,模型希望通过训练得到的向量,使得:</p>
<p></p><div class="math display">\[(w_\text{like}^\top \tilde w_\text{I} + b_\text{like} + \tilde b_\text{I}) - (w_\text{like}^\top \tilde w_\text{deep} + b_\text{like} + \tilde b_\text{deep}) \approx -0.693
\]</div><p></p><p>这样,训练后,词向量在空间中,“like” 会更靠近 “deep”,远离 “I”,以反映概率比例。</p>
<p>下面就是最后一步了:</p>
<h2 id="34-构建损失函数并训练">3.4 构建损失函数并训练</h2>
<p>在完成概率比例到向量内积映射后,GloVe 还需要一个<strong>可优化的损失函数</strong>来让训练可执行。<br>
这一步的思想是:<strong>让向量内积(加偏置)尽量逼近对数共现概率</strong>,同时对高频和低频词对做合理的权衡。</p>
<p>GloVe 的损失函数定义为:</p>
<p></p><div class="math display">\[J = \sum_{i,j=1}^{V} f(X_{ij}) \left( w_i^\top \tilde w_j + b_i + \tilde b_j - \log X_{ij} \right)^2
\]</div><p></p><p>看起来很复杂,实际上也不简单,我们详细解释一下各部分含义:</p>
<ol>
<li>
<p><strong>权重函数 <span class="math inline">\(f(X_{ij})\)</span></strong>:<br>
为了平衡高频和低频词对的影响,GloVe 引入了一个加权函数:</p>
<p></p><div class="math display">\[ f(x) =
\begin{cases}
\left(\dfrac{x}{x_\text{max}}\right)^\alpha, & x < x_\text{max} \\
1, & x \ge x_\text{max}
\end{cases}
\]</div><p></p><p>这里 <span class="math inline">\(x_\text{max}\)</span> 是阈值,<span class="math inline">\(\alpha\)</span> 通常取 <span class="math inline">\(0.75\)</span>。<br>
这是为了让高频词对不会主导训练,低频词对仍有一定权重。</p>
</li>
<li>
<p><strong><span class="math inline">\(w_i^\top \tilde w_j + b_i + \tilde b_j\)</span></strong>:模型预测的对数共现次数,即词向量加偏置的线性组合。</p>
</li>
<li>
<p><strong><span class="math inline">\(\log X_{ij}\)</span></strong>:对应统计信息的对数共现次数,是我们希望模型逼近的目标。</p>
</li>
<li>
<p><strong>平方误差 <span class="math inline">\((\cdot)^2\)</span></strong>:衡量预测值与目标值之间的差距,使模型通过梯度下降最小化误差。</p>
</li>
</ol>
<p>这里就可以解释我们在本周第一篇中留下的问题:<strong>词向量的长度受什么影响?</strong><br>
因为高频词在语料中出现次数多,因此它的共现矩阵行/列上的元素整体偏大,经过训练后,模型为了尽量逼近 <span class="math inline">\(\log X_{ij}\)</span>,会使得这些高频词的向量内积整体偏大,从而对应的向量长度也相对较长。<br>
<strong>也就是说,词向量的长度与词频正相关,但本身没有其他明确的语义解释,只是统计特性导致的结果。</strong></p>
<p>同时,在这里你可能会有一个问题:<strong>我们刚刚引入了概率比例和内积差的关系,为什么损失函数里都没有用到?</strong><br>
实际上,对某个中心词 <span class="math inline">\(i\)</span>,任意两个上下文词 <span class="math inline">\(j,k\)</span>,若你看损失梯度,会发现:<br>
在优化过程中,梯度会自然调整 <span class="math inline">\(w_i\)</span>,让 <strong>共现次数更多、概率大的词对应内积更大,共现次数更少、概率小的词对应内积更小</strong>。<br>
换句话说,<strong>比例关系会通过梯度自动体现出来</strong>,不需要显式算比值,并且这样还避免了显式计算所有词对之间的概率比造成的计算开销。</p>
<p>还是用我们的例子,假设在大语料中:</p>
<table>
<thead>
<tr>
<th>中心词</th>
<th>上下文词</th>
<th>共现次数 <span class="math inline">\(X_{ij}\)</span></th>
</tr>
</thead>
<tbody>
<tr>
<td>like</td>
<td>I</td>
<td>3</td>
</tr>
<tr>
<td>like</td>
<td>deep</td>
<td>6</td>
</tr>
</tbody>
</table>
<p>则训练目标:</p>
<ol>
<li>对 <strong>like-I</strong>:
<ul>
<li>目标 <span class="math inline">\(\log X_{\text{like,I}} = \log 3 \approx 1.099\)</span></li>
<li>模型希望 <span class="math inline">\(w_\text{like}^\top \tilde w_\text{I} + b_\text{like} + \tilde b_\text{I} \approx 1.099\)</span></li>
</ul>
</li>
<li>对 <strong>like-deep</strong>:
<ul>
<li>目标 <span class="math inline">\(\log X_{\text{like,deep}} = \log 6 \approx 1.792\)</span></li>
<li>模型希望 <span class="math inline">\(w_\text{like}^\top \tilde w_\text{deep} + b_\text{like} + \tilde b_\text{deep} \approx 1.792\)</span></li>
</ul>
</li>
<li>权重函数 <span class="math inline">\(f(X_{ij})\)</span> 可以调节两者在训练中的影响,使模型更稳健。</li>
</ol>
<p>训练时,GloVe <strong>会遍历所有有共现的词对</strong>,计算加权平方误差,利用梯度下降优化 <span class="math inline">\(w_i, \tilde w_j, b_i, \tilde b_j\)</span>,直到误差收敛。<br>
最后,你会发现,GloVe 的整个传播过程同时在维护两个词向量矩阵:</p>
<ol>
<li><strong>中心词向量 <span class="math inline">\(w_i\)</span></strong></li>
<li><strong>上下文词向量 <span class="math inline">\(\tilde w_j\)</span></strong><br>
而通常,我们将两者相加或平均作为最终词向量:</li>
</ol>
<p></p><div class="math display">\[v_i = w_i + \tilde w_i
\]</div><p></p><p>这样得到的 <span class="math inline">\(v_i\)</span> 便同时存在作为中心词和上下文词的语义距离,刻画了词与词之间的全局共现关系。</p>
<h1 id="4-总结">4. 总结</h1>
<p>因为 GloVe 相比起来较为复杂,这里我们不再表格整理概念了,而是<strong>整体梳理一遍其传播过程</strong>。<br>
<img src="https://img2024.cnblogs.com/blog/3708248/202601/3708248-20260123235856508-1491140111.png" alt="image" loading="lazy"></p><br><br>
来源:https://www.cnblogs.com/Goblinscholar/p/19524283
頁:
[1]