BCILattice Model Catalog
All BCI model classes plus the full HuggingFace ecosystem:Edge, GPT, Sequence, Transformer, and 679 HuggingFace blocks (Models, Tokenizers, Training, Pipelines, Datasets, PEFT, Evaluate, Hub). Constructor parameters, methods, and import lines.
Overview
BCILattice ships a curated set of deep learning model classes under the nm_models namespace. These are available as drag-and-drop blocks inside the ML Suite canvas and can be wired into any training pipeline. Each class is documented here with its full constructor signature, parameter table, and available methods.
All models accept EEG / BCI signal tensors as input and return a model object that can be connected to training, evaluation, and export blocks.
| Category | Module | Classes |
|---|---|---|
| BCI EEG Models | nm_models.bci_eeg | EEGNet, ShallowConvNet, DeepConvNet, ATCNet, EEGConformer |
| BCI Decoding | mne.decoding | CSP, SPoC, XdawnTransformer, SSD, EMS, UnsupervisedSpatialFilter, Vectorizer, Scaler |
| Riemannian Geometry | pyriemann | Covariances, ERPCovariances, TangentSpace + MDM, FgMDM, TSClassifier |
| Edge Models | nm_models.edge | MobileEEGNet, QuantizedEEGNet, TinyEEGNet |
| GPT Models | nm_models.gpt_models | TinyGPT, MiniGPT, LargeGPT, GPT2BCI, BioGPTBCI, LaBraMBCI |
| Sequence Models | nm_models.sequence | LSTMClassifier, BiLSTMClassifier, GRUClassifier, TCNClassifier, MambaSSM |
| Transformer Models | nm_models.transformers | PatchTST, BrainBERT, EEGTransformer, ViTEEG |
| HF Models | transformers | 48 classes:Auto, BERT, RoBERTa, DistilBERT, ALBERT, ELECTRA, XLNet, GPT-2, T5, Llama, Mistral, Qwen, Gemma, Phi, Falcon, Whisper, CLIP, ViT, DeiT, Swin + BitsAndBytesConfig, GenerationConfig |
| HF Tokenizers | transformers | 28 tokenizers / processors:AutoTokenizer, BertTokenizer(Fast), RobertaTokenizer(Fast), DistilBert, Albert, Electra, XLNet, GPT2, T5, Llama, Whisper, CLIP tokenizers + Auto Processors |
| HF Training | transformers | TrainingArguments, Seq2SeqTrainingArguments, Trainer, Seq2SeqTrainer, DataCollatorWithPadding, DataCollatorForSeq2Seq, DataCollatorForLanguageModeling, DataCollatorForWholeWordMask, EarlyStoppingCallback |
| HF Pipelines | transformers | pipeline() + 25 task variants: text-classification, NER, QA, text-generation, summarization, translation, fill-mask, zero-shot, ASR, image-classification, object-detection, VQA, depth-estimation, … |
| HF Datasets | datasets | load_dataset, load_from_disk, concatenate_datasets, interleave_datasets, Dataset, DatasetDict, IterableDataset, Features, ClassLabel, Sequence, Value, Array2D/3D |
| HF PEFT | peft | LoraConfig, AdaLoraConfig, IA3Config, PromptTuningConfig, PrefixTuningConfig, PromptEncoderConfig, get_peft_model, prepare_model_for_kbit_training, PeftModel, PeftModelForCausalLM/Seq2Seq/SequenceClassification/TokenClassification |
| HF Evaluate | evaluate | evaluate.load, evaluate.combine, evaluator, EvaluationModule (compute / add / add_batch / reset) |
| HF Hub | huggingface_hub | hf_hub_download, snapshot_download, HfApi, login, logout, whoami, list_models, list_datasets, model_info, dataset_info |
Edge Models
Lightweight EEG classification architectures optimised for edge deployment, low-latency inference, and quantization. Available in the nm_models.edge module.
MobileEEGNet
from nm_models.edge import MobileEEGNet
MobileEEGNet(n_channels=16, n_classes=4, width_mult=0.5, dropout=0.3)
Constructor Parameters
| Parameter | Type | Default |
|---|---|---|
| n_channels | int | 16 |
| n_classes | int | 4 |
| width_mult | float | 0.5 |
| dropout | float | 0.3 |
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
QuantizedEEGNet
from nm_models.edge import QuantizedEEGNet
QuantizedEEGNet()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
.prepare_quantization()-> self: QuantizedEEGNet.convert_to_int8()-> self: QuantizedEEGNet.export_onnx()-> path: str| Parameter | Type | Default |
|---|---|---|
| path | str | — |
| sample_input | torch.Tensor | — |
TinyEEGNet
from nm_models.edge import TinyEEGNet
TinyEEGNet()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
GPT Models
Transformer-based language-style architectures adapted for BCI signal classification and generation tasks. Available in nm_models.gpt_models.
TinyGPT
from nm_models.gpt_models import TinyGPT
TinyGPT()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
MiniGPT
from nm_models.gpt_models import MiniGPT
MiniGPT()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
LargeGPT
from nm_models.gpt_models import LargeGPT
LargeGPT()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
GPT2BCI
from nm_models.gpt_models import GPT2BCI
GPT2BCI()
Constructor Parameters
| Parameter | Type | Default |
|---|---|---|
| n_positions | int | 128 |
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
BioGPTBCI
from nm_models.gpt_models import BioGPTBCI
BioGPTBCI()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
LaBraMBCI
from nm_models.gpt_models import LaBraMBCI
LaBraMBCI()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
Sequence Models
Recurrent and temporal convolutional architectures for sequential BCI decoding. Available in nm_models.sequence.
LSTMClassifier
from nm_models.sequence import LSTMClassifier
LSTMClassifier()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
BiLSTMClassifier
from nm_models.sequence import BiLSTMClassifier
BiLSTMClassifier()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
GRUClassifier
from nm_models.sequence import GRUClassifier
GRUClassifier()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
TCNClassifier
from nm_models.sequence import TCNClassifier
TCNClassifier()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
MambaSSM
from nm_models.sequence import MambaSSM
MambaSSM()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
Transformer Models
Patch-based transformer architectures for time-series BCI classification. Available in nm_models.transformers.
PatchTST
from nm_models.transformers import PatchTST
PatchTST()
Output: model_obj: Any
Methods
.forward()-> output: Any| Parameter | Type | Default |
|---|---|---|
| x | torch.Tensor | — |
HuggingFace Integration
BCILattice integrates the full HuggingFace ecosystem as drag-and-drop blocks in the ML Suite and Workflow canvases. Every transformers, peft, datasets, evaluate, and huggingface_hub component is available with its complete parameter set:no coding required.
| Category | Library | Highlights |
|---|---|---|
| HF Models | transformers | Auto classes, BERT, RoBERTa, DistilBERT, ALBERT, ELECTRA, XLNet, GPT-2, T5, Llama, Mistral, Qwen2, Gemma2, Phi-3, Falcon, Whisper, CLIP, ViT, DeiT, Swin + quantization & generation configs |
| HF Tokenizers | transformers | AutoTokenizer, AutoProcessor, AutoFeatureExtractor, AutoImageProcessor and 25+ model-specific tokenizers with encode / decode / batch_encode_plus methods |
| HF Training | transformers | Trainer, Seq2SeqTrainer, TrainingArguments, Seq2SeqTrainingArguments, DataCollators (padding, seq2seq, LM, WWM), callbacks (EarlyStopping, Printer, Progress) |
| HF Pipelines | transformers | 25 task-specific pipelines: text-classification, NER, QA, text-generation, summarization, translation, fill-mask, zero-shot, ASR, image-classification, depth-estimation, VQA, and more |
| HF Datasets | datasets | load_dataset, Dataset, DatasetDict, IterableDataset, Features, ClassLabel, Sequence, Value, Array2D/3D + map / filter / shuffle / split / push_to_hub methods |
| HF PEFT | peft | LoRA, AdaLoRA, IA³, PromptTuning, PrefixTuning, PromptEncoder, get_peft_model, prepare_model_for_kbit_training, PeftModel + merge / unload / adapter management |
| HF Evaluate | evaluate | evaluate.load (accuracy, F1, BLEU, ROUGE, BERTScore, perplexity, seqeval, …), combine, evaluator + compute / add_batch methods |
| HF Hub | huggingface_hub | hf_hub_download, snapshot_download, HfApi (upload, create_repo, list_repo_files), login, list_models, list_datasets, model_info |
HF Models
All model classes live in the HuggingFace Models palette category. Each block exposes a from_pretrained method block plus save_pretrained and push_to_hub. Key constructor parameters (model_name_or_path, torch_dtype, device_map, num_labels) are editable in the Property Inspector.
Auto Classes
Auto classes select the correct architecture from the checkpoint name automatically.
AutoModelGeneral-purpose encoder:returns hidden states.AutoModelForSequenceClassificationText / signal classification (num_labels).AutoModelForTokenClassificationToken-level labeling:NER, POS tagging.AutoModelForQuestionAnsweringExtractive QA:returns start/end logits.AutoModelForCausalLMAutoregressive text / sequence generation.AutoModelForSeq2SeqLMEncoder-decoder generation (T5, BART, mBART).AutoModelForMaskedLMMasked language modeling:BERT-style.AutoModelForSpeechSeq2SeqSpeech → text (Whisper-family).AutoModelForImageClassificationImage → class label (ViT-family).AutoConfigLoad model configuration without weights.BERT Family
from transformers import BertForSequenceClassification
model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=4)| Parameter | Type | Default |
|---|---|---|
| model_name_or_path | str | bert-base-uncased |
| num_labels | int | 2 |
Also available: BertModel, BertForTokenClassification, BertForQuestionAnswering, BertForMaskedLM, RobertaModel/ForSequenceClassification/ForTokenClassification, DistilBertModel/For*, AlbertModel/For*, ElectraModel/For*, XLNetModel/For*.
GPT-2
from transformers import GPT2LMHeadModel, GenerationConfig
model = GPT2LMHeadModel.from_pretrained('gpt2')
gen_cfg = GenerationConfig(max_new_tokens=256, do_sample=True, temperature=0.8, top_p=0.95)T5
from transformers import T5ForConditionalGeneration, T5TokenizerFast
model = T5ForConditionalGeneration.from_pretrained('t5-small')
tokenizer = T5TokenizerFast.from_pretrained('t5-small')Llama / Mistral / Qwen
Large language models for causal generation:typically used with 4-bit or 8-bit quantization.
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
import torch
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype="bfloat16",
)
model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Meta-Llama-3-8B-Instruct",
quantization_config=bnb_config,
device_map="auto",
)Supported: LlamaForCausalLM, Llama3ForCausalLM, MistralForCausalLM, MixtralForCausalLM, Qwen2ForCausalLM, Gemma2ForCausalLM, Phi3ForCausalLM, FalconForCausalLM.
Vision & Multimodal
from transformers import ViTForImageClassification, CLIPModel
vit = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
clip = CLIPModel.from_pretrained('openai/clip-vit-base-patch32')Also: DeiTForImageClassification, SwinModel, CLIPTextModel.
Audio (Whisper)
from transformers import WhisperForConditionalGeneration, WhisperProcessor
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-small")
processor = WhisperProcessor.from_pretrained("openai/whisper-small")Quantization & Generation
| Parameter | Type | Default |
|---|---|---|
| load_in_4bit | bool | false |
| load_in_8bit | bool | false |
| bnb_4bit_quant_type | str | nf4 |
| bnb_4bit_use_double_quant | bool | true |
| bnb_4bit_compute_dtype | str | bfloat16 |
Tokenizers & Processors
All tokenizers expose a unified set of methods: __call__, encode, decode, batch_encode_plus, tokenize, convert_tokens_to_ids, convert_ids_to_tokens, save_pretrained, and from_pretrained.
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
encoded = tokenizer(
"EEG signal classification",
padding="max_length",
truncation=True,
max_length=128,
return_tensors="pt",
)| Parameter | Type | Default |
|---|---|---|
| padding | str | max_length |
| truncation | bool | true |
| max_length | int | 512 |
| return_tensors | str | pt |
28 tokenizers available including AutoProcessor, AutoFeatureExtractor, AutoImageProcessor, WhisperProcessor, CLIPProcessor.
Training
TrainingArguments
Controls every aspect of the training loop:learning rate, batch size, checkpointing, logging, and mixed precision.
from transformers import TrainingArguments
args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
per_device_train_batch_size=16,
learning_rate=5e-5,
fp16=True,
evaluation_strategy="epoch",
save_strategy="epoch",
load_best_model_at_end=True,
report_to="none",
)| Parameter | Type | Default |
|---|---|---|
| output_dir | str | ./results |
| num_train_epochs | int | 3 |
| per_device_train_batch_size | int | 16 |
| per_device_eval_batch_size | int | 16 |
| learning_rate | float | 5e-5 |
| lr_scheduler_type | str | linear |
| warmup_steps | int | 500 |
| weight_decay | float | 0.01 |
| fp16 | bool | false |
| bf16 | bool | false |
| gradient_accumulation_steps | int | 1 |
| evaluation_strategy | str | epoch |
| save_strategy | str | epoch |
| load_best_model_at_end | bool | true |
| metric_for_best_model | str | eval_loss |
| push_to_hub | bool | false |
| report_to | str | none |
| seed | int | 42 |
Trainer
The Trainer block orchestrates training, evaluation, and prediction. Wire it to a model, tokenizer, datasets, and collator.
from transformers import Trainer
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_ds,
eval_dataset=eval_ds,
tokenizer=tokenizer,
data_collator=collator,
compute_metrics=compute_metrics,
)
trainer.train()Methods: train(), evaluate(), predict(), save_model(), push_to_hub(), get_train_dataloader().
Seq2Seq variant: Seq2SeqTrainer with Seq2SeqTrainingArguments.
Data Collators
| Collator | Use Case |
|---|---|
| DataCollatorWithPadding | Classification:pads sequences to longest in batch. |
| DataCollatorForSeq2Seq | Encoder-decoder:pads inputs and labels separately. |
| DataCollatorForLanguageModeling | MLM / CLM:applies random token masking (mlm_probability). |
| DataCollatorForWholeWordMask | Whole-word masking for BERT pre-training. |
Callbacks
EarlyStoppingCallback(early_stopping_patience=3):stops training when metric_for_best_model stops improving. PrinterCallback and ProgressCallback for logging.
Pipelines
The pipeline() block wraps a model and tokenizer into a single callable inference object. BCILattice exposes 25 task-specific variants as ready-made blocks.
from transformers import pipeline
clf = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
asr = pipeline("automatic-speech-recognition", model="openai/whisper-small", device=0)| Task | Default Model |
|---|---|
| text-classification / sentiment-analysis | distilbert-base-uncased-finetuned-sst-2-english |
| token-classification / ner | dbmdz/bert-large-cased-finetuned-conll03-english |
| question-answering | deepset/roberta-base-squad2 |
| text-generation | gpt2 |
| summarization | facebook/bart-large-cnn |
| translation (en→fr/de/ro) | Helsinki-NLP/opus-mt-* |
| fill-mask | bert-base-uncased |
| zero-shot-classification | facebook/bart-large-mnli |
| automatic-speech-recognition | openai/whisper-small |
| image-classification | google/vit-base-patch16-224 |
| object-detection | facebook/detr-resnet-50 |
| visual-question-answering | dandelin/vilt-b32-finetuned-vqa |
| depth-estimation | Intel/dpt-large |
| conversational | microsoft/DialoGPT-medium |
Datasets
The datasets library provides fast, memory-mapped dataset loading with built-in transforms and Hub integration.
from datasets import load_dataset
ds = load_dataset("imdb", split="train") # HuggingFace Hub
ds = load_dataset("csv", data_files="data.csv") # local CSV
ds = ds.train_test_split(test_size=0.1, seed=42)Dataset Methods
| Parameter | Type | Default |
|---|---|---|
| map(fn, batched, num_proc) | Dataset | — |
| filter(fn) | Dataset | — |
| shuffle(seed) | Dataset | — |
| select(indices) | Dataset | — |
| train_test_split(test_size) | DatasetDict | — |
| sort(column) | Dataset | — |
| rename_column(old, new) | Dataset | — |
| remove_columns(cols) | Dataset | — |
| set_format(type="torch") | None | — |
| save_to_disk(path) | None | — |
| push_to_hub(repo_id) | None | — |
Feature types: Value, ClassLabel, Sequence, Array2D, Array3D.
PEFT / LoRA
Parameter-Efficient Fine-Tuning methods let you fine-tune large models by training only a small fraction of parameters. BCILattice exposes all PEFT methods as canvas blocks.
LoraConfig
from peft import LoraConfig, TaskType
config = LoraConfig(
task_type=TaskType.CAUSAL_LM,
r=8,
lora_alpha=32,
lora_dropout=0.1,
target_modules=["q_proj", "v_proj"],
bias="none",
)| Parameter | Type | Default |
|---|---|---|
| task_type | TaskType | CAUSAL_LM |
| r | int | 8 |
| lora_alpha | int | 32 |
| lora_dropout | float | 0.1 |
| target_modules | List[str] | — |
| bias | str | none |
| use_rslora | bool | false |
| modules_to_save | List[str] | — |
PeftModel
from peft import get_peft_model, PeftModel # Wrap a base model peft_model = get_peft_model(model, lora_config) peft_model.print_trainable_parameters() # Load saved adapter loaded = PeftModel.from_pretrained(model, "path/to/adapter") merged = loaded.merge_and_unload() # merge LoRA weights into base
Methods: print_trainable_parameters(), merge_adapter(), unmerge_adapter(), merge_and_unload(), save_pretrained(), load_adapter(), enable/disable_adapter_layers(), set_adapter().
Other PEFT Methods
| Config Class | Method |
|---|---|
| AdaLoraConfig | Adaptive LoRA:dynamically allocates rank budget. |
| IA3Config | IA³:scales attention keys, values, and FFN activations. |
| PromptTuningConfig | Soft prompt tuning:prepend learnable virtual tokens. |
| PrefixTuningConfig | Prefix vectors prepended to every transformer layer. |
| PromptEncoderConfig | P-tuning v2:MLP encoder produces prefix embeddings. |
| prepare_model_for_kbit_training | Prepares a quantized model for gradient checkpointing. |
Evaluate
evaluate.load() returns a metric module with compute(predictions, references), add(), add_batch(), and reset() methods.
import evaluate
accuracy = evaluate.load("accuracy")
f1 = evaluate.load("f1")
rouge = evaluate.load("rouge")
combined = evaluate.combine(["accuracy", "f1"])
results = accuracy.compute(predictions=[1, 0, 1], references=[1, 1, 0])Available metrics: accuracy, f1, precision, recall, bleu, rouge, meteor, bertscore, perplexity, seqeval, glue, squad, squad_v2.
HuggingFace Hub
Upload models, datasets, and adapters:or download checkpoints:directly from canvas blocks.
from huggingface_hub import login, hf_hub_download, HfApi
login(token="hf_...")
# Download a single file
path = hf_hub_download(repo_id="bert-base-uncased", filename="config.json")
# Upload via HfApi
api = HfApi(token="hf_...")
api.upload_file(
path_or_fileobj="./model.pt",
path_in_repo="model.pt",
repo_id="my-org/my-model",
)HfApi Methods
| Parameter | Type | Default |
|---|---|---|
| upload_file(path, path_in_repo, repo_id) | str | — |
| upload_folder(folder, repo_id) | str | — |
| create_repo(repo_id, private) | RepoUrl | — |
| delete_repo(repo_id) | None | — |
| list_repo_files(repo_id) | Iterable[str] | — |
| delete_file(path_in_repo, repo_id) | None | — |