Efficient Semiring-Weighted Earley Parsing
Andreas Opedal, Ran Zmigrod, Tim Vieira, Ryan Cotterell, Jason Eisner
Abstract
This paper provides a reference description, in the form of a deduction system, of Earley's (1970) context-free parsing algorithm with various speed-ups. Our presentation includes a known worst-case runtime improvement from Earley's O N 3 |G||R| , which is unworkable for the large grammars that arise in natural language processing, to O N 3 |G| , which matches the runtime of CKY on a binarized version of the grammar G. Here N is the length of the sentence, |R| is the number of productions in G, and |G| is the total length of those productions. We also provide a version that achieves runtime of O N 3 |M| with |M| ≤ |G| when the grammar is represented compactly as a single finite-state automaton M (this is partly novel). We carefully treat the generalization to semiring-weighted deduction, preprocessing the grammar like Stolcke (1995) to eliminate deduction cycles, and further generalize Stolcke's method to compute the weights of sentence prefixes. We also provide implementation details for efficient execution, ensuring that on a preprocessed grammar, the semiring-weighted versions of our methods have the same asymptotic runtime and space requirements as the unweighted methods, including sub-cubic runtime on some grammars. https://github.com/rycolab/ earleys-algo 7 All methods in this paper can be also applied directly to lattice parsing, in which i, j, k range over states in an acyclic lattice of possible input strings, and 0 and N refer to the unique initial and final states. A lattice edge from j to k labeled with terminal a is then encoded by the axiom [j, k, a]. 8 Assuming that all nonterminals B ∈ N are generating, i.e., ∃x ′ ∈ Σ * such that B * ⇒ x ′ . To ensure this, repeatedly mark B ∈ N as generating whenever R contains some B → ρ such that all nonterminals in ρ are already marked as generating. Then delete any unmarked nonterminals and their rules. 9 Earley (1970) also generalized the algorithm to prove this item only if it can appear in a proof of some string that begins with x 0:(j+∆) , for a fixed ∆. This is lookahead of ∆ tokens.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 322d242c-4c7d-4cb5-aacf-60bfe1d1783cCited by top-tier papers3
- Syntactic and Semantic Control of Large Language Models via Sequential Monte CarloJoão Loula, Benjamin LeBrun, Li Du, Ben Lipkin et al.ICLR 2025
- An Exploration of Left-Corner TransformationsAndreas Opedal, Eleftheria Tsipidi, Tiago Pimentel, Ryan Cotterell et al.EMNLP 2023
- Earley-Driven Dynamic Pruning for Efficient Structured DecodingXintong Sun, Chi Wei, Minghao Tian, Shiwen NiICML 2025
Builds on2
- Constrained Language Models Yield Few-Shot Semantic ParsersRichard Shin, Christopher H. Lin, Sam Thomson, Charles Chen et al.EMNLP 2021 · 131 citations
- Neural Datalog Through Time: Informed Temporal Modeling via Logical SpecificationHongyuan Mei, Guanghui Qin, Minjie Xu, Jason EisnerICML 2020 · 21 citations
Related papers
- Faster general parsing through context-free memoizationGrzegorz HermanPLDI 2020 · 4 citations
- Algorithms for Weighted Pushdown AutomataAlexandra Butoi, Brian DuSell, Tim Vieira, Ryan Cotterell et al.EMNLP 2022 · 2 citations
- A Root of a Problem: Optimizing Single-Root Dependency ParsingMilos Stanojevic, Shay B. CohenEMNLP 2021 · 5 citations
- Algorithms for Acyclic Weighted Finite-State Automata with Failure ArcsAnej Svete, Benjamin Dayan, Ryan Cotterell, Tim Vieira et al.EMNLP 2022 · 2 citations
- Zippy LL(1) parsing with derivativesRomain Edelmann, Jad Hamza, Viktor KuncakPLDI 2020 · 13 citations
