Aiming at the complex operating conditions,high maintenance costs,and harsh working environment of long-distance pipelines faced by centrifugal compressors,a fault warning method for centrifugal compressors based on attention mechanism(AM)and butterfly algorithm optimized bidirectional short-term and short-term memory neural network(XBOA-Bi-LSTM)was proposed.Firstly,in response to the problems of slow convergence speed,single conversion probability,and easy falling into local optima in traditional butterfly algorithms,infinite folding iterative aliasing mapping was introduced to enrich the initial population of butterfly algorithms.At the same time,an adaptive inertia conversion probability based on population dispersion and iteration number was proposed to improve the optimization ability of the butterfly algorithm.Then,the grey correlation analysis method was used to extract features from the measurement point data,and the grey correlation coefficient was assigned to the input sequence using attention mechanism.Finally,a bidirectional long-term and short-term memory neural network fault warning model was established,and the fault warning of centrifugal compressors was completed through simulation experiments.The feasibility of the fault warning method for a centrifugal compressor in a long-distance natural gas pipeline unit was verified using the centrifugal compressor as the simulation object.The experiment results prove that when using the attention mechanism and XBOA-Bi-LSTM based centrifugal compressor fault warning method,a warning signal is issued within 2 h~3 h before the centrifugal compressor fault occurred,achieving fault warning for abnormal pressure difference of the inlet filter and abnormal operation of the support bearing of the centrifugal compressor.