Data Engineering and Large Language Model Construction for the Food Safety Domain
Si Shen, Wenhua Zhao, Liu Liu, Dongbo Wang, Tiansheng ZhengLarge language models (LLMs) have demonstrated remarkable capabilities in natural language processing; however, their direct application to food safety remains limited by insufficient domain knowledge, inadequate reasoning over regulatory documents, and the tendency to generate factual hallucinations. To address these challenges, this study proposes FSLLM, a domain-specific LLM designed for food safety applications. A high-quality domain corpus was constructed from diverse sources, including food safety incidents, regulatory documents, inspection reports, and industry-related materials. It initially comprised approximately 150 million tokens, of which 45,024 documents and approximately 121 million tokens were retained after decontamination. Based on the Qwen3-8B foundation model, FSLLM was developed through a two-stage training framework consisting of continual pre-training for domain knowledge adaptation and supervised fine-tuning for task alignment. Furthermore, a comprehensive benchmark covering 10 representative food safety tasks, including named entity recognition, text classification, text generation, factual verification, regulatory compliance analysis, and public health question answering, was established for systematic evaluation. Experimental results show that FSLLM outperforms the base model across multiple food safety tasks. Specifically, FSLLM achieved a Micro-F1 score of 0.5286 in named entity recognition and an accuracy of 85.21% in food safety event classification, demonstrating improvements over the base model. These findings indicate that domain-specific corpus and continual pre-training with fine-tuning enhance LLM expertise and reasoning, offering a viable solution for intelligent food safety supervision and risk analysis.