References

1. Method Comparison

传统词向量方法有两类:

方法类型代表优点缺点
Count-basedLSA, PPMI利用全局统计信息难以捕捉语义关系
Prediction-basedWord2Vec捕捉语义关系无法利用全局信息

GloVe means Global Vectors. It combines global information from the co-occurrence matrix with a prediction-style optimization objective.

2. Co-occurrence Matrix

2.1 Definition

  • : 共现矩阵, 表示词 在词 的上下文窗口中出现的次数.
  • : 词 的上下文中所有词的总次数.
  • : 词 在词 上下文中出现的概率.

2.2 Features

  • Symmetry: 由于不区分词序, 是对称矩阵.
  • Sparsity: 大型语料库中, 非常稀疏.
  • One-pass construction: 只需扫描语料库一次.

2.3 Dimensionality Reduction: SVD

Theorem (SVD). Any matrix can be decomposed as:

取前 个奇异值得到低秩近似:

Problem. 高频词, 如 “the” and “a”, 影响过大.

Solutions.

  • 对数变换: .
  • 阈值截断: , .
  • 直接忽略.

3. PMI: Pointwise Mutual Information

3.1 PMI Definition

  • : 和 正相关, 共现频率高于独立假设.
  • : 独立.
  • : 负相关, 倾向于不共现.

3.2 PPMI: Positive PMI

只保留正相关, 更稳定.

3.3 SPPMI: Shifted PPMI

其中 是平滑参数.

Note: SGNS as matrix factorization

Skip-gram with negative sampling implicitly factorizes a shifted PMI matrix. Reference: Neural Word Embedding as Implicit Matrix Factorization.

4. GloVe Model

4.1 Core Intuition: Odds Ratio

考虑词 ice 和 steam 的共现概率比:

Ratio
solid8.9 > 1
gas0.085 < 1
water1.36 approx. 1
fashion0.96 approx. 1

Interpretation:

  • Ratio > 1: 与 ice 更相关.
  • Ratio < 1: 与 steam 更相关.
  • Ratio approx. 1: 与两者关系相似.

4.2 Model Derivation

Goal. Find function such that:

Derivation:

  1. Difference vector representation.
  1. Homomorphic property.
  1. Exponential function.
  1. Taking log.
  1. Merge bias terms.

4.3 Loss Function

其中:

  • : 权重函数, 抑制高频词影响.
  • : 词向量.
  • : bias 项.
  • 本质是**加权最小二乘法**.

4.4 Weight Function

通常 .

5. GloVe vs Word2Vec

特性Word2VecGloVe
方法类型Prediction-basedCount-based + Prediction
训练方式滑动窗口, 逐样本全局共现矩阵
目标函数交叉熵 / 负采样加权最小二乘
训练效率较慢, 多次扫描较快, 一次构建矩阵
语义关系YesYes
全局信息NoYes