{"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/pre-3-enabling-deterministic-pushdown","title":"Pre$^3$: Enabling Deterministic Pushdown Automata for Faster Structured LLM Generation","arxiv_id":"2506.03887","date":"2025-06-04","proceeding":null,"authors":["Junyi Chen","Shihao Bai","Zaijun Wang","Siyu Wu","Chuheng Du","Hailong Yang","Ruihao Gong","Shengzhong Liu","Fan Wu","Guihai Chen"],"abstract":"Extensive LLM applications demand efficient structured generations, particularly for LR(1) grammars, to produce outputs in specified formats (e.g., JSON). Existing methods primarily parse LR(1) grammars into a pushdown automaton (PDA), leading to runtime execution overhead for context-dependent token processing, especially inefficient under large inference batches. To address these issues, we propose Pre$^3$ that exploits deterministic pushdown automata (DPDA) to optimize the constrained LLM decoding efficiency. First, by precomputing prefix-conditioned edges during the preprocessing, Pre$^3$ enables ahead-of-time edge analysis and thus makes parallel transition processing possible. Second, by leveraging the prefix-conditioned edges, Pre$^3$ introduces a novel approach that transforms LR(1) transition graphs into DPDA, eliminating the need for runtime path exploration and achieving edge transitions with minimal overhead. Pre$^3$ can be seamlessly integrated into standard LLM inference frameworks, reducing time per output token (TPOT) by up to 40% and increasing throughput by up to 36% in our experiments. Our code is available at https://github.com/ModelTC/lightllm.","url_abs":"https://arxiv.org/abs/2506.03887v1","url_pdf":"https://arxiv.org/pdf/2506.03887v1.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":"pre-3-enabling-deterministic-pushdown","repo_url":"https://github.com/modeltc/lightllm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2506.03887","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2506.03887"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/ModelTC/lightllm","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":3},"by_repo_kind":{"official":{"samples":3,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"18fa00623d84dd02","entry":"get_draft_model_class","repo":"ModelTC/lightllm","repo_kind":"official","path":"lightllm/models/draft_registry.py","file_url":"https://github.com/ModelTC/lightllm/blob/HEAD/lightllm/models/draft_registry.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"18fa00623d84dd02"}},{"code_sha256_prefix":"72b5e8089e8c68a6","entry":"is_valid_ipv6_address","repo":"ModelTC/lightllm","repo_kind":"official","path":"lightllm/utils/net_utils.py","file_url":"https://github.com/ModelTC/lightllm/blob/HEAD/lightllm/utils/net_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"72b5e8089e8c68a6"}},{"code_sha256_prefix":"f24d62912a4ea0f0","entry":"load_model_class","repo":"ModelTC/lightllm","repo_kind":"official","path":"lightllm/models/registry.py","file_url":"https://github.com/ModelTC/lightllm/blob/HEAD/lightllm/models/registry.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f24d62912a4ea0f0"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}