{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/algorithms-for-acyclic-weighted-finite-state","title":"Algorithms for Acyclic Weighted Finite-State Automata with Failure Arcs","arxiv_id":"2301.06862","date":"2023-01-17","proceeding":null,"authors":["Anej Svete","Benjamin Dayan","Tim Vieira","Ryan Cotterell","Jason Eisner"],"abstract":"Weighted finite-state automata (WSFAs) are commonly used in NLP. Failure transitions are a useful extension for compactly representing backoffs or interpolation in $n$-gram models and CRFs, which are special cases of WFSAs. The pathsum in ordinary acyclic WFSAs is efficiently computed by the backward algorithm in time $O(|E|)$, where $E$ is the set of transitions. However, this does not allow failure transitions, and preprocessing the WFSA to eliminate failure transitions could greatly increase $|E|$. We extend the backward algorithm to handle failure transitions directly. Our approach is efficient when the average state has outgoing arcs for only a small fraction $s \\ll 1$ of the alphabet $\\Sigma$. We propose an algorithm for general acyclic WFSAs which runs in $O{\\left(|E| + s |\\Sigma| |Q| T_\\text{max} \\log{|\\Sigma|}\\right)}$, where $Q$ is the set of states and $T_\\text{max}$ is the size of the largest connected component of failure transitions. When the failure transition topology satisfies a condition exemplified by CRFs, the $T_\\text{max}$ factor can be dropped, and when the weight semiring is a ring, the $\\log{|\\Sigma|}$ factor can be dropped. In the latter case (ring-weighted acyclic WFSAs), we also give an alternative algorithm with complexity $\\displaystyle O{\\left(|E| + |\\Sigma| |Q| \\min(1,s\\pi_\\text{max}) \\right)}$, where $\\pi_\\text{max}$ is the size of the longest failure path.","url_abs":"https://arxiv.org/abs/2301.06862v2","url_pdf":"https://arxiv.org/pdf/2301.06862v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"algorithms-for-acyclic-weighted-finite-state","repo_url":"https://github.com/rycolab/failure-backward","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"none","reach":null}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":null,"mcp":null,"developers":"https://syntology.ai/developers"},"arxiv_metadata":null,"syntology_extracted_results":null}