Manuscript Offprint

arXiv:2610.20766

Semantic Alignment of EEG and Text: A Contrastive Learning Framework for Decoding Imagined Speech

Shahryar G. Namdari, Francesco Iacomi, Riccardo Barbieri, Luca Mainardi

Shahryar G. Namdari*, Francesco Iacomi*, Riccardo Barbieri, Senior Member, IEEE, and Luca Mainardi, Member, IEEE

Abstract—Imagined speech decoding from EEG is a promising route toward naturalistic brain–computer interfaces. Traditional closed-set classifiers treat semantic categories as independent labels and therefore do not explicitly exploit the relationships among possible linguistic intents, limiting the flexibility of their output representation.

We adapt a multimodal contrastive learning framework to the imagined-speech setting, aligning EEG trials with language representations by mapping EEG into the embedding space of a frozen pretrained text encoder. An EEG encoder is trained with a composite objective that combines semantically reweighted EEG–sentence alignment with text-prototype-based class discrimination, encouraging semantically structured representations while preserving separability among the 39 intent categories.

We evaluate the approach on the Chisco imagined speech dataset with 39 semantic categories across multiple subjects, reporting Top-k accuracy, macro-F1, and balanced pairwise matching accuracy (2v2). We additionally examine whether maximum EEG-text cosine similarity provides an intrinsic indicator of decoding reliability and probe semantic structure beyond the original category labels using evaluation-time semantic axes and a qualitative Semantic Gallery Probe (SGP) with previously unseen candidate sentences. The contrastive framework achieved conventional decoding performance comparable to the task-optimized closed-set classifier while mapping EEG into a frozen language embedding space. MaxCosine consistently identified subsets of held-out trials with higher Top-1 and Top-5 accuracy across subjects, evaluation-time semantic axes showed mean agreement above the 50% chance reference across all five examined dimensions, and the SGP qualitatively illustrated direct comparison with previously unseen candidate sentences. Together, these findings show that EEG-language alignment can retain comparable fixed-intent decoding while enabling similarity-based retrieval, intrinsic reliability ranking, and evaluation of broader semantic structure.

  • These authors equally contribute to this work.

Shahryar G. Namdari is with the Department of Electronics, Information and Bioengineering, Politecnico di Milano, Milano, 20133, Italy (e-mail: shahryar.namdari@mail.polimi.it).

Francesco Iacomi is with the Department of Electronics, Information and Bioengineering, Politecnico di Milano, Milano, 20133, Italy (e-mail: francesco.iacomi@polimi.it).

Riccardo Barbieri is with the Department of Electronics, Information and Bioengineering, Politecnico di Milano, Milano, 20133, Italy (e-mail: riccardo.barbieri@polimi.it).

Luca Mainardi is with the Department of Electronics, Information and Bioengineering, Politecnico di Milano, Milano, 20133, Italy (e-mail: luca.mainardi@polimi.it).

Index Terms—Imagined Speech, EEG, Contrastive Learning, Semantic Alignment, Language Embeddings

I. INTRODUCTION

Brain–Computer Interfaces (BCIs) aim to establish a direct communication channel between the human brain and external devices [1]. Beyond motor imagery and P300 paradigms, recent work has increasingly explored decoding of imagined speech, the internal articulation of words without vocalization, as a more natural communication pathway, particularly for individuals with severe motor impairments that limit reliable speech output such as Amyotrophic Lateral Sclerosis (ALS) and locked-in syndrome [2], [3].

Despite this promise, imagined-speech EEG decoding is still predominantly formulated as a closed-set classification problem, in which semantic categories are treated as independent labels [4]. Such classifiers are effective for fixed-vocabulary intent recognition, but their output representation does not explicitly encode relationships among semantically related intents. A representation aligned with language space offers a complementary objective: preserving discriminability among known categories while organizing EEG trials according to the semantic structure of their linguistic targets.

The recent release of the Chinese Imagined Speech Corpus (Chisco) [5], with 39 semantic categories and multiple subjects, enables learning objectives that go beyond rigid classification of a limited set of words.

