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