Shale oil has become a crucial unconventional resource, bolstering energy supply security, and it is important to accurately predict shale oil production dynamics. However, traditional prediction methods are faced with the challenges of large data fluctuations and numerous interference factors, which make accurate prediction difficult. This paper introduces a deep learning approach, specifically a physical constraint-based convolutional neural network combined with long short-term memory and attention mechanism (CNN-LSTM-AM), to predict shale oil production dynamics. Initially, the correlation analysis method is used to analyze the correlation strengths of features with the prediction target, and the data that are most strongly correlated with the daily oil production are screened out and preprocessed. Key features are then extracted; that is, the CNN layer's output is fed into the LSTM layer, the output of which informs a fully connected layer for time-series production predictions. The model integrates an AM to concentrate on vital data aspects. In the “five-linear flow” formula, the imbibition is hard-coded into the shale oil production prediction model. Physical constraints are introduced into the model. Data driven and empirical formulas are used to introduce a loss function as a constraint condition in the training process of a machine learning model to improve the interpretability and predictive ability of the model. During the tuning phase, Bayesian optimization is used to fine-tune the model's hyperparameters. Shapley additive explanation and accumulated local effects analyses are used to further assess and quantify the significance of the essential parameters, thus optimizing the prediction effectiveness.