BackgroundElectrocardiogram (ECG) is a powerful tool for studying cardiac activity and diagnosing various cardiovascular diseases, including arrhythmia. While machine learning and deep learning algorithms have been applied to ECG interpretation, there is still room for improvement. For instance, the commonly used Recurrent Neural Networks (RNNs), reply on its previous state to update and is therefore ineffective for parallel computing. RNN also struggles to efficiently address the issue of long‐distance reliance.PurposeTo reduce computational complexity by dimensionality reduction of ECG signals we constructed a Stacked Auto‐encoders model using Transformer for ECG‐based arrhythmia detection. And overcome the challenges of long‐term dependencies and limited parallelizability in traditional RNNs when applied to ECG signal processing.MethodsIn this paper, a Transformer‐Based ECG Dimensionality Reduction Stacked Auto‐encoders model is proposed for ECG‐based arrhythmia detection. The transformer is used to encode ECG signals into a feature matrix, which is then dimensionally reduced using unsupervised greedy training through the four linear layers. This resulted in a low‐dimensional representation of ECG features, which are subsequently classified using support vector machines (SVM) to minimize overfitting.ResultsThe proposed method is benchmarked on the MIT‐BIH Arrhythmia database. In the 10‐fold cross validation of beat‐based arrhythmia detection, the average accuracy, sensitivity, specificity and F1 score of the proposed method are 99.83%, 98.84%, 99.84% and 99.13%, respectively, for the record‐based arrhythmia detection which refers to the approach where the training and testing sets use ECG data from independent recorded patients are 88.10%, 49.79%, 91.56% and 39.95%, respectively.ConclusionsCompared to other existing ECG‐based arrhythmia detection methods, our proposed approach exhibits improved detection accuracy and stronger generalization for arrhythmia beats. Additionally, the use of the record‐based data division method makes our approach more suitable for clinical practice.