1.0 KiB
1.0 KiB
title, created, updated, type, tags, sources
| title | created | updated | type | tags | sources | |||
|---|---|---|---|---|---|---|---|---|
| Position Encoding (位置编码) | 2025-06-02 | 2025-06-02 | concept |
|
Position Encoding
Transformer 模型中为 token 注入序列位置信息的技术。
主要方法
- 绝对位置编码:为每个位置分配唯一向量(原始 Transformer)
- rotary-position-embedding(旋转位置编码):通过旋转矩阵编码相对位置,广泛用于现代 LLM
- ALiBi:通过注意力偏置编码相对位置
- NTK-aware 插值:扩展位置编码的范围(见 length-extrapolation)
在多轮推理中的挑战
goru-one-pass-to-reason-2025 揭示了 position-id-discrepancy 问题——同一 token 在生成和上下文两种场景中的绝对位置不同,需通过策略性位置 ID 分配解决。