Porosity, as a key parameter to describe the properties of rock reservoirs, is essential for evaluating the permeability and fluid migration performance of underground rocks. In order to overcome the limitations of traditional logging porosity interpretation methods in the face of geological complexity and nonlinear relationships, this study introduces a CNN (convolutional neural network)-transformer model, which aims to improve the accuracy and generalization ability of logging porosity prediction. CNNs have excellent spatial feature capture capabilities. The convolution operation of CNNs can effectively learn the mapping relationship of local features, so as to better capture the local correlation in the well log. Transformer models are able to effectively capture complex sequence relationships between different depths or time points. This enables the model to better integrate information from different depths or times, and improve the porosity prediction accuracy. We trained the model on the well log dataset to ensure that it has good generalization ability. In addition, we comprehensively compare the performance of the CNN-transformer model with other traditional machine learning models to verify its superiority in logging porosity prediction. Through the analysis of experimental results, the CNN-transformer model shows good superiority in the task of logging porosity prediction. The introduction of this model will bring a new perspective to the development of logging technology and provide a more efficient and accurate tool for the field of geoscience.