Strain measurements are vital in engineering trials, testing, and scientific research. In the process of signal acquisition, baseline drift has a significant impact on the accuracy and validity of data. Traditional solutions, such as discrete wavelet transform and empirical mode decomposition, cannot be used in real-time systems. To solve this problem, this paper proposes a Transformer-based model to eliminate the drift in the signal. A self-attentive mechanism is utilized in the encoder of the model to learn the interrelationships between the components of the input signal, and captures the key features. Then, the decoder generates a corrected signal. Meanwhile, a high-precision strain acquisition system is constructed. The experiments tested the model’s ability to remove drift from simulated voltage signals with and without Gaussian noise. The results demonstrated that the transformer model excels at eliminating signal baseline drift. Additionally, the performance of the model was investigated under different temperature conditions and with different levels of force applied by the electronic universal testing machine to produce strain. The experimental results indicate that the Transformer model can largely eliminate drift in dynamic signals l and has great potential for practical applications.