A progressive fine-tuning strategy for domain-specific large language models in wastewater treatment plants safety Authors: Lina Tang, Ziyi Bian, Kai Liu, Zhiyao Zhao, Jiping Xu, Xiaoyi Wang, Jiabin Yu Published: 2026 ABSTRACT AbstractThe management of safety in wastewater treatment plants (WWTPs) is faced with fundamental challenges, including sparse domain knowledge, dynamic evolution of safety protocols, and the necessity for highly reliable decision-making. While traditional risk assessment methods and expert systems provide essential support, they struggle to integrate multi-source heterogeneous knowledge to mitigate high-consequence, low-frequency(HCLF) risks. Existing general-purpose large language models (LLMs) demonstrate significant deficiencies in domain-specific knowledge, meanwhile, traditional fine-tuning methods are susceptible to catastrophic forgetting and knowledge conflicts during continual learning, rendering them unsuitable for direct application in this context. To address these challenges, this study proposes a progressive fine-tuning strategy to develop a domain-specific LLM tailored specifically for WWTP safety management. First, a domain-specific dataset is constructed through specialized dataset engineering. Subsequently, the proposed progressive fine-tuning strategy partitions domain knowledge into sequential stages, enabling the model to gradually learn and consolidate core knowledge at each stage before proceeding to the next. This orderly accumulation process ensures the deep integration of knowledge. The model is deployed and continuously optimized using vLLM, and direct preference optimization (DPO). The experimental results demonstrate that the progressive fine-tuning strategy effectively mitigates knowledge conflicts arising from multi-task fine-tuning. This approach not only ensures precise adherence to bottom-line safety protocols and enhances the model’s depth of domain understanding in WWTP safety management, but also facilitates more coordinated capability allocation and knowledge integration across different professional tasks. By progressively refining the model, the proposed approach achieves superior task-specific performance even compared to models with substantially larger parameter scales, offering an effective and reproducible pathway for addressing analogous domain adaptation challenges.Keywords: Wastewater treatment plants safety, Large language models, Progressive fine-tuning, Dataset engineeringSubject terms: Engineering, Mathematics and computing Introduction Wastewater treatment plants (WWTPs) serve as critical infrastructure for safeguarding regional aquatic environmental safety and public health, thus, their stable operation is of paramount importance1,2. With the continuous strengthening of national requirements for environmental infrastructure safety, the industry has preliminarily established a systematic safety management framework, along with corresponding bodies of knowledge and knowledge bases and regulatory standards3. However, in practical operation, WWTP safety management continues to face two core challenges4. First, safety related knowledge is deeply embedded in national regulations, operational procedures, accident case reports, and expert experience. This knowledge is highly specialized and unstructured, and it exhibits a sparse distribution across data sources and learning across different types of knowledge can easily lead to a “knowledge conflict dilemma” As a result, traditional models struggle to effectively capture and interpret HCLF risks patterns from large volumes of routine data, leading to pronounced knowledge sparsity at the data level5. Second, operational conditions in WWTPs—including influent water quality, and discharge standards-exhibit continuous temporal variation6. This dynamic environment requires models not only to continuously acquire new knowledge but also to preserve previously learned core safety knowledge. As a result, WWTPs face the challenge of balancing stabitity with the need for continuous madel updatas7. The emergence of large language models (LLMs), together with their outstanding capabilities in natural language understanding and strong general reasoning knowledge, has provided a new paradigm for addressing the aforementioned challenges8,9. However, general-purpose LLMs exhibit inherent limitations when applied to highly specialized domains such as wastewater treatment10. Their intrinsic knowledge gap often lead to misinterpretation of domain-specific terms, (e.g., “sludge bulking” and “hydrogen sulfide poisoning”), insufficient sensitivity to low-frequency yet HCLF safety risks, and uncontrollable outputs. Direct deployment may therefore result in misinterpretation of professional terminology, reasoning breakdowns along complex process chains11, and even the generation of safety-violating hallucinations, posing serious safety hazards12. Consequently, the direct application of general-purpose models is infeasible, making domain-specific fine-tuning indispensable13. However, existing mainstream fine-tuning approaches, including full-parameter fine-tuning and parameter-efficient fine-tuning, still face fundamental challenges when applied to WWTP safety management characterized by sparse, heterogeneous, and dynamically evolving knowledge. In traditional full-parameter fine-tuning settings, knowledge conflicts are likely to occur, primarily due to significant distributional differences among heterogeneous knowledge sources14. As the model attempts to adapt to diverse data characteristics, imbalanced trade-offs can emerge, which in turn degrade overall generalization performance15. Consequently, how to effectively suppress knowledge conflicts while preserving knowledge sharing across tasks, and thereby enhance model stability and generalization in complex scenarios, has become a critical challenge for application of LLMs in specialized domains such as wastewater treatment. To address the above challenges, this study proposes a progressive fine-tuning strategy for a domain-specific LLM tailored to WWTP safety management. The main contributions are summarized as follows. First, a dataset engineering framework for the WWTP safety domain is constructed, providing a reliable data foundation for fine-tuning. Second, by simulating the cognitive growth process of domain experts, fragmented safety knowledge is injected into the model in a stage-wise manner, guiding the model to achieve progressive cognitive construction. This work fills the research gap regarding systematic fine-tuning and cognitive construction for WWTP safety domain and offers a reproducible fine-tuning strategy for the trustworthy adaptation of LLMs in HCLF industrial scenarios. The structure of this paper is organized as follows: Sect. “Introduction” presents the introduction and research background; Sect. “Related work” provides a literature review and systematically summarizes related studies; Sect. “Methods and overall framework” details the research methods employed; Sect. “Experimental results and analysis” presents experimental analysis and results. Section “Conclusion” concludes the paper. Related work Traditional safety management and operational assurance methods for wastewater treatment plants Safety management in wastewater treatment plants has long relied on traditional risk assessment and operational assurance methods, which can be broadly categorized into four types, (1)Traditional risk assessment methods, such as HAZOP, LOPA, and FMEA, enable systematic analysis of known hazard sources based on process flows. HAZOP is a classical methodology widely adopted in the process industry. Mocellin16 systematically summarized the basic HAZOP procedure, noting that the method is typically organized around process nodes, parameter deviations, and guidewords for identifying potential hazards and operability issues, and is characterized by well-defined structure and strong interpretability. (2) In the area of process monitoring and alarm management, Luo17 proposed an adaptive online optimization method for alarm thresholds based on multilayer Bayesian networks and active transfer entropy, enabling dynamic adjustment of alarm thresholds in response to changes in process conditions, thereby demonstrating that online adaptive optimization can enhance the responsiveness of alarm systems to process variations.(3) With regard to knowledge-based diagnostic methods, Puñal18 constructed an expert system for monitoring and diagnosis of anaerobic wastewater treatment plants; Wu19 further proposed an online intelligent expert diagnostic system for anaerobic wastewater treatment processes, integrating online monitoring systems with an expert diagnostic database to enable diagnostic, predictive, and early-warning functions. These works demonstrate that expert systems can systematize operational experience and diagnostic knowledge for application in process state identification and fault diagnosis in wastewater treatment. (4) In data-driven methods, Li20 proposed a CNN-LSTM effluent quality prediction model incorporating an attention mechanism. The results showed that the introduction of CNN and the attention mechanism improved prediction accuracy, indicating that deep learning approaches hold considerable promise for water quality prediction in wastewater treatment. It is worth noting that in traditional industrial control domains, knowledge updating is typically achieved through continual learning and domain adaptation strategies. Existing studies have employed strategies such as continual learning, elastic weight consolidation (EWC), and feature space alignment to improve model adaptability to pattern shifts, feature drift, and catastrophic forgetting21,22. However, when applied to wastewater treatment plant safety management scenarios, these methods exhibit notable limitations. They are primarily designed to handle dynamic data streams and feature distribution shifts in industrial processes, but their adaptability remains limited when confronted with the multi-dimensional, semantically heterogeneous tasks involved in WWTP safety management—such as regulatory texts, accident case records, and scenario reasoning. Furthermore, safety management scenarios impose stricter requirements on knowledge consistency and stability, and conventional methods still fall short of meeting the core demands of this domain when balancing new and old knowledge. Existing traditional methods have achieved considerable progress in hazard identification, alarm optimization, expert diagnostics, and water quality prediction. However, most are designed for single-task settings and lack unified support for multi-source knowledge integration, dynamic operating conditions, and complex decision-making requirements. Consequently, they remain inadequate for addressing HCLF risks, with limitations manifesting primarily in three respects: the difficulty of integrating multi-source heterogeneous knowledge dispersed across unstructured texts, limited capacity for semantic association with respect to sparse-sample risks, and insufficient support for high-confidence reasoning that bridges regulatory provisions and real-world operational scenarios. Based on these observations, the introduction of LLMs—which possess strong text comprehension and logical reasoning capabilities—offers new possibilities for addressing the challenges of knowledge sparsity and risk dynamics in this domain. Applications of LLMs in wastewater treatment scenarios Building upon the recognized capability boundaries of the aforementioned traditional methods, researchers have begun to explore the integration of Large Language Models (LLMs) into wastewater treatment scenarios. The fundamental motivation lies in the potential of LLMs to address the longstanding underutilization of multi-source heterogeneous knowledge23. At the level of operational decision-making, Samuel Rothfarb24 innovatively constructed a multi-agent LLM framework comprising collaborating specialized components—a problem identifier, a data analyst, a research analyst, and a decision generator—which collectively achieved integrated analysis of multi-source heterogeneous data and real-time decision support, thereby substantially enhancing the precision of process control and the rigor of operational decision-making. In the field of anomaly diagnosis, Xu adopted an alternative approach by training high-accuracy random forest “small models” as carriers of domain knowledge and using their outputs as activation keys to guide LLMs toward professional reasoning, significantly enhancing diagnostic accuracy and interpretability25. In water quality monitoring and spectral analysis, the study by Liang demonstrated that even through carefully designed prompt engineering alone, LLMs could achieve, or even surpass, the predictive accuracy of traditional machine learning models in UV–NIR spectral prediction of chemical oxygen demand, substantially lowering the barrier to practical application26. In terms of systematic evaluation and optimization, Xu first established WaterER, the first large-scale evaluation benchmark for water-related LLM tasks. Building upon this benchmark, the authors further developed a domain-specific model, WaterGPT, by fine-tuning open-source LLMs, achieving a 135.4% performance improvement in engineering tasks. These results empirically demonstrate the substantial advantages of fine-tuning over prompt-based approaches27. The studies reviewed above demonstrate that LLMs have shown considerable promise across multiple operational aspects of wastewater treatment. Nevertheless, in the HCLF domain of safety management and control, relevant research remains conspicuously absent. This domain imposes exceptionally stringent requirements on both the accuracy of domain knowledge and the regulatory compliance of decision outputs. General-purpose models, lacking the requisite vertical industry knowledge, are prone to generating hallucinations that contradict established safety protocols. Accordingly, how to design a fine-tuning strategy capable of guiding models to internalize domain-specific knowledge while maintaining an effective balance between stability and plasticity has emerged as the central challenge in enabling the reliable deployment of LLMs within the safety management domain of wastewater treatment plants. Fine-tuning techniques for LLMs LLM fine-tuning has been successfully validated across multiple domains, including healthcare, law, and finance, leading to the emergence of a series of domain-specific models such as Med-PaLM28 and FinGPT29. Through targeted fine-tuning of pre-trained models, these approaches effectively transform strong general-purpose capabilities into deep domain expertise. At present, LLM fine-tuning primarily follows two technical paradigms: full-parameter fine-tuning and parameter-efficient fine-tuning. Full-parameter fine-tuning achieves deep domain adaptation by updating all model parameters. Recent studies have made notable progress in reducing communication overhead and memory consumption30. For example, Qin Z. proposed FedKSeed31, while Lv introduced the LOMO optimizer32, both of which enable the fine-tuning of hundred-billion-parameter models under limited computational resources. In terms of safety alignment, Bhardwaj. proposed the RESTA method, which reduces model harmfulness from 18.6% to 5.1% through parameter arithmetic33, while Hsu introduced Safe low-rank adaptation (LoRA), which suppresses safety risks via projection-based techniques34. However, full-parameter fine-tuning remains constrained by substantial computational cost, high storage requirements, and limited deployment flexibility. These limitations become particularly pronounced in scenarios that require frequent adaptation across multiple tasks or domains, where efficiency bottlenecks are increasingly evident. To address these challenges, parameter-efficient fine-tuning (PEFT) techniques have emerged, aiming to significantly improve fine-tuning efficiency by updating only a small subset of model parameters while preserving strong adaptation capability. Among these methods, LoRA has become a representative approach by injecting trainable low-rank matrices to approximate parameter updates. LoRA substantially reduces the number of trainable parameters while achieving performance comparable to full-parameter fine-tuning, and has therefore become a key technique for efficient adaptation of LLMs. In practical applications, Choi proposed the SAFT framework, which reduces model harmfulness by up to 27.8% through harmful sample filtering35. Chen further demonstrated that semi-supervised prefix tuning performs effectively in industrial fault diagnosis scenarios characterized by data scarcity. Collectively, these methods exhibit high parameter efficiency and strong portability across application domains36. However, regardless of whether full-parameter fine-tuning or parameter-efficient fine-tuning is employed, the conventional multi-task parallel fine-tuning paradigm frequently yields degraded performance in wastewater treatment plant safety scenarios, owing to knowledge conflicts arising from the heterogeneous nature of the training data—which encompasses regulatory texts (characterized by hard constraints), accident case records (characterized by weak logical structure), and scenario analysis (characterized by high inferential complexity)37. When the model attempts to simultaneously accommodate these knowledge sources with markedly divergent distributional properties, optimization trade-off imbalances readily emerge. To address this issue, the present study adopts a progressive fine-tuning strategy. This strategy emulates the cognitive developmental trajectory of domain experts by constructing a hierarchically structured training pipeline organized according to the intrinsic logical relationships among knowledge types. Its core principle is to prevent the model from being exposed to all heterogeneous knowledge simultaneously within a single training phase; instead, in accordance with the natural laws of cognitive formation, the model progressively builds its capability structure following a cognitive sequence that advances from foundational regulatory knowledge, through experiential case understanding, to complex inferential reasoning. By controlling the order in which knowledge is introduced into the model’s parameter space, this training paradigm enables fundamental safety regulations to first establish stable knowledge anchors, upon which accident case knowledge and scenario reasoning capabilities are incrementally introduced, thereby effectively reducing optimization competition among distinct knowledge categories.The necessity and superiority of this strategy are reflected in its capacity to substantially suppress negative transfer between heterogeneous knowledge types, preventing hard-constraint regulatory knowledge from being diluted by weakly structured experiential knowledge or high-degree-of-freedom inferential patterns during multi-task parallel training. This ensures that the model retains precise recall of and stable adherence to baseline safety protocols even when performing complex scenario analysis and risk reasoning. Compared with conventional one-pass fine-tuning approaches, this staged and progressive knowledge internalization mechanism not only enhances the hierarchical organization of knowledge representations, but also improves the controllability and trustworthiness of the model’s decision-making process. The result is a domain-specific model for wastewater treatment that embodies greater knowledge depth and more reliable decision-making capacity, thereby filling a critical gap in the technical adaptation of large language models for HCLF industrial safety scenarios. Methods and overall framework Overall process The overall workflow consists of three stages: dataset engineering, progressive fine-tuning, and Model Deployment and Continuous Optimization, forming a complete closed-loop process from data to application that is capable of autonomous evolution. First, multiple types of dataset engineering are constructed to establish a solid knowledge foundation for model training. Subsequently, the progressive fine-tuning strategy is applied to gradually enhance the model’s domain-specific understanding and predictive capabilities. Finally, after deployment, the model is continuously optimized through feedback to ensure its ability to adapt to the dynamic requirements of WWTP safety management. The overall framework is illustrated in Fig. 1. Overall framework of the proposed progressive fine-tuning approach. Dataset engineering The construction of the dataset engineering follows the core principles of business-driven design, multidimensional coverage, and stage alignment, with the objective of providing a complete knowledge chain to support progressive fine-tuning for WWTP safety management. This knowledge chain spans all critical stages, extending from compliance foundations to risk identification, and further encompassing scenario-based decision-making and interactive applications. This knowledge chain systematically covers all stages, ranging from foundational legal and regulatory compliance, through risk identification, to scenario-based decision-making and interactive applications. The overall data system consists of four interrelated dataset engineering components. Fig. 2(a) and (b) show the number of samples and their respective proportions across the four domains, including legal and regulatory texts (13,276 samples), accident cases (9,813 samples), scenario analysis data (16,782 samples), and professional question–answer data (12,742 samples); Fig. 2(c) compares the training and evaluation sets across these four domains, where the evaluation set comprises 1,000 samples randomly selected from each domain, resulting in a total of 4,000 evaluation samples, which are used to comprehensively assess model performance under diverse scenarios. All four dataset engineering components are constructed through a unified and rigorous data processing pipeline, ensuring the breadth, depth, and overall quality of the datasets. Overview of the constructed datasets. (a) number of samples across different domains; (b) proportion of datasets across different domains; (c) comparison between training and evaluation sets across different domains. Legal and regulatory dataset engineering To ensure that the LLM achieves a comprehensive and accurate understanding of laws and regulations related to WWTPs, this study constructs a dedicated laws and regulations dataset engineering. During the data collection stage, legal and regulatory texts were systematically acquired from multiple authoritative sources, including official government websites, legal service platforms, and industry standard repositories, covering both national-level and local environmental laws and regulations as well as relevant industry standards. To guarantee data timeliness and completeness, an automated data acquisition system based on web crawling techniques was configured to perform periodic updates, supplemented by manual review to incorporate specific local regulations and industry standards, thereby ensuring comprehensive and accurate coverage. During the data screening and cleaning stage, the collected texts were first standardized in format and uniformly converted into structured article-based representations, with excessively long paragraphs appropriately segmented. To address potential duplication arising from regulatory revisions, text similarity computation and hash-based matching were applied to remove redundant entries and ensure the uniqueness of each provision. In addition, natural language processing techniques were employed to extract core keywords such as “wastewater treatment” and “pollutant discharge,” facilitating data categorization and content focus. Through relevance analysis, provisions unrelated to WWTP safety management were excluded, thereby enhancing the dataset’s specificity and practical relevance. Following these procedures, a high-quality dataset containing 13,276 legal and regulatory entries was ultimately constructed. This dataset engineering process is characterized by comprehensive coverage, standardized structure, and clear thematic focus, providing professional and reliable legal text support for subsequent LLM training and application. Representative data samples are presented in Table 1. Table 1Examples of structured annotation for legal and regulatory texts.IDTitleMain contentKeywordsPublication dateLatest revision date001《Law of the People’s Republic of China on the Prevention and Control of Water Pollution》Article 84: Where an outfall is installed within a drinking water source protection area, the local people’s government at or above the county level shall order its removal within a prescribed time limit and impose a fine of no less than 100,000 yuan …discharge outlet; fine; …1984-05-112017-06-27002《Environmental Protection Law of the People’s Republic of China》Article 50: People’s governments at all levels shall allocate funds in their fiscal budgets to support the protection of rural drinking water sources, the treatment of domestic wastewater, and other wastes …wastewater treatment; environmental protection; …1989-12-262014-04-24003《Measures for the Supervision and Administration of River Discharge Outlets》Article 6: River discharge outlets are classified into four categories according to the industry of the responsible entity and discharge characteristics, including industrial discharge outlets, urban WWTP outlets, agricultural outlets, and others …river discharge outlet; urban WWTP outlet; …2024-10-162024-10-16004《Regulations on Ecological Environmental Damage Compensation Management》Article 4: Ecological environmental damage refers to adverse changes to the atmosphere, surface water, groundwater, and other environmental elements caused by environmental pollution or ecological destruction …ecological environmental damage; adverse groundwater change; …2022-04-262022-04-26 Examples of structured annotation for legal and regulatory texts. Scenario analysis dataset engineering In research on WWTP safety management, the construction of a scenario analysis dataset plays a critical role in identifying safety risks and enhancing the contextual awareness of generative LLMs. In this study, a scenario analysis dataset engineering process comprising 16,782 scenario records was developed, covering a wide range of operational conditions, environmental variations, and emergency situations. This dataset provides diverse scenario information to the model, thereby strengthening its capability to address complex real-world conditions. Data collection integrated multiple sources of real-world materials, including historical accident reports, safety inspection and risk assessment records, expert interviews, on-site investigation findings, as well as relevant environmental and safety standard documents. By extracting accident backgrounds, operational procedures, and consequences, and combining expert experience with standard specifications, risk sources and potential vulnerabilities across different scenarios were systematically identified. During the data processing and annotation stage, each scenario was transformed into a structured representation, with explicit labels assigned to attributes such as scenario type, associated facilities, operational processes, safety risks, risk levels, and corresponding mitigation measures. In addition, key factors including personnel conditions, equipment status, and environmental factors were incorporated to support fine-grained contextual analysis and risk assessment. After removing irrelevant information through data cleaning, a high-quality and highly focused scenario analysis dataset was obtained, providing effective support for model training. Some data examples are presented in Table 2. Table 2Examples of structured annotation for scenario analysis.IDScenario typeScenario descriptionRisk levelEquipment and facilitiesSafety riskMitigation measures001Equipment failureEquipment malfunction is detected during shutdown inspection, and the water pump fails to start …HighWater pump; motorPump shutdown leads to reduced wastewater treatment capacityActivate the backup pump and immediately repair the faulty pump …002Human errorThe operator accidentally presses an incorrect control button, resulting in excessive chemical injection …MediumChemical injection systemExcessive chemical dosage may cause environmental pollutionImmediately stop chemical injection and initiate emergency response procedures …003Environmental anomalySudden heavy rainfall causes overload of the drainage system …HighDrainage pumps; pipeline systemDrainage system overload leads to overflowActivate the emergency drainage system and issue early warnings in coordination with meteorological services … Examples of structured annotation for scenario analysis. Accident case dataset engineering In research on WWTP safety management, accident case data play a critical role in risk identification as well as in supporting early warning and emergency response. By incorporating historical accident information into model fine-tuning, the model’s capabilities in accident prediction, risk assessment, and emergency handling can be effectively enhanced, thereby strengthening overall plant safety management performance. In this study, a dataset engineering effort comprising 9,813 accident cases was constructed, covering safety incidents occurring under a wide range of scenarios, including routine operation, equipment failures, operational errors, and changes in external environmental conditions. The data were collected from multiple sources, such as accident investigation reports, safety drill records, industry case studies, and analytical reports. Key information—including accident type, causal factors, related facilities, operational vulnerabilities, consequences, and corresponding response measures—was systematically extracted to ensure comprehensive coverage and diversity, thereby improving the model’s generalization capability. During the data annotation and structuring stage, each accident case was uniformly labeled with attributes such as time, location, facilities involved, causes, consequences, emergency measures, and impact scope, with particular emphasis on accurately reconstructing the real accident context and handling processes. Text similarity algorithms and deduplication techniques were applied to eliminate redundant cases, ensuring data uniqueness and training effectiveness. After systematic processing, the resulting dataset exhibits a clear structure and comprehensive information content, providing effective support for the precise training and practical application of LLMs in WWTP safety management. Some data examples are presented in Table 3. Table 3Examples of accident cases in WWTPs.IDCase descriptionDateaccident typeDirect CauseConsequencesCorrective measures and best practices001On June 30, 2024, a severe coke oven gas leakage and explosion accident occurred at a WWTP of a coking facility in Shanxi Province …2024-06-30Coke oven gas leakage and explosionIgnition source generated during welding operations combined with gas leakage5 fatalities, 7 severe injuries, and direct economic losses of RMB 28 million(1) Conduct regular wall thickness inspections and pressure tests; (2) install gas monitoring and alarm systems; (3) strictly enforce hot work permit management …002On November 5, 2023, a tragic chloroform poisoning accident occurred at a wastewater treatment station of an electronics factory in Jiangsu Province …2023-11-05Chloroform poisoningAccumulation of toxic gases due to an uncovered wastewater equalization tank2 fatalities and direct economic losses of RMB 5 million(1) Cover the equalization tank and install exhaust gas treatment systems; (2) enforce forced ventilation and gas detection; (3) require mandatory use of personal protective equipment …003On September 20, 2021, a serious nickel-containing wastewater leakage accident occurred at a wastewater treatment facility of an electroplating factory in Hunan Province …2021-09-20Nickel-containing wastewater leakageWastewater leakage caused by structural cracks in the treatment tankWater and soil contamination with direct economic losses of RMB 26 million(1) Upgrade corrosion protection of treatment tanks; (2) install leakage sensors and monitoring systems; (3) strengthen emergency material reserves and response drills … Examples of accident cases in WWTPs. Knowledge question-answering dataset engineering To support the LLM in comprehensively acquiring knowledge related to WWTPs, this study constructs a knowledge question–answer dataset engineering. This dataset engineering integrates multiple sources, including industry standards, technical literature, training materials, and public educational platforms, and systematically collects question types such as multiple-choice and fill-in-the-blank items covering core topics including treatment processes, facilities and equipment, and emergency response. During the data cleaning and annotation stage, the original questions were standardized in format and uniformly organized into a “question–answer–explanation” structure to ensure data consistency and readability. Text similarity algorithms were applied to remove duplicate entries, guaranteeing the uniqueness of each data item. In addition, natural language processing techniques were used to extract keywords such as “wastewater treatment processes” and “safety inspection,” enhancing data retrievability and category management. Relevance analysis was further conducted to exclude non-related items, thereby improving the dataset’s specificity and practical applicability. The finalized knowledge question–answer dataset contains a total of 12,742 high-quality entries, characterized by comprehensive coverage, standardized structure, and a focused thematic scope, providing reliable knowledge support for LLM training and application in WWTP safety management. Some data examples are shown in Table 4. Table 4Examples of the knowledge question-answering dataset.IDQuestion typeQuestion contentOptionsAnswerExplanation001Single-choiceFor single- and double-row scaffolds with a height below 24 m, scissor bracing must be installed at (), with one set provided at each location …(A) At both outer ends, corners, and elevations with intermediate spacing not exceeding 15 m (B) At both outer ends, corners, intermediate positions, and elevations with intermediate spacing not exceeding 15 m (C) At intermediate positions (D) At elevations with intermediate spacing not exceeding 15 mAAccording to the Safety Technical Code for Steel Tube Scaffolding with Couplers in Construction (JGJ 130–2011), for single- and double-row scaffolds with a height below 24 m, scissor bracing shall be installed at both outer ends, corners, and elevations with intermediate spacing not exceeding 15 m.002Fill-in-the-blankAccording to the Regulations on the Reporting, Investigation, and Handling of Production Safety Accidents, an accident report shall be submitted within () days from the date of occurrence.–60According to Article 29 of the Regulations on the Reporting, Investigation, and Handling of Production Safety Accidents, the accident investigation report shall be submitted within 60 days from the date of the accident. Examples of the knowledge question-answering dataset. Progressive fine-tuning strategy Traditional fine-tuning strategies are typically performed on the basis of a pre-trained model (as shown in Fig. 3), in which all types of dataset engineering—including laws and regulations, accident cases, scenario analysis, and knowledge question–answer data—are used simultaneously in a single fine-tuning process. Although this approach can improve the model’s overall adaptability to all dataset engineering components, differences in data distribution characteristics and sample sizes across datasets often lead to knowledge conflicts, thereby negatively affecting the model’s learning effectiveness. Conventional multi-task fine-tuning paradigm. To address this issue, the core idea of the proposed progressive fine-tuning strategy is to simulate the growth trajectory of domain experts by injecting knowledge in a stage-wise manner, enabling the model to progressively learn and integrate regulatory knowledge, case-based reasoning, scenario analysis, and question–answer interaction capabilities. As a result, the model exhibits enhanced stability and improved generalization performance in the context of WWTP safety management. The proposed “Progressive” strategy differs fundamentally from conventional phased fine-tuning and continual learning approaches. Phased fine-tuning typically organizes different datasets sequentially from a purely procedural perspective, with the primary objective of improving training stability or incrementally optimizing performance; however, it lacks explicit knowledge continuity across phases. Continual learning, by contrast, focuses on mitigating catastrophic forgetting as new tasks are introduced, but generally treats tasks as temporally ordered increments without explicitly modeling the structural dependencies between knowledge types.In contrast, the progressive strategy proposed in this study is guided by the inherent structure of domain knowledge, with the training sequence designed according to the constraint strength, inferential complexity, and semantic dependency relationships of each knowledge type. The model first learns safety rule representations using the Legal Regulation dataset; as the Accident Case, Scenario Analysis, and Knowledge Q&A datasets are subsequently introduced, the model continuously revisits historical samples while progressively increasing the proportion of retrospective data, ensuring that newly acquired knowledge is consistently built upon the foundation of previously established knowledge. Accordingly, this strategy emphasizes the progressive evolution of knowledge organization rather than the mere incremental accumulation of tasks. Model capabilities are expanded in a structured sequence—from regulatory comprehension, through experiential modeling, to scenario-level reasoning—realizing a cognitively structured parameter optimization process that not only reduces the risk of forgetting, but also mitigates the knowledge conflict problem characteristic of multi-task parallel fine-tuning. The progressive fine-tuning strategy fits different types of dataset engineering incrementally through a phased approach, ensuring that the learning at each stage proceeds in a stable and effective manner. Under this strategy, the fine-tuning process is divided into a series of discrete stages, each of which focuses on training with a specific type of dataset. The model advances to the subsequent stage only after the task of the current stage has been sufficiently fitted and a predefined criterion has been met. This progressive fine-tuning paradigm mirrors the developmental trajectory of domain experts, ensuring that the model fully comprehends and assimilates the target knowledge at each stage before establishing a solid foundation for the next. To ensure the operability and reproducibility of this process, the stage transition criterion is explicitly defined as follows: when the rate of change in the validation loss satisfies and the accuracy fluctuation remains below 0.5% for three consecutive epochs, the model is considered to have reached a knowledge convergence steady state, automatically triggering the transition to the next stage. The fine-tuning process is illustrated in Fig. 4. Specifically, the progressive fine-tuning procedure begins with the Legal Regulation dataset as the initial training phase, which serves to establish stable knowledge representations of safety regulations and provide the model with a foundational basis for compliance constraints. Once the model has acquired a firm grasp of the fundamental regulatory rules, the second stage introduces the Accident Case dataset while retaining a small proportion of regulatory samples for joint training, thereby maintaining the stability of previously acquired knowledge and mitigating parameter drift caused by the introduction of new knowledge. The third stage is dominated by Scenario Analysis data, supplemented by experience replay of historical data, in which regulatory and accident case samples participate in training at proportions of 5% and 15%, respectively. This differentiated replay strategy is designed to continuously activate fundamental rule and experiential knowledge representations while enhancing complex scenario reasoning capabilities, thereby reducing the extent to which high-degree-of-freedom reasoning tasks overwrite established safety knowledge. The final stage employs Knowledge Q&A data to fine-tune the model’s interactive and knowledge retrieval capabilities. To prevent catastrophic forgetting induced by late-stage task training, a globally balanced replay mechanism is introduced at this stage, sampling 5% of historical data from each of the three preceding dataset categories for joint training, enabling the model to maintain global knowledge consistency while further developing its application capabilities. Progressive fine-tuning strategy. Throughout this progressive training process, the incorporation of experience replay at each stage achieves a dynamic balance between stability and plasticity during parameter updates, thereby effectively mitigating catastrophic forgetting and promoting the synergistic integration of multi-type knowledge. Taken as a whole, the progressive fine-tuning strategy constitutes a coherent and organically structured pipeline that builds the model’s knowledge system through the logical sequence of regulations, cases, scenarios, and interactions, yielding superior performance in the domain of wastewater treatment plant safety management. Model deployment and continuous optimization In the model deployment and optimization stage, this study implements an efficient and stable service-oriented deployment using the vLLM inference framework, thereby effectively supporting real-time inference requirements in water safety business scenarios. During system operation after deployment, user interaction data and feedback information are continuously collected, enabling dynamic perception of user needs. To further enhance the safety, consistency, and usability of the model in real-world interactive environments, this study introduces a Direct Preference Optimization (DPO) mechanism. In terms of dataset scale, a dedicated training set comprising 6,000 high-quality preference pairs was constructed. With respect to the construction of preference pairs , this study adopts a “multi-source sampling combined with expert collaborative annotation” approach, wherein denotes the user query or task description, denotes the preferred response that conforms to safety standards, is factually correct, and is of overall higher quality, and denotes the non-preferred response that contains safety risks, factual errors, insufficient logical reasoning, or is of overall lower quality. The specific construction pathways are as follows: (1) multi-candidate sampling with model-based ranking, whereby multiple candidate responses are generated using diverse decoding strategies and subsequently annotated by domain experts with safety backgrounds according to regulatory compliance, logical coherence, and practical operability; and (2) for HCLF scenarios, rule-based filtering and safety constraints are applied to actively construct negative samples exhibiting violation-characteristic features, thereby strengthening the model’s discriminative capability with respect to output boundaries. Given that wastewater treatment plants constitute a HCLF safety-critical domain, this study embeds a four-layer safety constraint mechanism—guardrails—within the DPO data construction and deployment framework, comprising: (1) a rule-based filtering mechanism that intercepts candidate outputs violating industry regulations (such as the Technical Specification for the Operation, Maintenance and Safety of Urban Sewage Treatment Plants) based on sensitive word lexicon and safety templates; (2) an external evaluation model assistance mechanism: an independent reward model quantitatively score the safety and completeness of outputs, providing auxiliary signals for preference ranking; (3) factual consistency verification, through which responses containing knowledge hallucinations or logical conflicts are identified and removed via automated scripts and expert review; and (4) refusal alignment constraints targeting malicious instructions that exceed the model’s knowledge boundaries or pose extreme risks, reinforcing the model’s behavior of issuing stable refusals or safety-oriented guidance to ensure output determinism in analogous HCLF scenarios. This closed-loop optimization strategy, in conjunction with the multi-layer safety protection mechanism, not only enhances the model’s practical utility in long-term deployment but also lays a solid technical foundation for the future advancement of the water safety domain. Experimental results and analysis Experimental environment and application scenario In this study, Qwen2.5-14B-Instruct was selected as the base model, with a parameter scale of 14B. The experimental environment was established on a high-performance server equipped with powerful hardware to support large-scale model training and inference tasks. The server is equipped with four NVIDIA A800 GPUs, providing a total GPU memory capacity of 320 GB, which meets the high memory demands of LLM training, particularly for complex tasks. In terms of processing capability, the server adopts an Intel Xeon Gold 6348 CPU with 14 physical cores, supporting efficient parallel computation and ensuring sufficient computational performance for large-scale data processing and model fine-tuning. The system is further equipped with 100 GB of system memory, effectively supporting large-scale data loading and high-speed caching requirements, thereby ensuring efficiency and stability during model training and inference. The operating system is Ubuntu 22.04, which ensures system compatibility and stability. With respect to the software environment, PyTorch 2.3.0 is used as the deep learning framework. with CUDA version 12.1 and Python version 3.12. Conda 24.4.0 is employed for environment management and package configuration. Overall, the hardware and software configuration provides strong support for LLM fine-tuning and experimental validation. The fine-tuned LLM was successfully deployed at a large WWTP in Tianjin. The plant has a treatment capacity of 280,000 m³/d during the dry season and 450,000 m³/d during the wet season, with a total approved land area of 400,000 m2. It is responsible for treating domestic wastewater from the city and surrounding areas, as well as a portion of industrial wastewater. To meet increasingly stringent environmental protection requirements, the plant adopts multiple treatment processes, including physical, chemical, and biological methods, to ensure that effluent water quality complies with relevant national and local standards. Evaluation metrics and experimental setup Scoring To enhance the transparency and reproducibility of the experimental evaluation, this study adopts a combined human-automated scoring approach for the comprehensive assessment of model output quality. The final composite score is defined as Eq. (1). where HumanScore measures the quality of model responses in terms of linguistic expression, task relevance, and factual correctness, and automatically quantifies the degree of semantic consistency between model-generated responses and reference answers. Human evaluation. Human evaluation assesses model output quality along three dimensions: fluency, relevance, and accuracy. Fluency measures whether the response is grammatically correct, naturally expressed, and linguistically fluent, scored on a scale of 0–100. Relevance measures whether the response directly addresses the question and adequately covers the user’s task requirements, scored on a scale of 0–100. Accuracy measures whether the response is factually correct and consistent with domain knowledge and safety standards, scored on a scale of 0–100. Each dimension is scored on a hundredth scale, denoted as , , and , respectively. The human evaluation score for the i-th sample is defined as follows: where is normalized to the range . Averaging over all N samples yields the overall human evaluation score is defined as Eq. (3). Automated evaluation. The automatic evaluation component is computed using the BERTScore metric. BERTScore is an automatic evaluation index based on contextual semantic representations from pre-trained language models. It leverages pre-trained models such as BERT to generate contextual embeddings for both candidate and reference answers, measuring text quality by calculating the degree of similarity between them in the semantic space. Compared with traditional metrics like BLEU and ROUGE, which primarily rely on surface-level n-gram overlap, BERTScore more effectively captures semantic similarity. Consequently, it is better suited for assessing the consistency between responses generated by large language models and reference answers. In this study, the Precision, Recall, and F1 values of BERTScore are calculated, with the F1 value serving as the foundation for the automatic score. Let and represent the BERTScore Precision and Recall for the i-th sample, respectively; the F1 value is defined as Eq. (4). For the i-th sample, the automatic score is defined as . Furthermore, the overall automatic score is defined as the average across N samples, as shown in Eq. (5). The aforementioned scoring methodology effectively balances the expertise of human evaluation in judging professionalism and safety with the stability of automatic metrics in measuring semantic similarity. Experimental hyperparameters and setup The overall configuration of the progressive fine-tuning process follows the principle of “balancing training stability, parameter efficiency, and convergence effectiveness under limited computational resources”. Key hyperparameters include a learning rate of 2e-5 to avoid excessive perturbation of pre-trained parameters, and a training duration of 7 epochs to ensure sufficient acquisition of domain knowledge while mitigating the risk of overfitting. The batch size is set to 2 to accommodate GPU memory constraints during the fine-tuning of large-parameter models, combined with a cutoff length of 4096 to enhance the model’s ability to model long contexts and complex safety-related texts. Regarding PEFT, this study utilizes the LoRA mechanism. The experiments apply a progressive fine-tuning strategy across four wastewater-related dataset engineering components. The LoRA rank is set to 8, alpha to 16, and dropout to 0.05 to improve domain adaptability while maintaining controllable parameter overhead. The LoRA target modules are selected as q_proj and v_proj, specifically adapting key projection layers within the attention mechanism to effectively inject domain knowledge. Furthermore, the AdamW optimizer is employed with a cosine decay learning rate schedule (including a 10% warmup) to enhance initial training stability and improve late-stage convergence. A maximum gradient norm of 1.0 is applied to suppress gradient fluctuations and ensure a stable training process. To ensure fairness, rigor, and reproducibility across different models, the following standardized configurations were implemented for all comparative experiments: Knowledge Retrieval Control: All compared LLMs operate in closed-book mode without any Retrieval-Augmented Generation (RAG) mechanisms. Results are obtained without external knowledge intervention to purely evaluate the internalized parameterized knowledge and domain adaptation achieved through progressive fine-tuning. Knowledge Retrieval Control: All compared LLMs operate in closed-book mode without any Retrieval-Augmented Generation (RAG) mechanisms. Results are obtained without external knowledge intervention to purely evaluate the internalized parameterized knowledge and domain adaptation achieved through progressive fine-tuning. Prompt Strategy Consistency: All models are evaluated in a Zero-shot setting. The use of Few-shot examples is strictly prohibited to eliminate potential bias from manually selected seed samples, ensuring the results reflect the model’s native understanding of domain instructions. Prompt Strategy Consistency: All models are evaluated in a Zero-shot setting. The use of Few-shot examples is strictly prohibited to eliminate potential bias from manually selected seed samples, ensuring the results reflect the model’s native understanding of domain instructions. Standardized Prompt Templates: A unified prompt template is used across all models, encompassing consistent task instructions, background context, and output constraints. Only minimal format adaptations (e.g., conversation format conversion) are made for specific model interfaces, without altering the semantic content of the prompts. Standardized Prompt Templates: A unified prompt template is used across all models, encompassing consistent task instructions, background context, and output constraints. Only minimal format adaptations (e.g., conversation format conversion) are made for specific model interfaces, without altering the semantic content of the prompts. Decoding Parameters and Environment: Inference for all models uses a consistent generation configuration, with Temperature set to 0.7 to balance certainty and diversity. Additionally, the maximum generation length (Max tokens) is strictly limited, and uniform structural output constraints are applied. Decoding Parameters and Environment: Inference for all models uses a consistent generation configuration, with Temperature set to 0.7 to balance certainty and diversity. Additionally, the maximum generation length (Max tokens) is strictly limited, and uniform structural output constraints are applied. These rigorous controlled experimental settings maximize the elimination of external environmental variables, ensuring the validity of the comparative analysis between models of different scales and fine-tuning strategies (Table 5). Table 5Key Hyperparameter settings for LoRA fine-tuning.ParameterValueLearning rate2e-5Number of epochs7Batch size2Cutoff length4096LoRA rank8LoRA dropout0.05PISSA_ITER16LoRA target modulesq_proj, v_projLoRA alpha16OptimizerAdamWLearning rate scheduleCosine decay with 10% warmupMax gradient norm1.0FlashAttentionEnabled (FlashAttention-2)Sequence packingEnabled Key Hyperparameter settings for LoRA fine-tuning. Experimental validation of progressive fine-tuning strategies To evaluate the effectiveness of the proposed progressive fine-tuning strategy in adapting to WWTP safety management, we conducted a systematic evaluation of multiple fine-tuned models across four core tasks: laws and regulations understanding, accident case analysis, scenario reasoning, and professional knowledge question answering. The performance of these models was quantified using the scoring methodology defined in Sect. “Scoring”. As shown in Table 6, different fine-tuning strategies exhibit substantial differences in their impact on model performance. The base model Qwen2.5, without domain-specific fine-tuning, shows imbalanced performance across the four tasks. While its scenario analysis capability is relatively strong (score: 80.55), its accident case understanding performance is comparatively weak (score: 60.80), resulting in an overall score of 72.07. This outcome reflects the inherent limitations of general-purpose LLMs in domain-specific knowledge comprehension and task adaptation. After four-stage overall fine-tuning, the Qwen2.5** model achieves notable performance improvements across all four tasks. In particular, its score on the knowledge question–answer task reaches 92.23, with the overall score increasing to 88.65. This indicates that fine-tuning can effectively enhance the model’s generalization ability and knowledge integration across multiple tasks. However, the four-stage overall fine-tuning strategy does not fully resolve inter-task adaptability differences or achieve sufficient depth of knowledge integration. In contrast, the SafeFlow model proposed in this study, which adopts the progressive fine-tuning strategy, demonstrates superior performance across all tasks. Notably, it achieves high scores of 91.24, 94.29, and 95.47 on the laws and regulations understanding, scenario analysis, and knowledge question–answer tasks, respectively, with an overall score of 91.30. This overall Score provides a balanced integration of rigorous human oversight for professional compliance and the capacity of automated metrics to capture semantic consistency. It objectively demonstrates that the progressive fine-tuning strategy, by injecting domain knowledge in a stage-wise manner, effectively alleviates the knowledge conflicts inherent in full-parameter fine-tuning. Consequently, this approach significantly enhances the model’s depth of knowledge understanding within the specialized domain of wastewater treatment plant safety management. Table 6Performance comparison of different fine-tuning strategies.ModelScore (legal and regulatory)Score (accident cases)Score (scenario analysis)Score (knowledge question answering)MeanQwen2.575.2560.8080.5571.6772.07Qwen2.5**89.6182.2190.5692.2388.65SafeFlow (ours) 91.24 84.23 94.29 95.47 91.30 Performance comparison of different fine-tuning strategies. To further evaluate the efficacy of the progressive fine-tuning strategy in mitigating knowledge conflicts and catastrophic forgetting, this study analyzed the model’s performance persistence across historical tasks at each stage. Using Qwen2.5 as the baseline, the retention ratio is defined as the score of SafeFlow at a specific stage relative to the baseline score. As illustrated in Fig. 5, a retention ratio exceeding 1 indicates that the model’s current iteration outperforms the baseline on the corresponding historical task. Retention ratio of the SafeFlow model on historical tasks across progressive fine-tuning stages. The overall trend reveals that from SafeFlow-1 S to SafeFlow-4 S, the retention ratios for laws and regulations, accident cases, scenario analysis, and knowledge Q&A consistently remain above unity. This underscores that progressive fine-tuning avoids substantial performance degradation on historical tasks. Furthermore, with the exception of minor fluctuations, most curves exhibit monotonic stability throughout the stages without any precipitous declines. These results suggest that the proposed progressive knowledge injection and experience replay mechanisms effectively alleviate knowledge conflicts and catastrophic forgetting during the joint training of heterogeneous data, thereby tempering the overwriting effect of subsequent training on previously acquired knowledge. Notably, performance on the accident case task did not exhibit a linear decay in later stages but instead showed localized gains. This phenomenon is attributed to the presence of overlapping samples within the Phase 4 knowledge Q&A dataset, alongside semantic intersections with the scenario analysis datasets across different stages. Consequently, the proficiency in accident case analysis in later stages does not rely solely on “memory retention” but is bolstered by cross-stage knowledge reinforcement. The upward trajectory of this curve is more accurately interpreted as a reinforcement effect stemming from knowledge revisiting rather than isolated historical retention. Thus, Fig. 5 primarily demonstrates that, facilitated by cross-stage knowledge correlations, the proposed method robustly preserves and extends previous task capabilities, confirming that the model is resilient to catastrophic forgetting. Further analysis of the progressive fine-tuning strategy (as shown in Table 7), reveals that model capabilities exhibit characteristics of stage-wise enhancement and localized dynamic adjustment. In the first stage of progressive fine-tuning (SafeFlow-1 S), the model’s performance on the laws and regulations task increases substantially to 93.24, while improvements on the other three tasks remain limited, resulting in an overall score of 78.01. This indicates that fine-tuning at this stage primarily strengthens the model’s ability to understand structured legal texts, with this improvement not yet being effectively transferred to other task types. As training progresses, the second stage (SafeFlow-2 S) shows a marked improvement on the accident case task, with the score rising sharply to 85.54, and the overall score increasing to 84.25. This suggests that the gradual introduction of heterogeneous task data helps the model progressively expand its semantic understanding and reasoning boundaries. In the third stage (SafeFlow-3 S), the model reaches a peak performance of 95.74 on the scenario analysis task, while experiencing slight declines on the laws and regulations and accident case tasks. This phenomenon reflects potential knowledge interference or forgetting effects during multi-stage training. Nevertheless, the overall performance (score: 86.63) remains higher than that of the previous stage, indicating continued improvement in the model’s holistic semantic modeling and task coordination capabilities. Finally, in the fourth stage (SafeFlow-4 S), the model achieves consistently high and well-balanced performance across all four tasks, particularly attaining a score of 95.47 on the knowledge question–answer task, with an overall score of 91.30, which is clearly superior to both the four-stage overall fine-tuning baseline and the base model. Although slight declines are observed on individual tasks relative to their respective stage-specific peaks, the overall performance gains demonstrate that progressive fine-tuning can effectively guide the model toward more coordinated capability allocation and deeper knowledge integration across diverse professional tasks. Table 7Stage-wise performance of progressive fine-tuning.ModelScore (legal and regulatory)Score (accident cases)Score (scenario analysis)Score (knowledge question answering)MeanQwen2.575.2560.8080.5571.6772.07SafeFlow-1 S 93.24 61.2082.2075.4178.01SafeFlow-2 S92.12 85.54 83.1576.2084.25SafeFlow-3 S91.3283.37 95.74 76.1086.63SafeFlow-4 S91.2484.2394.29 95.47 91.30 Stage-wise performance of progressive fine-tuning. To evaluate the model’s performance in HCLF operational scenarios, a specialized analysis was conducted on eight representative risk patterns within wastewater treatment plant (WWTP) operations. These scenarios involve rare fault types characterized by severe class imbalance, yet they command the highest priority in safety management. Given the inherent long-tail distribution of industrial failure events, Recall was selected as the primary metric to quantify the model’s sensitivity in capturing these critical anomalies. As illustrated in Fig. 6, SafeFlow-4 S consistently outperformed the Qwen2.5 baseline across all evaluated dimensions, including toxic shock, aeration failure, sludge bulking, sensor drift, chemical overdose, influent surge, anoxic collapse, and toxic inflow. The absolute Recall enhancement per scenario ranged from 0.08 to 0.32, indicating that domain-specific progressive fine-tuning significantly augmented the model’s sensitivity to rare operational perturbations. Notably, the gains in toxic shock and sensor drift were particularly substantial, demonstrating the proposed method’s superior capability in identifying sparse yet safety-critical events. From the perspective of HCLF scenario detection, these results provide robust evidence that the progressive knowledge injection effectively rectifies catastrophic forgetting while fortifying domain-specific safety awareness. Model recall rates across HCLF operational scenarios. Figure 7 provides a clear visualization of the evolutionary trajectory of model capabilities across different domains, from the base model to the final-stage model.The left panel compares models trained using the multi-task fine-tuning strategy. After a single round of fine-tuning, the model exhibits performance improvements across all four key domains—laws and regulations, accident cases, scenario analysis, and knowledge question answering—indicating that four-stage overall fine-tuning enables simultaneous capability enhancement across multiple tasks and improves the model’s adaptability across domains.The right panel illustrates the progression of model capabilities across successive stages under the progressive fine-tuning strategy. As shown in Fig. 7, model performance demonstrates a continuous upward trend as fine-tuning advances through stages. By the fourth stage, the model’s overall capabilities across all four domains clearly surpass those of the multi-task fine-tuned model, validating the advantage of the progressive fine-tuning strategy in enhancing model performance and providing important empirical evidence and theoretical guidance for fine-tuning LLMs in the field of WWTP safety managemen. Comparison of domain-specific capabilities across different model stages. The left panel shows the performance comparison of models trained with the multi-task fine-tuning strategy, while the right panel illustrates the capability growth of models across successive stages under the progressive fine-tuning strategy. Performance comparison across LLMs with different parameter scales To further systematically validate the performance advantages of the proposed progressive fine-tuning strategy across models with different parameter scales, this study conducts a comparative performance evaluation between SafeFlow, which adopts the progressive fine-tuning strategy, and a set of general-purpose LLMs with different architectures and parameter sizes. The parameter scales of the compared models are listed in Table 8. Each experiment was conducted 10 times on the dataset described in Sect. “Dataset engineering”, with the inference temperature hyperparameter set to 0.7. Table 8Parameter scales of the compared LLMs.ModelQwen2.5-14BQwen2.5-32BQwen3-32BQwen-MaxDeepSeek-V3Qwen2.5**SafeFlowParameter Scale14B32B32B> 1T671B14B14B Parameter scales of the compared LLMs. As shown in Table 9, the experimental results indicate that among general-purpose models of the same category, model performance exhibits a clear positive correlation with parameter scale: as the number of parameters increases, the overall scores of the models show a steady upward trend. Taking DeepSeek-V3 and Qwen-Max as examples, these large-parameter general-purpose models achieve strong performance in this domain, with average scores of 85.75 and 87.91, respectively. This reflects the robust foundational capabilities and task generalization ability endowed by large-scale pre-training. However, these results also indicate that relying solely on increasing model scale to improve performance in a specific domain may yield diminishing marginal returns and encounter a performance ceiling. In contrast, models fine-tuned using the progressive fine-tuning strategy demonstrate a clear advantage. In this study, the fine-tuned SafeFlow model, despite having a significantly smaller parameter scale than large general-purpose models such as DeepSeek-V3 and Qwen-Max, outperforms these larger models in the target domain. These findings clearly demonstrate that high-quality dataset engineering can compensate for, and even surpass, disparities in model scale. When combined with the progressive fine-tuning strategy, which incrementally and finely optimizes the model, this approach enables more effective adaptation to domain-specific tasks and achieves superior performance. Table 9Performance comparison of LLMs with different parameter scales (10 runs).ModelScore ofRun 1Score ofRun 2Score ofRun 3Score ofRun 4Score ofRun 5Score ofRun 6Score ofRun 7Score ofRun 8Score ofRun 9Score ofRun 10MeanQwen2.5-14B74.4670.3969.7573.6474.5275.6868.2270.9570.6872.4172.07Qwen2.5-32B75.8180.0476.3276.9280.2880.3377.8176.5779.5280.1078.37Qwen3-32B74.4374.1970.0569.8072.5373.7373.6675.0070.6676.5573.06Qwen-Max84.9891.8386.4984.5291.7584.1591.1591.0584.5388.6587.91DeepSeek-V387.9385.3287.8986.3983.5288.1484.2784.0785.4784.5085.75Qwen2.5**92.1490.1686.2988.3888.1287.7992.6388.3187.5085.1888.65 SafeFlow 88.0893.2587.5595.2693.1387.7892.6294.7592.0288.5691.3 Performance comparison of LLMs with different parameter scales (10 runs). Conclusion Built upon dataset engineering, this study employs a stage-wise training mechanism to progressively deepen the model’s domain-specific cognition in WWTP safety management. Through sequential fine-tuning across laws and regulations, scenario analysis, accident cases, and knowledge question answering, the model incrementally acquires core knowledge from four key domains. After deployment and continuous optimization, the results demonstrate that the proposed progressive fine-tuning strategy achieves significant performance gains in the field of WWTP safety management. Compared with traditional fine-tuning approaches, the progressive fine-tuning strategy effectively alleviates knowledge conflicts arising from parallel multi-task training through stage-wise knowledge injection, thereby enhancing the depth of domain knowledge understanding and cross-task coordination capability. Moreover, even when compared with general-purpose models of much larger parameter scales, the progressively fine-tuned model exhibits superior performance in domain-specific evaluations of WWTP safety management. This indicates that the proposed approach can achieve more efficient domain adaptation under limited parameter budgets. Overall, this study provides an effective pathway for constructing high-performance and highly reliable domain-specific LLMs in resource-constrained scenarios. Despite the encouraging progress achieved in this study, several directions remain worthy of further exploration. At the data level, future work may move beyond the current reliance on static text-based knowledge representations by progressively integrating multimodal information such as real-time sensor data, process images, and video surveillance, thereby constructing a dynamically evolving domain knowledge system. At the training mechanism level, more adaptive fine-tuning strategies can be explored to enhance knowledge absorption efficiency and long-term memory stability across different training stages. In terms of practical deployment, future research will focus on deeply integrating the proposed approach with intelligent water management platforms in WWTPs to develop dynamic risk management systems for real-world applications. In addition, the proposed framework is expected to be extended to broader high-reliability industrial domains such as environmental monitoring, emergency management, and energy safety, providing sustainable and reusable technical support for intelligent industrial transformation. Author contributions Lina Tang: Conceptualization, Methodology, Data curation, Formal analysis, Writing – original draft, Visualization **. Ziyi Bian: Methodology, Data curation, Software, Formal analysis, Writing – original draft. Kai Liu: Methodology, Software, Validation, Formal analysis, Writing – review & editing. Zhiyao Zhao: Data curation, Investigation, Visualization. Jiping Xu: Supervision, Project administration, Funding acquisition, Methodology, Writing - review & editing. Xiaoyi Wang : Conceptualization, Data curation, Investigation, Validation, Supervision. Jiabin Yu: Methodology, Software, Formal analysis, Investigation, Validation, Supervision, Writing – original draft. Funding This research was funded by the National Natural Science Foundation of China (62402020 and 62303022), the Beijing Nova Program (20240484720), Research and application of unmanned water plant operation management and control system based on artificial intelligence. Data availability Data will be made available on request. Declarations Competing interests The authors declare no competing interests. Footnotes Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Contributor Information Xiaoyi Wang, Email: wangxiaoyi@ccmusic.edu.cn. Jiabin Yu, Email: yujiabin@th.btbu.edu.cn. References Associated Data Data Availability Statement Data will be made available on request.