In this study, we address the challenge of estimating the resonance frequency of a photoacoustic detector (PAD) gas cell under varying temperature conditions, which is crucial for improving the accuracy of gas concentration measurements. We introduce a novel approach that uses a long short-term memory network and a self-attention mechanism to model resonance frequency shifts based on temperature data. To investigate the impact of the gas mixture temperature on the resonance frequency, we modified the PAD to include an internal temperature sensor. Our experiments involved multiple heating and cooling cycles with varying methane concentrations, resulting in a comprehensive dataset of temperature and resonance frequency measurements. The proposed models were trained and validated on this dataset, and the results demonstrate real-time prediction capabilities with a mean absolute error of less than 1 Hz for frequency shifts exceeding 30 Hz over four-hour periods. This approach allows continuous, real-time tracking of the resonance frequency without interrupting the laser operation, significantly enhancing gas concentration measurements and contributing to the long-term stabilization of the sensor. The results suggest that the proposed approach is effective in managing temperature-induced frequency shifts, making it a valuable tool for improving the accuracy and stability of gas sensors in practical applications.