Vol. 4 No. 8 (2025)
Articles

Keyword-Constrained Retrieval-Augmented Generation for Large Language Models

Wenrui Ma
University of Southern California, Los Angeles, USA
Weiyi Zhong
Independent Researcher, Bellevue, USA

Published 2025-08-30

How to Cite

Ma, W., & Zhong, W. (2025). Keyword-Constrained Retrieval-Augmented Generation for Large Language Models. Journal of Computer Technology and Software, 4(8). https://doi.org/10.5281/zenodo.21699666

Abstract

This study addresses the problems of semantic drift, redundant information, and hallucinatory outputs in retrieval-augmented generation for open-domain question answering and knowledge-intensive tasks, and proposes an improved method based on large language models with keyword constraints. The method introduces a keyword coverage mechanism in the retrieval stage to explicitly control the relevance of retrieved results and ensure semantic consistency between candidate documents and queries, while in the generation stage, it applies a keyword constraint strategy to softly restrict the decoding process, enhancing the specificity and accuracy of generated content. To evaluate its effectiveness, systematic experiments were conducted from multiple perspectives, including performance comparison with traditional retrieval-augmented generation models as well as analyses of hyperparameter sensitivity, environmental sensitivity, and data sensitivity. The results show that the method outperforms baseline models on TokenF1, ROUGE-L, and BLEU-1, and demonstrates greater robustness and stability. Across experiments on keyword weights, coverage thresholds, the number of retrieved documents, similarity measures, and query noise perturbations, the model exhibits clear performance trends, further confirming the critical role of keyword constraints in balancing retrieval and generation quality. Overall, the proposed framework improves the relevance and reliability of answers while maintaining fluency, providing effective insights and practical support for building high-precision retrieval-augmented generation systems.