词嵌入: 将词映射到连续向量空间的表示学习方法.

1. Core Problem

NLP 的首要问题是如何表示词.

1.1 Traditional Method: One-Hot Encoding

  • 每个词是一个维度为 的向量, 其中 为词汇表大小.
  • 表示是离散的、稀疏的.
  • 缺点: 词与词之间都是正交的, 无法表示相似性.

1.2 Modern Method: Word Embeddings

  • 将每个词映射到一个连续的低维向量空间.
  • 语义相近的词在空间中距离也相近.
  • 将高维稀疏表示转化为低维稠密表示.

2. Mathematical Representation

给定词嵌入矩阵 :

  • = 词汇表大小.
  • = 词向量维度, 是超参数, 常取 到 .
  • 第 行 表示第 个词的向量.

对于 one-hot 表示的句子 , 其中 是句子长度, 词向量表示为:

3. Method Categories

方法类型代表模型核心思想优缺点
Prediction-basedWord2Vec通过预测上下文学习词向量捕捉语义关系, 但无全局信息
Count-basedLSA, GloVe基于共现矩阵学习词向量利用全局信息, 但计算复杂
ContextualBERT, ELMo动态词向量, 依赖上下文消歧能力强, 但计算成本高

4. Notes Index

NoteKey Concepts
Word2VecSkip-gram, CBOW, neural network perspective, PyTorch implementation
Negative SamplingSampling distribution, binary approximation
GloVeCo-occurrence matrix, PMI, global vectors

5. Concept Map

Word Embeddings
  |
  |-- Word2Vec (Prediction-based)
  |     |-- Negative Sampling (optimization)
  |
  |-- GloVe (Count-based)
  |
  |-- BERT (Contextual embeddings)