Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: bsd-3-clause
|
| 3 |
+
tags:
|
| 4 |
+
- meg
|
| 5 |
+
- brain-signals
|
| 6 |
+
- speech-detection
|
| 7 |
+
- conformer
|
| 8 |
+
- libribrain
|
| 9 |
+
datasets:
|
| 10 |
+
- pnpl/LibriBrain
|
| 11 |
+
metrics:
|
| 12 |
+
- f1
|
| 13 |
+
library_name: pytorch
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# MEGConformer for Speech Detection
|
| 17 |
+
|
| 18 |
+
Conformer-based MEG decoder for binary speech detection, trained with 10 different random seeds for reproducibility.
|
| 19 |
+
|
| 20 |
+
## Model Performance
|
| 21 |
+
|
| 22 |
+
| Seed | Val F1-Macro | Checkpoint |
|
| 23 |
+
|------|--------------|------------|
|
| 24 |
+
| 0 (best) | **87.06%** | `seed-0/pytorch_model.ckpt` |
|
| 25 |
+
| 6 | 86.80% | `seed-6/pytorch_model.ckpt` |
|
| 26 |
+
| 4 | 86.62% | `seed-4/pytorch_model.ckpt` |
|
| 27 |
+
| 1 | 86.54% | `seed-1/pytorch_model.ckpt` |
|
| 28 |
+
| 2 | 86.37% | `seed-2/pytorch_model.ckpt` |
|
| 29 |
+
| 5 | 86.29% | `seed-5/pytorch_model.ckpt` |
|
| 30 |
+
| 7 | 86.18% | `seed-7/pytorch_model.ckpt` |
|
| 31 |
+
| 3 | 86.13% | `seed-3/pytorch_model.ckpt` |
|
| 32 |
+
| 8 | 85.92% | `seed-8/pytorch_model.ckpt` |
|
| 33 |
+
| 9 | 85.18% | `seed-9/pytorch_model.ckpt` |
|
| 34 |
+
|
| 35 |
+
- **Holdout score of seed 0:** 88.90%
|
| 36 |
+
|
| 37 |
+
## Quick Start
|
| 38 |
+
|
| 39 |
+
### Load Best Model
|
| 40 |
+
```python
|
| 41 |
+
import torch
|
| 42 |
+
from huggingface_hub import hf_hub_download
|
| 43 |
+
|
| 44 |
+
from libribrain_experiments.models.configurable_modules.classification_module import (
|
| 45 |
+
ClassificationModule,
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
# Download a checkpoint (seed-0)
|
| 49 |
+
checkpoint_path = hf_hub_download(
|
| 50 |
+
repo_id="zuazo/megconformer-speech-detection", filename="seed-0/pytorch_model.ckpt"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
# Choose device
|
| 54 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 55 |
+
|
| 56 |
+
# Load model and move to device
|
| 57 |
+
model = ClassificationModule.load_from_checkpoint(checkpoint_path, map_location=device)
|
| 58 |
+
model.eval()
|
| 59 |
+
|
| 60 |
+
# Inference
|
| 61 |
+
meg_signal = torch.randn(1, 306, 125, device=device) # Create directly on device
|
| 62 |
+
|
| 63 |
+
with torch.no_grad():
|
| 64 |
+
logits = model(meg_signal)
|
| 65 |
+
prediction = torch.argmax(logits, dim=1) # 0=silence, 1=speech
|
| 66 |
+
|
| 67 |
+
print(f"Prediction: {'Speech' if prediction.item() == 1 else 'Silence'}")
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
## Model Details
|
| 71 |
+
|
| 72 |
+
- **Architecture**: Conformer Small
|
| 73 |
+
- Hidden size: 144
|
| 74 |
+
- FFN dim: 576
|
| 75 |
+
- Layers: 16
|
| 76 |
+
- Attention heads: 4
|
| 77 |
+
- Depthwise conv kernel: 31
|
| 78 |
+
- **Input**: 306-channel MEG signals
|
| 79 |
+
- **Window size**: 2.5 seconds (625 samples at 250 Hz)
|
| 80 |
+
- **Output**: Binary classification (silence/speech)
|
| 81 |
+
- **Training**: [LibriBrain](https://huggingface.co/datasets/pnpl/LibriBrain) 2025 Standard track
|
| 82 |
+
|
| 83 |
+
## Reproducibility
|
| 84 |
+
|
| 85 |
+
All 10 random seeds are provided to ensure reproducibility.
|
| 86 |
+
|
| 87 |
+
## Citation
|
| 88 |
+
```bibtex
|
| 89 |
+
@misc{dezuazo2025megconformerconformerbasedmegdecoder,
|
| 90 |
+
title={MEGConformer: Conformer-Based MEG Decoder for Robust Speech and Phoneme Classification},
|
| 91 |
+
author={Xabier de Zuazo and Ibon Saratxaga and Eva Navas},
|
| 92 |
+
year={2025},
|
| 93 |
+
eprint={2512.01443},
|
| 94 |
+
archivePrefix={arXiv},
|
| 95 |
+
primaryClass={cs.CL},
|
| 96 |
+
url={https://arxiv.org/abs/2512.01443},
|
| 97 |
+
}
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
## License
|
| 101 |
+
|
| 102 |
+
The 3-Clause BSD License
|
| 103 |
+
|
| 104 |
+
## Links
|
| 105 |
+
|
| 106 |
+
- **Paper**: [arXiv:2512.01443](https://arxiv.org/abs/2512.01443)
|
| 107 |
+
- **Code**: [GitHub](https://github.com/neural2speech/libribrain-experiments)
|
| 108 |
+
- **Competition**: [LibriBrain 2025](https://neural-processing-lab.github.io/2025-libribrain-competition/)
|