Accurately predicting river water levels is crucial for managing water resources and controlling floods. In this study, we propose a water level prediction model based on a deep learning method (Transformer model) to improve the accuracy and efficiency of predicting inland river water levels. Water level data from seven hydrological stations were collected from the downstream area of the Three Gorges Reservoir, which confirmed the effectiveness of the model. the proposed model was improved by three main algorithms: the wavelet thresholding denoising (WTD) algorithm, the maximum information coefficient (MIC) algorithm, and the linear exponential (LIMEX) loss function. We are dedicated to improving the accuracy of predicting peak water levels during flood seasons. The results show that the proposed MIC-TF-LINEX model has achieved superior performance in predicting water levels compared to other models, such as traditional Transformer, Back Propagation (BP) Neural Network, and Bi-directional Long Short Term Memory (BILSTM). Furthermore, extending the forecast period will also affect the accuracy of the water level forecasting model. When the prediction duration is 8 hours, the R2 value is 0.9989, the MAE is 0.1020, the MSE is 0.0166, and the MAPE is 0.0060. When the prediction timeframe is within 56 hours, the MSE of the prediction result is still less than 0.1 meters. This study provides a highly accurate and well-suited method for predicting floods.