In this work, we investigate contrastive EEG–language alignment as an alternative representation for imagined-speech decoding. The proposed framework maps single-trial EEG into the embedding space of a frozen pretrained language model and is trained using a composite objective that combines semantically reweighted EEG–sentence alignment with text-prototype-based class discrimination. This design aims to preserve discriminability among the 39 Chisco intent categories while organizing EEG representations within a structured linguistic space.

The study addresses three complementary questions. First, we test whether semantic alignment can retain conventional decoding performance relative to a task-optimized closed-set classifier, using Top-k accuracy, macro-F1, and balanced pairwise matching accuracy (2v2). Second, we investigate whether the maximum cosine similarity between an EEG embedding and the text-derived category prototypes, already computed during category prediction, can serve as an indicator of prediction reliability and support selective decoding without requiring a separate confidence model. Third, we investigate whether the learned EEG representations exhibit semantic structure beyond the original 39 categories by measuring their agreement with text embeddings along five predefined bipolar semantic dimensions (e.g., practical versus social/emotional), introduced only during evaluation. We also use the Semantic Gallery Probe (SGP) to qualitatively examine their similarity to previously unseen candidate sentences. Together, these analyses evaluate not only whether the intended category can be recovered, but also what additional structure becomes available when imagined-speech EEG is represented directly in language space.

References (45)

  • Brain-computer interfaces for communication and control
  • Brain-computer communication: Unlocking the locked in
  • Brain-computer interfaces for communication and rehabilitation
  • A state-of-the-art review of EEG-based imagined speech decoding
  • Chisco: An EEG-based BCI dataset for decoding of imagined speech
  • EEG-CLIP: Learning EEG representations from natural language descriptions
  • Assembling the mind’s mosaic: Towards EEG semantic intent decoding
  • Toward a universal decoder of linguistic meaning from brain activation
  • Semantic reconstruction of continuous language from non-invasive brain recordings
  • Generative language reconstruction from brain recordings
  • ZuCo, a simultaneous EEG and eye-tracking resource for natural sentence reading
  • ZuCo 2.0: A dataset of physiological recordings during natural reading and annotation
  • DeWave: Discrete encoding of EEG waves for EEG to text translation
  • Open vocabulary electroencephalography-to-text decoding and zero-shot sentiment classification
  • Decoding text from electroencephalography signals: A novel hierarchical gated recurrent unit with masked residual attention mechanism
  • A cross-species neural foundation model for end-to-end speech decoding
  • Learning Transferable Visual Models From Natural Language Supervision
  • Scaling up visual and vision-language representation learning with noisy text supervision
  • Towards decoding individual words from non-invasive brain recordings
  • Contrastive representation learning with transformers for robust auditory EEG decoding
  • Representational similarity analysis—connecting the branches of systems neuroscience
  • The utility metric: A novel method to assess the overall performance of discrete brain-computer interfaces
  • BCI-utility metric for asynchronous P300 brain-computer interface systems
  • The PREP pipeline: standardized preprocessing for large-scale EEG analysis
  • Autoreject: Automated artifact rejection for MEG and EEG data
  • ICLabel: An automated electroencephalographic independent component classifier, dataset, and website
  • Overcoming catastrophic forgetting in neural networks
  • Recall and learn: Fine-tuning deep pretrained language models with less forgetting
  • Episodic memory in lifelong language learning
  • C-Pack: Packed resources for general chinese embeddings
  • Multilingual E5 text embeddings: A technical report
  • Sentence-BERT: Sentence embeddings using siamese BERT-networks
  • MPNet: Masked and permuted pre-training for language understanding
  • XGBoost: A scalable tree boosting system
  • EEGNet: a compact convolutional neural network for EEG-based brain–computer interfaces
  • Attention is all you need
  • Representation learning with contrastive predictive coding
  • Class-balanced loss based on effective number of samples
  • Rethinking the inception architecture for computer vision
  • Predicting human brain activity associated with the meanings of nouns
  • Tracking neural coding of perceptual and semantic features of concrete nouns
  • Using EEG to decode semantics during an artificial language learning task
  • Adam: A Method for Stochastic Optimization
  • Non-invasive brain–computer interfaces: State of the art and trends
  • An EEG-based asynchronous MI-BCI system to reduce false positives with a small number of channels for neurorehabilitation: A pilot study