Abstract:
Objectives To address the challenges in traditional fault diagnosis of marine diesel engines, such as high domain knowledge barriers, long algorithm development cycles, and data privacy concerns, this paper proposes an intelligent fault diagnosis framework for marine diesel engines based on large language models (LLMs). Methods Using Qwen3.5-Plus as the core model, a three-stage framework is constructed: structured prompt construction, diagnostic task code generation, and closed-loop iterative optimization. Through modules such as role anchoring and context sensing, the framework organizes diagnostic task prompts for marine diesel engines and leverages the large language model to automatically map diagnostic requirements into executable Python code. Furthermore, by incorporating a code error feedback channel and a performance optimization feedback channel, the diagnostic code is corrected and improved. Results Experiments are conducted on the lubrication oil system of an 8V396 diesel engine, generating a total of 305 lines of diagnostic code. The effective code rate reaches 67.54%, the average cyclomatic complexity is 2.56, and the domain component coverage achieves 100%. After closed-loop optimization, model convergence stability and classification performance are further enhanced, with a significant reduction in misjudgment. Conclusions The proposed method effectively establishes a diagnostic pipeline from knowledge to task, to code, and to optimization. It lowers the development barrier, improves code quality and diagnostic automation, offering a secure, efficient, and iterative new pathway for marine diesel engine fault diagnosis.