Quantization of Vision Transformer-Based Model for Real-Time EEG Classification

Rabindra Khadka, Poushali Sengupta, Pedro G. Lind, Anis YazidiCommunications 2025 · DOI · OpenAlex

Abstract

Electroencephalography (EEG) is a non-invasive and cost-effective tool for capturing brain signals. However, existing approaches based on deep learning models for classifying EEG signals are primarily trained on large EEG datasets and require extensive computational resources. This poses significant challenges for real-time processing, particularly in resource-constrained environments such as wearable devices and edge computing. Our work addresses these challenges by exploring quantization techniques to optimize a vision transformer model for real-time EEG classification. We apply post-training quantization to the proposed Vision Transformer (ViT) model, termed the Brain Signal Vision Transformer (BSVT), to reduce computational overhead while maintaining high performance. The BSVT model, trained on the ex3 HPC system, efficiently handles large datasets. We comprehensively analyze the trade-offs between model accuracy and computational efficiency. Specifically, we demonstrate the use of dynamic quantization on a ViT-based model for EEG classification, achieving a 2.49x reduction in model size and a 1.46x improvement in inference speed. These findings underscore the potential of quantization techniques and distributed computing to revolutionize the adoption of AI in healthcare.

Introduction: The Challenge of Edge-Based EEG Classification

Electroencephalography (EEG) is a standard, non-invasive method for monitoring brain activity and diagnosing neurological conditions. Recently, deep learning models—specifically Vision Transformers (ViTs)—have achieved state-of-the-art performance in classifying these complex EEG signals.

However, ViTs are typically massive, data-hungry, and computationally expensive. Current analysis workflows often require sending EEG data to centralized cloud servers, introducing latency and dependency on stable connectivity. For real-time, portable medical equipment or smart wearables, edge computing is essential. This research addresses the challenge of shrinking heavy transformer models for local execution on resource-constrained edge devices without sacrificing diagnostic accuracy.

Overview of the proposed pipeline for real-time EEG classification, from cloud training to edge deployment.

Methodology

The Brain Signal Vision Transformer (BSVT)

The core of this approach is the Brain Signal Vision Transformer (BSVT). Unlike standard ViTs designed for image processing, BSVT utilizes a "factorized convolution stem"—comprising a 2D convolution followed by a 1D convolution—to extract spatio-temporal features from raw EEG signals. These features are then converted into tokens for processing by a transformer encoder. To handle the computational demands of training on large datasets, the BSVT model was trained using the ex3 HPC system.

Detailed architecture of the Brain Signal Vision Transformer (BSVT) featuring a factorized convolutional stem and transformer encoder.

Dynamic Post-Training Quantization

To bridge the gap between heavy models and lightweight hardware, the authors apply Post-Training Quantization (PTQ). Specifically, dynamic PTQ is used to convert the model's weights from 32-bit floating-point (FP32) to 8-bit integers (INT8).

To maintain accuracy, quantization is applied selectively. Heavy fully connected (FC) layers are quantized to INT8, while highly sensitive operations—such as Softmax, Layer Normalization, and GELU activations—are preserved in FP32. Dynamic quantization determines scale factors for activations during runtime, eliminating the need for extensive retraining or parameter tuning.

Experimental Evaluation

Dataset and Preprocessing

The model was trained and evaluated on the Temple University Hospital (TUH) Abnormal EEG dataset v2.0.0, containing 2,993 recordings from 2,329 subjects. The data is binary-labeled as either normal (1,385 recordings) or abnormal (998 recordings). Preprocessing involved cropping recordings to 20 minutes, applying a 1–40 Hz bandpass filter, downsampling to 100 Hz, and segmenting the data into overlapping 5-second windows.

Performance Results

The quantized model was evaluated on a single-threaded CPU to simulate edge-like constraints. The results demonstrate significant efficiency gains with minimal performance loss:

  • Model Size: Reduced from 149.00 MB (FP32) to 59.72 MB (INT8), a 59% reduction (2.49x smaller).
  • Inference Speed: Validation set processing time dropped from 1487.41s to 1018.70s, a 47% increase in speed (1.46x faster).
  • Accuracy: Minimal degradation, with accuracy dropping from 81.0% to 79.3% and the F1 score moving from 0.79 to 0.77.

Discussion and Key Insights

This work demonstrates that transformer-based medical diagnostics can be effectively deployed on the edge. By employing selective quantization, the model retains its complex representational power while significantly reducing its memory footprint. Furthermore, the use of dynamic PTQ offers a practical, accessible method for optimizing pre-trained medical AI models without the complexity of Quantization-Aware Training (QAT).

Conclusion and Future Directions

While the results are promising, future work will explore even lower bit-width quantization and QAT to further optimize memory and latency. The ultimate goal remains the seamless integration of these advanced models into real-world, portable EEG monitoring devices.

Summary updated

Abstract

Abstract Electroencephalography (EEG) is a non-invasive and cost-effective tool for capturing brain signals. However, existing approaches based on deep learning models for classifying EEG signals are primarily trained on large EEG datasets and require extensive computational resources. This poses significant challenges for real-time processing, particularly in resource-constrained environments such as wearable devices and edge computing. Our work addresses these challenges by exploring quantization techniques to optimize a vision transformer model for real-time EEG classification. We apply post-training quantization to the proposed Vision Transformer (ViT) model, termed the Brain Signal Vision Transformer (BSVT), to reduce computational overhead while maintaining high performance. The BSVT model, trained on the ex3 HPC system, efficiently handles large datasets. We comprehensively analyze the trade-offs between model accuracy and computational efficiency. Specifically, we demonstrate the use of dynamic quantization on a ViT-based model for EEG classification, achieving a 2.49x reduction in model size and a 1.46x improvement in inference speed. These findings underscore the potential of quantization techniques and distributed computing to revolutionize the adoption of AI in healthcare.
BibTeX
@inproceedings{khadka2025quantization,
  author = {Rabindra Khadka and Poushali Sengupta and Pedro G. Lind and Anis Yazidi},
  title = {{Quantization of Vision Transformer-Based Model for Real-Time EEG Classification}},
  booktitle = {Communications},
  year = {2025},
  doi = {10.1007/978-3-031-86240-3\_2},
}
Figure