词嵌入: 将词映射到连续向量空间的表示学习方法.
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-based | Word2Vec | 通过预测上下文学习词向量 | 捕捉语义关系, 但无全局信息 |
| Count-based | LSA, GloVe | 基于共现矩阵学习词向量 | 利用全局信息, 但计算复杂 |
| Contextual | BERT, ELMo | 动态词向量, 依赖上下文 | 消歧能力强, 但计算成本高 |
4. Notes Index
| Note | Key Concepts |
|---|---|
| Word2Vec | Skip-gram, CBOW, neural network perspective, PyTorch implementation |
| Negative Sampling | Sampling distribution, binary approximation |
| GloVe | Co-occurrence matrix, PMI, global vectors |
5. Concept Map
Word Embeddings
|
|-- Word2Vec (Prediction-based)
| |-- Negative Sampling (optimization)
|
|-- GloVe (Count-based)
|
|-- BERT (Contextual embeddings)