Skip to main content
QUICK REVIEW

[论文解读] A Formal Perspective on Byte-Pair Encoding

Vilém Zouhar, Clara Meister|arXiv (Cornell University)|Jun 29, 2023
Algorithms and Data Compression被引用 5
一句话总结

本文将字节对编码(BPE)形式化为一个组合优化问题,以最大化压缩效用,证明了贪心BPE算法可实现1−e−σ(µ⋆)的近似比——经验上约为0.37——并基于子模函数理论进行推导。本文提出了一种O(N log M)时间复杂度的运行时优化贪心BPE实现,以及一种基于记忆化技术的精确算法,用于计算最优合并序列。

ABSTRACT

Byte-Pair Encoding (BPE) is a popular algorithm used for tokenizing data in NLP, despite being devised initially as a compression method. BPE appears to be a greedy algorithm at face value, but the underlying optimization problem that BPE seeks to solve has not yet been laid down. We formalize BPE as a combinatorial optimization problem. Via submodular functions, we prove that the iterative greedy version is a $\frac{1}{σ(\boldsymbolμ^\star)}(1-e^{-{σ(\boldsymbolμ^\star)}})$-approximation of an optimal merge sequence, where ${σ(\boldsymbolμ^\star)}$ is the total backward curvature with respect to the optimal merge sequence $\boldsymbolμ^\star$. Empirically the lower bound of the approximation is $\approx 0.37$. We provide a faster implementation of BPE which improves the runtime complexity from $\mathcal{O}\left(N M ight)$ to $\mathcal{O}\left(N \log M ight)$, where $N$ is the sequence length and $M$ is the merge count. Finally, we optimize the brute-force algorithm for optimal BPE using memoization.

研究动机与目标

  • 将BPE训练形式化为一个在受限组合空间上最大化压缩效用的组合优化问题。
  • 基于子模函数理论,为贪心BPE算法建立理论性能保证。
  • 通过一种新型数据结构,将贪心BPE的运行时复杂度从O(NM)优化至O(N log M)。
  • 利用记忆化与安全排列剪枝技术,开发一种用于计算最优BPE合并序列的精确算法。
  • 为BPE在自然语言处理中(尤其是子词分词)的经验成功提供形式化基础。

提出的方法

  • 提出将BPE形式化为在受限组合空间上最大化压缩效用函数的问题。
  • 使用总后向曲率σ(µ⋆)来界定贪心BPE的近似比为1/σ(µ⋆)(1−e−σ(µ⋆))。
  • 引入一种基于最大堆和摊销分析的数据结构,将贪心BPE的时间复杂度从O(NM)降低至O(N log M)。
  • 应用记忆化与安全排列剪枝技术,避免在精确BPE计算中对等价合并序列的冗余探索。
  • 定义合并冲突与安全排列,以刻画何时两个合并序列产生相同的括号结构。
  • 使用偏序关系⋗在精确算法中剪枝非规范合并序列,从而减少搜索空间。

实验结果

研究问题

  • RQ1BPE所解决的底层优化问题是什么?能否被形式化定义?
  • RQ2相对于最优合并序列,贪心BPE算法的理论近似保证是什么?
  • RQ3能否在先前实现的O(NM)复杂度基础上,进一步优化贪心BPE的运行时性能?
  • RQ4如何构建并优化一种用于计算最优BPE合并序列的精确算法?
  • RQ5合并序列的何种结构特性使得在精确BPE计算中可实现有效剪枝?

主要发现

  • 基于σ(µ⋆) ≈ 2.5,贪心BPE算法在压缩效用比上相对于最优合并序列的下界约为0.37。
  • 贪心BPE的运行时复杂度被优化至O(N log M),相比先前实现的O(NM)复杂度有显著提升。
  • 采用记忆化与安全排列剪枝的精确BPE算法,其运行速度优于暴力枚举方法(后者时间复杂度为O(NM min(|Σ|2M, NM)))。
  • 压缩效用函数被证明是受限空间上一种特殊的子模函数,从而支持理论保证的建立。
  • 所提出的精确算法通过利用安全排列下的等价性,剪枝冗余合并序列,在不损失最优性的情况下减少搜索空间。
  • 实验结果表明,尽管在合成小样本示例上表现次优,贪心BPE在真实世界自然语言数据上仍接近最优。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。