Proceedings

Grammar-State Aware Beam Search for Enhancing Structural Diversity in LLM Generation

Download BibTeX Cite

Proceedings of the Thirty-Fifth International Joint Conference on Artificial Intelligence. Main Track. Pages 5739-5747.

https://doi.org/10.24963/ijcai.2026/639

Abstract

In many large language model (LLM) applications, generating structurally diverse candidate outputs is crucial for downstream decision-making and reasoning. However, conventional beam search allocates search budget at the token-prefix level, so multiple beam slots may be occupied by lexically different but structurally similar hypotheses. To address these limitations, we propose Grammar-State Aware Beam Search (GSA-Beam). Our method first organizes search at the constraint state level rather than individual prefix level, enabling explicit control over structural diversity. It further incorporates a dynamic state-level beam regulation mechanism that adaptively adjusts beam allocation based on the branching of constraint states, efficiently exploring the feasible structured solution space. Experiments on JSON-schema constrained generation show that GSA-Beam improves explicit state coverage and final structural diversity while preserving schema validity; across several LLM backbones, it reduces reference latency by 22.5% on average compared with standard constrained beam search. Code is available at https://github.com/Paradozile/GSABeam.

  1. [AI@Meta, 2024] AI@Meta. Llama 3 model card. 2024.
  2. [Ao et al., 2025] Jicong Ao, Fan Wu, Yansong Wu, Abdalla Swiki, and Sami Haddadin. Llm-as-bt-planner: Leverag- ing llms for behavior tree generation in robot task plan- ning. In 2025 IEEE International Conference on Robotics and Automation (ICRA), pages 1233-1239. IEEE, 2025.
  3. [Cao et al., 2024] Boxi Cao, Mengjie Ren, Hongyu Lin, Xi- anpei Han, Feng Zhang, Junfeng Zhan, and Le Sun. StructEval: Deepen and broaden large language model as- sessment via structured evaluation. In Lun-Wei Ku, Andre Martins, and Vivek Srikumar, editors, Findings of the As- sociation for Computational Linguistics: ACL 2024, pages 5300-5318, Bangkok, Thailand, August 2024. Associa- tion for Computational Linguistics.
  4. [Chan et al., 2025] Brian J. Chan, Jui-Hung Cheng, Mao Xun Huang, Chao-Ting Chen, and Hen-Hsen Huang. Efficient beam search for large language models using trie-based decoding. arXiv preprint arXiv:2502.00085, 2025.
  5. [Chen et al., 2025] Junyi Chen, Shihao Bai, Zaijun Wang, Siyu Wu, Chuheng Du, Hailong Yang, Ruihao Gong, Shengzhong Liu, Fan Wu, and Guihai Chen. Pre3: En- abling deterministic pushdown automata for faster struc- tured llm generation. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 11253-11267, 2025.
  6. [Chomatek et al., 2025] Łukasz Chomatek, Jakub Papuga, Przemyslaw Nowak, and Aneta Poniszewska-Marańda. Decoding ci/cd practices in open-source projects with llm insights. In Proceedings of the 33rd ACM International Conference on the Foundations of Software Engineering, pages 1638-1644, 2025.
  7. [DeepSeek-AI, 2025] DeepSeek-AI. Deepseek-r1: Incen- tivizing reasoning capability in llms via reinforcement learning, 2025.
  8. [Dong et al., 2025] Yixin Dong, Charlie F Ruan, Yaxing Cai, Ziyi Xu, Yilong Zhao, Ruihang Lai, and Tianqi Chen. Xgrammar: Flexible and efficient structured generation engine for large language models. Proceedings of Machine Learning and Systems, 7, 2025.
  9. [Ge et al., 2023] Suyu Ge, Yunan Zhang, Liyuan Liu, Minjia Zhang, Jiawei Han, and Jianfeng Gao. Model tells you what to discard: Adaptive kv cache compression for llms. arXiv preprint arXiv:2310.01801, 2023.
  10. [Geng et al., 2023] Saibo Geng, Martin Josifoski, Maxime Peyrard, and Robert West. Grammar-constrained decoding for structured nlp tasks without finetuning. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 10932-10952. As- sociation for Computational Linguistics, 2023.
  11. [Gerganov, 2023] Georgi Gerganov. llama.cpp: A portable high-performance inference engine for llama models. GitHub repository, 2023. Open-source project, MIT Li- cense.
  12. [Gu et al., 2018] Jiatao Gu, Daniel Jiwoong Im, and Vic- tor OK Li. Neural machine translation with gumbel- greedy decoding. In Proceedings of the AAAI conference on artificial intelligence, volume 32, 2018.
  13. [Hong et al., 2025] Zijin Hong, Zheng Yuan, Qinggang Zhang, Hao Chen, Junnan Dong, Feiran Huang, and Xiao Huang. Next-generation database interfaces: A survey of llm-based text-to-sql. IEEE Transactions on Knowledge and Data Engineering, 2025.
  14. [Jiang et al., 2023] Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, Lélio Renard Lavaud, Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Thibaut Lavril, Thomas Wang, Timothée Lacroix, and William El Sayed. Mistral 7b, 2023.
  15. [Kool et al., 2019] Wouter Kool, Herke Van Hoof, and Max Welling. Stochastic beams and where to find them: The gumbel-top-k trick for sampling sequences without re- placement. In International conference on machine learn- ing, pages 3499-3508. PMLR, 2019.
  16. [Kwon et al., 2023] Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with pagedattention. In Proceedings of the 29th sym- posium on operating systems principles, pages 611-626, 2023.
  17. [Kwon, 2025] Woosuk Kwon. vLLM: An Efficient Inference Engine for Large Language Models. PhD thesis, Univer- sity of California, Berkeley, 2025.
  18. [Luo et al., 2025] Linhao Luo, Zicheng Zhao, Gholam- reza Haffari, Yuan-Fang Li, Chen Gong, and Shirui Pan. Graph-constrained reasoning: Faithful reasoning on knowledge graphs with large language models. In Aarti Singh, Maryam Fazel, Daniel Hsu, Simon Lacoste-Julien, Felix Berkenkamp, Tegan Maharaj, Kiri Wagstaff, and Jerry Zhu, editors, Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Pro- ceedings of Machine Learning Research, pages 41540- 41565. PMLR, 13-19 Jul 2025.
  19. [Meister et al., 2021] Clara Meister, Martina Forster, and Ryan Cotterell. Determinantal beam search. arXiv preprint arXiv:2106.07400, 2021.
  20. [Nous Research, 2024] Nous Research. Json-mode- eval. https://huggingface.co/datasets/NousResearch/ json-mode-eval, 2024. Hugging Face dataset; accessed 2025-10-07. Link
  21. [Steinbiss et al., 1994] Volker Steinbiss, Bach-Hiep Tran, and Hermann Ney. Improvements in beam search. In IC- SLP, volume 94, pages 2143-2146, 1994.
  22. [Ugare et al., 2024] Suhas Ugare, Tarun Suresh, Hanjun Kang, Faisal Ahmed, Yelong Qi, Anusha Kannan, Yuntian Cao, Kathryn Mazaitis, and Graham Neubig. Syncode: Llm generation with grammar augmentation. Transactions on Machine Learning Research, 2024. TMLR.
  23. [Vaswani et al., 2017] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
  24. [Vijayakumar et al., 2016] Ashwin K. Vijayakumar, Michael Cogswell, Ramprasath R. Selvaraju, Qing Sun, Stefan Lee, David Crandall, and Dhruv Batra. Diverse beam search: Decoding diverse solutions from neural sequence models. In Proceedings of the 2016 AAAI Conference on Artificial Intelligence, 2016.
  25. [Wei et al., 2024] Chengwei Wei, Kee Kiat Koo, Amir Ta- vanaei, and Karim Bouyarmane. Confidence-aware sub- structure beam search (cabs): Mitigating hallucination in structured data generation with large language models. arXiv preprint arXiv:2406.00069, 2024.
  26. [Willard and Louf, 2023] Brandon T. Willard and Rémi Louf. Efficient guided generation for large language mod- els, 2023.
  27. [Yang et al., 2025] An Yang, Anfeng Li, Baosong Yang, Be- ichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, Chujie Zheng, Dayi- heng Liu, Fan Zhou, Fei Huang, Feng Hu, Hao Ge, Hao- ran Wei, Huan Lin, Jialong Tang, Jian Yang, Jianhong Tu, Jianwei Zhang, Jianxin Yang, Jiaxi Yang, Jing Zhou, Jin- gren Zhou, Junyang Lin, Kai Dang, Keqin Bao, Kexin Yang, Le Yu, Lianghao Deng, Mei Li, Mingfeng Xue, Mingze Li, Pei Zhang, Peng Wang, Qin Zhu, Rui Men, Ruize Gao, Shixuan Liu, Shuang Luo, Tianhao Li, Tianyi Tang, Wenbiao Yin, Xingzhang Ren, Xinyu Wang, Xinyu Zhang, Xuancheng Ren, Yang Fan, Yang Su, Yichang Zhang, Yinger Zhang, Yu Wan, Yuqiong Liu, Zekun Wang, Zeyu Cui, Zhenru Zhang, Zhipeng Zhou, and Zihan Qiu. Qwen3 technical report, 2025. Zheng et al., 2024] Lianmin Zheng, Liangsheng Yin, Zhiqiang Xie, Chuyue Sun, Jeff Huang, Cody Hao Yu, Shiyi Cao, Christos Kozyrakis, Ion Stoica, Joseph E. Gon- zalez, Clark Barrett, and Ying Sheng. Sglang: Efficient execution of structured language model programs. In A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, and C. Zhang, editors, Advances in Neural Information Processing Systems, volume 37, pages 62557-62583.
  28. Curran Associates, Inc., 2024.

References were extracted automatically from the PDF and may contain errors.

Welcome Future Conferences AI Journal Division IJCAI Proceedings About IJCAI IJCAI Awards