English

A Fast Algorithm for Computing Prefix Probabilities

Formal Languages and Automata Theory 2025-05-09 v5 Data Structures and Algorithms

Abstract

Multiple algorithms are known for efficiently calculating the prefix probability of a string under a probabilistic context-free grammar (PCFG). Good algorithms for the problem have a runtime cubic in the length of the input string. However, some proposed algorithms are suboptimal with respect to the size of the grammar. This paper proposes a novel speed-up of Jelinek and Lafferty's (1991) algorithm, whose original runtime is O(n3N3+N4)O(n^3 |N|^3 + |N|^4), where nn is the input length and N|N| is the number of non-terminals in the grammar. In contrast, our speed-up runs in O(n2N3+n3N2)O(n^2 |N|^3+n^3|N|^2).

Keywords

Cite

@article{arxiv.2306.02303,
  title  = {A Fast Algorithm for Computing Prefix Probabilities},
  author = {Franz Nowak and Ryan Cotterell},
  journal= {arXiv preprint arXiv:2306.02303},
  year   = {2025}
}

Comments

Corrected typos, changed the layout of the algorithms, and improved appendix B on the semiring version of the algorithm