Precisely estimating the carbonate’s porosity is essential for subsurface reservoir characterization. However, conventional methods for obtaining porosity using either core measurements or logging interpretation are expensive and inefficient. Considering the sequence data feature of logging curves and the booming development of intelligent networks in geoscience, this study proposes a reliable and low-cost intelligent Porosity Prediction Transformer (PPTransformer) framework for reservoir porosity prediction using logging curves as inputs. PPTransformer network not only extracts global features through convolutional layers but also captures local features using Encoders and self-attention mechanisms. This proposed network is a data-driven supervised learning framework with a superior accuracy and robustness. The testing results demonstrate that compared to the Transformer network, Long Short-Term time series network, and support vector machine method, the PPTransformer framework exhibits the highest average correlation coefficient and determination coefficient indicators and the lowest root mean square error and absolute error indicators. Moreover, adding stratigraphic lithology as geological constraints to the PPTransformer framework further improves the prediction performance. This indicates that geological constraints will enhance network performance.