SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.03312 · 2026

Escaping the BLEU Trap: A Signal-Grounded Framework with Decoupled Semantic Guidance for EEG-to-Text Decoding

Haonan Wang, Xiaomeng Li, Honglong Yang, Yuchen Wang, Yu Guo

arXiv · PDF

Code that ran

5 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2603.03312.json · badge: /api/ran/2603.03312.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
xmed-lab/SemKey community
Papers with Code archive
5 ran · 3 no recorded run
FunctionStatusWhere it lives
CrossAttention Ran
ran on a synthesized input
xmed-lab/SemKey/model/semkey_parallel.py
code served (permissive licence) · get_code("8ad54fe671ae56e3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

class CrossAttention(nn.MultiheadAttention):

    def __init__(self, hidden_dim, num_heads, dropout=0, bias=True, batch_first=True):
        super().__init__(hidden_dim, num_heads, dropout, bias, batch_first=batch_first)

    def forward(self, q, x, mask=None, need_weights=False) -> tuple:
        mask = ~mask.bool() if mask is not None else mask
        return super().forward(q, x, x, key_padding_mask=mask, need_weights=need_weights)


INIT_ARGS = {
    'hidden_dim': 4,
    'num_heads': 2,
    'dropout': 0.0,
    'bias': True,
    'batch_first': True,
}

ARGS = {
    'q': torch.randn(2, 3, 4),
    'x': torch.randn(2, 5, 4),
    'mask': torch.zeros(2, 5, dtype=torch.bool),
    'need_weights': False,
}

if __name__ == '__main__':
    model = CrossAttention(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output type: {type(output)}")
    print(f"Output length: {len(output)}")
    print(f"Attention output shape: {output[0].shape}")
    print(f"Attention weights: {output[1]}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
DecoderBlock Ran
ran on a synthesized input · constructed an object; no result was computed
xmed-lab/SemKey/model/semkey_parallel.py
code served (permissive licence) · get_code("de8c4bc7cfdac12a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, DecoderBlock: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from timm.models.vision_transformer import Mlp

torch.manual_seed(0)

# Define the DecoderBlock class and dependencies
class CrossAttention(nn.MultiheadAttention):

    def __init__(self, hidden_dim, num_heads, dropout=0, bias=True, batch_first=True):
        super().__init__(hidden_dim, num_heads, dropout, bias, batch_first=batch_first)

    def forward(self, q, x, mask=None, need_weights=False) -> tuple:
        mask = ~mask.bool() if mask is not None else mask
        return super().forward(q, x, x, key_padding_mask=mask, need_weights=need_weights)

class SelfAttention(nn.MultiheadAttention):

    def __init__(self, hidden_dim, num_heads, dropout=0, bias=True, batch_first=True, is_causal=False):
        super().__init__(hidden_dim, num_heads, dropout, bias, batch_first=batch_first)
        self.num_heads = num_heads
        self.is_causal = is_causal

    def forward(self, x, mask=None, need_weights=False):
        if self.is_causal and mask is None:
            B, L, D = x.shape
            mask_3d = torch.triu(torch.full((L, L), float('-inf'), dtype=x.dtype, device=x.device), diagonal=1).unsqueeze(0)
            mask_3d = mask_3d.expand(B * self.num_heads, -1, -1)
            return super().forward(x, x, x, attn_mask=mask_3d, is_causal=self.is_causal, need_weights=need_weights)[0]
        elif self.is_causal and mask is not None:
            raise NotImplementedError
        else:
            mask = ~mask.bool() if mask is not None else mask
            return super().forward(x, x, x, key_padding_mask=mask, need_weights=need_weights)[0]

class DecoderBlock(nn.Module):
    """
    A naive Transformer decoder block.
    """

    def __init__(self, dim, num_heads=8, mlp_ratio=4, dropout=0.0, is_causal=True):
        super().__init__()
        self.norm1 = nn.LayerNorm(dim, eps=1e-06, elementwise_affine=True)
        self.self_attn = SelfAttention(dim, num_heads, dropout, is_causal=is_causal)
        self.norm2 = nn.LayerNorm(dim, eps=1e-06, elementwise_affine=True)
        self.cross_attn = CrossAttention(dim, num_heads, dropout)
        self.norm3 = nn.LayerNorm(dim, eps=1e-06, elementwise_affine=True)
        self.mlp = Mlp(dim, dim * mlp_ratio, drop=dropout, act_layer=lambda: nn.GELU(approximate='tanh'))

    def forward(self, q, x, x_mask, need_weights=False) -> tuple:
        q = q + self.self_attn(self.norm1(q), need_weights=need_weights)
        attn_out, attn_weights = self.cross_attn(self.norm2(q), x, x_mask, need_weights=need_weights)
        q = q + attn_out
        q = q + self.mlp(self.norm3(q))
        return (q, attn_weights)

# Create test inputs
batch_size = 2
seq_len_q = 5
seq_len_x = 6
dim = 4
num_heads = 2

# q: (batch_size, seq_len_q, dim)
q = torch.randn(batch_size, seq_len_q, dim)

# x: (batch_size, seq_len_x, dim)
x = torch.randn(batch_size, seq_len_x, dim)

# x_mask: (batch_size, seq_len_x) - True for valid tokens, False for padding
x_mask = torch.ones(batch_size, seq_len_x, dtype=torch.bool)

ARGS = {
    "dim": dim,
    "num_heads": num_heads,
    "mlp_ratio": 4,
    "dropout": 0.0,
    "is_causal": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
lightning, timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DecoderBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a DecoderBlock output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
EncoderBlock Ran
ran on a synthesized input · constructed an object; no result was computed
xmed-lab/SemKey/model/semkey_parallel.py
code served (permissive licence) · get_code("e34125eeae114501")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, EncoderBlock: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from timm.models.vision_transformer import Mlp

torch.manual_seed(0)

ARGS = {
    "hidden_dim": 4,
    "hidden_len": 3,
    "inject_prompt": True,
    "temporal_modulate": True,
    "is_causal": False,
    "num_heads": 2,
    "mlp_ratio": 4,
    "dropout": 0.0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
lightning, timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EncoderBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a EncoderBlock output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
PromptEmbedder Ran
ran on a synthesized input · constructed an object; no result was computed
xmed-lab/SemKey/model/semkey_parallel.py
code served (permissive licence) · get_code("6f649c4b108bef2c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, PromptEmbedder: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Define prompt_keys dictionary with matching structure
prompt_keys = {
    'task': ['task_a', 'task_b', 'task_c'],
    'dataset': ['ds_x', 'ds_y', 'ds_z'],
    'subject': ['subj_1', 'subj_2', 'subj_3', 'subj_4', 'subj_5', 'subj_6', 'subj_7', 'subj_8', 'subj_9', 'subj_10', 'subj_11', 'subj_12', 'subj_13', 'subj_14', 'subj_15', 'subj_16', 'subj_17', 'subj_18', 'subj_19', 'subj_20', 'subj_21', 'subj_22', 'subj_23', 'subj_24', 'subj_25', 'subj_26', 'subj_27', 'subj_28', 'subj_29', 'subj_30', 'subj_31']
}

ARGS = {
    'dim': 4,
    'prompt_nums': (3, 3, 31),
    'drop_probs': (0.0, 0.0, 0.0),
    'prompt_keys': prompt_keys
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PromptEmbedder — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a PromptEmbedder output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
SelfAttention Ran
ran on a synthesized input · constructed an object; no result was computed
xmed-lab/SemKey/model/semkey_parallel.py
code served (permissive licence) · get_code("5fb31b7fb7dcea79")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, SelfAttention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal input tensor
# Shape: (batch_size=2, seq_len=3, hidden_dim=4)
x = torch.randn(2, 3, 4)

# Create a mask tensor if needed
# Shape: (batch_size=2, seq_len=3) for key_padding_mask
mask = torch.zeros(2, 3, dtype=torch.bool)

ARGS = {
    "hidden_dim": 4,
    "num_heads": 2,
    "dropout": 0.0,
    "bias": True,
    "batch_first": True,
    "is_causal": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
lightning, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SelfAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SelfAttention output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Aligner Not yet run
unverified (harvested, no recorded run)
xmed-lab/SemKey/model/semkey_parallel.py
code served (permissive licence) · get_code("789de8cfd69b6cbb")
How it ran

no invocation recorded.

EEGEncoder Not yet run
unverified (harvested, no recorded run)
xmed-lab/SemKey/model/semkey_parallel.py
code served (permissive licence) · get_code("0258bdc17f614574")
How it ran

no invocation recorded.

SEMKEY_PARALLEL Not yet run
unverified (harvested, no recorded run)
xmed-lab/SemKey/model/semkey_parallel.py
code served (permissive licence) · get_code("0cbabfd1dc7f08d2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Decoding natural language from non-invasive EEG signals is a promising yet challenging task. However, current state-of-the-art models remain constrained by three fundamental issues: Semantic Bias, where outputs collapse into generic linguistic templates; Signal Neglect, where models rely heavily on LLM priors to hallucinate fluent text even in the absence of meaningful signals; and the "BLEU Trap", where high-frequency stopwords inflate n-gram metrics, masking a lack of true semantic fidelity. To resolve these challenges, we move beyond conventional end-to-end pipelines and propose SEMKEY, a novel multi-stage framework that enforces signal-grounded generation through four decoupled semantic objectives: sentiment, topic, length, and surprisal. We extract these semantic anchors from EEG embeddings directly, then unify them with an Active Retrieval Decoding mechanism, compelling the LLM to ground its token generation in the neural signals rather than defaulting to linguistic priors. Furthermore, we break the BLEU Trap by establishing a comprehensive evaluation protocol using rigorous retrieval and distribution-based metrics such as Fréchet Distance. Extensive experiments demonstrate that SEMKEY effectively mitigates hallucinations on noise inputs and achieves SOTA performance on these robust protocols. Code will be released upon acceptance at https://github.com/xmed-lab/SemKey.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2603.03312")
get_code_for_paper("2603.03312")
have("2603.03312")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2603.03312.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2603.03312.svg)](https://syntology.ai/paper/2603.03312)

Connect an agent — have() is free.