| name | tribev2-brain-encoding |
| description | Use TRIBE v2, Meta's multimodal foundation model for predicting fMRI brain responses to video, audio, and text stimuli |
| triggers | ["predict brain responses to video","fMRI encoding model","TRIBE v2 brain prediction","multimodal brain encoding","in-silico neuroscience model","predict cortical activity from video","brain response to naturalistic stimuli","tribev2 inference and training"] |
TRIBE v2 Brain Encoding Model
Skill by ara.so — Daily 2026 Skills collection
TRIBE v2 is Meta's multimodal foundation model that predicts fMRI brain responses to naturalistic stimuli (video, audio, text). It combines LLaMA 3.2 (text), V-JEPA2 (video), and Wav2Vec-BERT (audio) encoders into a unified Transformer architecture that maps multimodal representations onto the cortical surface (fsaverage5, ~20k vertices).
Installation
pip install -e .
pip install -e ".[plotting]"
pip install -e ".[training]"
Quick Start — Inference
Load pretrained model and predict from video
from tribev2 import TribeModel
model = TribeModel.from_pretrained("facebook/tribev2", cache_folder="./cache")
df = model.get_events_dataframe(video_path="path/to/video.mp4")
preds, segments = model.predict(events=df)
print(preds.shape)
Multimodal input — video + audio + text
from tribev2 import TribeModel
model = TribeModel.from_pretrained("facebook/tribev2", cache_folder="./cache")
df = model.get_events_dataframe(
video_path="path/to/video.mp4",
audio_path="path/to/audio.wav",
text_path="path/to/script.txt",
)
preds, segments = model.predict(events=df)
print(preds.shape)
Text-only prediction
from tribev2 import TribeModel
model = TribeModel.from_pretrained("facebook/tribev2", cache_folder="./cache")
df = model.get_events_dataframe(text_path="path/to/narration.txt")
preds, segments = model.predict(events=df)
Brain Visualization
from tribev2 import TribeModel
from tribev2.plotting import plot_brain_surface
model = TribeModel.from_pretrained("facebook/tribev2", cache_folder="./cache")
df = model.get_events_dataframe(video_path="path/to/video.mp4")
preds, segments = model.predict(events=df)
plot_brain_surface(preds[0], backend="nilearn")
Training a Model from Scratch
1. Set environment variables
export DATAPATH="/path/to/studies"
export SAVEPATH="/path/to/output"
export SLURM_PARTITION="your_slurm_partition"
2. Authenticate with HuggingFace (required for LLaMA 3.2)
huggingface-cli login
3. Local test run
python -m tribev2.grids.test_run
4. Full grid search on Slurm
python -m tribev2.grids.run_cortical
python -m tribev2.grids.run_subcortical
Key API — TribeModel
from tribev2 import TribeModel
model = TribeModel.from_pretrained(
"facebook/tribev2",
cache_folder="./cache"
)
df = model.get_events_dataframe(
video_path=None,
audio_path=None,
text_path=None,
)
preds, segments = model.predict(events=df)
Project Structure
tribev2/
├── main.py # Experiment pipeline: Data, TribeExperiment
├── model.py # FmriEncoder: Transformer multimodal→fMRI model
├── pl_module.py # PyTorch Lightning training module
├── demo_utils.py # TribeModel and inference helpers
├── eventstransforms.py # Event transforms (word extraction, chunking)
├── utils.py # Multi-study loading, splitting, subject weighting
├── utils_fmri.py # Surface projection (MNI / fsaverage) and ROI analysis
├── grids/
│ ├── defaults.py # Full default experiment configuration
│ └── test_run.py # Quick local test entry point
├── plotting/ # Brain visualization backends
└── studies/ # Dataset definitions (Algonauts2025, Lahner2024, …)
Configuration — Defaults
Edit tribev2/grids/defaults.py or set environment variables:
{
"datapath": "/path/to/studies",
"savepath": "/path/to/output",
"slurm_partition": "learnfair",
"model": "FmriEncoder",
"modalities": ["video", "audio", "text"],
"surface": "fsaverage5",
}
Custom Experiment with PyTorch Lightning
from tribev2.main import Data, TribeExperiment
from tribev2.pl_module import TribePLModule
import pytorch_lightning as pl
experiment = TribeExperiment(
datapath="/path/to/studies",
savepath="/path/to/output",
modalities=["video", "audio", "text"],
)
data = Data(experiment)
module = TribePLModule(experiment)
trainer = pl.Trainer(
max_epochs=50,
accelerator="gpu",
devices=4,
)
trainer.fit(module, data)
Working with fMRI Surfaces
from tribev2.utils_fmri import project_to_fsaverage, get_roi_mask
surface_data = project_to_fsaverage(mni_data, target="fsaverage5")
roi_mask = get_roi_mask(roi_name="V1", surface="fsaverage5")
v1_responses = preds[:, roi_mask]
print(v1_responses.shape)
Common Patterns
Batch prediction over multiple videos
from tribev2 import TribeModel
import numpy as np
model = TribeModel.from_pretrained("facebook/tribev2", cache_folder="./cache")
video_paths = ["video1.mp4", "video2.mp4", "video3.mp4"]
all_predictions = []
for vp in video_paths:
df = model.get_events_dataframe(video_path=vp)
preds, segments = model.predict(events=df)
all_predictions.append(preds)
Extract predictions for specific brain region
from tribev2 import TribeModel
from tribev2.utils_fmri import get_roi_mask
model = TribeModel.from_pretrained("facebook/tribev2", cache_folder="./cache")
df = model.get_events_dataframe(video_path="video.mp4")
preds, segments = model.predict(events=df)
ac_mask = get_roi_mask("auditory_cortex", surface="fsaverage5")
auditory_responses = preds[:, ac_mask]
Access segment timing metadata
preds, segments = model.predict(events=df)
for i, seg in enumerate(segments):
print(f"Segment {i}: onset={seg['onset']:.2f}s, duration={seg['duration']:.2f}s")
print(f" Brain response shape: {preds[i].shape}")
Troubleshooting
LLaMA 3.2 access denied
huggingface-cli login
CUDA out of memory during inference
import torch
model = TribeModel.from_pretrained("facebook/tribev2", cache_folder="./cache")
model.to("cpu")
Missing visualization dependencies
pip install -e ".[plotting]"
Slurm training not submitting
echo $DATAPATH $SAVEPATH $SLURM_PARTITION
Video without audio track causes error
df = model.get_events_dataframe(
video_path="silent_video.mp4",
audio_path="separate_audio.wav",
)
Citation
@article{dAscoli2026TribeV2,
title={A foundation model of vision, audition, and language for in-silico neuroscience},
author={d'Ascoli, St{\'e}phane and Rapin, J{\'e}r{\'e}my and Benchetrit, Yohann and Brookes, Teon
and Begany, Katelyn and Raugel, Jos{\'e}phine and Banville, Hubert and King, Jean-R{\'e}mi},
year={2026}
}
Resources