Published 2024-12-30
How to Cite

This work is licensed under a Creative Commons Attribution 4.0 International License.
Abstract
This paper addresses the hallucination problem in the generation process of large language models. It proposes an alignment mechanism designed for hallucination detection and content verification, aiming to improve the model's generation ability in terms of factual consistency and semantic reliability. The method is structured across three dimensions: input modeling, generation consistency, and factual alignment. A multi-module framework is developed, including instruction-aware embeddings, generation constraints, and semantic matching verification. First, the instruction-aware module performs structural modeling of input semantics, guiding the model to maintain semantic focus during the generation phase. Second, consistency loss and multi-path KL constraints are introduced into the generation process to suppress random hallucinations. Finally, by combining external knowledge retrieval with semantic similarity computation, the model performs factual verification and semantic comparison of the generated text, thereby receiving stable alignment feedback signals. In the experimental section, multiple evaluation tasks are designed to cover hyperparameter sensitivity, robustness to data perturbations, and changes in inference mechanisms. These experiments systematically validate the proposed alignment mechanism under different conditions, including input length, temperature settings, decoding strategies, and training data quality. Compared with existing public models and methods, the proposed approach shows clear advantages in hallucination suppression, factual consistency, and semantic matching. This demonstrates the comprehensive ability of the alignment mechanism to support generation control and content reliability in large language models.