LeVJEPA README

The project's README from github.com/MLO-lab/LeVJEPA. As one markdown file: README.md.

LeVJEPA: Efficient & Scalable Video Pretraining without the Heuristics

Official implementation of LeVJEPA, the first video encoder trained under LeJEPA's collapse-free objective.

Lukas Kuhn, Lucas Maes, Giuseppe Serra, Quentin Le Lidec, Yann LeCun, Randall Balestriero, Florian Buettner

Paper on arXiv Project Page Model on Hugging Face

What is LeVJEPA?

Self-supervised video pretraining has so far relied on architectural machinery to avoid representation collapse:

LeVJEPA dispenses with all of it. A single encoder is trained with an invariance loss over global and local views of a clip. The loss is regularized by SIGReg, the Sketched Isotropic Gaussian Regularizer from LeJEPA, which constrains the embedding distribution to an isotropic Gaussian and so rules out collapse with a provable guarantee. The trainable architecture reduces to an encoder and a small projector, and the objective has a single hyperparameter, λ.

Because there is no target-encoder forward pass and no predictor, the cost of a training step depends only on the number of tokens the encoder sees. The paper develops two consequences of this:

Results

LeVJEPA-1.5-Large was trained on ~5,300 unique video hours with 151 exaflops of compute. That is 25.7× less data and 5.6× less compute than V-JEPA 1, and 321× less data and ~28.5× less compute than V-JEPA 2. All three encoders are evaluated frozen with attentive probing. The table shows mean accuracy (%):

LeVJEPA 1.5 Large V-JEPA 1 V-JEPA 2
Image (15 datasets) 83.34 83.03 84.90
Video (7 datasets) 68.94 72.79 74.61
Overall (22 datasets) 78.76 79.77 81.63

Per-dataset results and the training budget are on the model card.

Versions

This repository holds the second version of the code. The encoder of the paper and the released checkpoint (v1) uses a [cls] token over the whole clip and block-causal attention. The v1 code remains available as legacy/vision_transformer.py so that v1 checkpoints load and evaluate here (see Loading v1 models).

The v2 encoder (model.py) is built for streaming:

Pretraining is otherwise the paper's recipe:

Pretrained checkpoint

A ViT-L/16 is released as LeVJEPA-1.5-Large. It is a v1 encoder with 303M parameters, trained on 1.8M clips from Kinetics-710, Something-Something v2, Walking Tours and PE-Video. The released tensors are the EMA copy of the encoder.

It loads without this repository through transformers:

import torch
from transformers import AutoModel

model = AutoModel.from_pretrained("galilai-group/LeVJEPA-1.5-Large", trust_remote_code=True).eval()

video = torch.randn(1, 3, 16, 224, 224)   # (B, C, T, H, W), ImageNet-normalised, 16 frames at ~7.5 fps
with torch.no_grad():
    out = model(pixel_values=video)
out.last_hidden_state   # (1, 3137, 1024): [cls] + 16*14*14 patch tokens
out["pooler_output"]    # (1, 1024): the [cls] token

For a single image, repeat it along the time axis: image.unsqueeze(2).repeat(1, 1, 16, 1, 1). To see the features rather than just extract them, notebooks/feature_visualization.ipynb reproduces the paper's dense-feature visualizations: patch-token PCA on images and query-patch cosine similarity on videos. Leave config.attn_mode at "block_causal". The weights were trained causal, and full attention returns worse features without raising an error. The checkpoint is meant for frozen feature extraction and has no classification head. Like the v1 encoder code, the weights are under CC BY-NC 4.0.

Loading v1 models

legacy/encoder.py wraps the v1 encoder behind the v2 interface. It loads:

from legacy.encoder import load_legacy_encoder

encoder = load_legacy_encoder("galilai-group/LeVJEPA-1.5-Large", name="vit_large", num_frames=16)
cls, patches, _ = encoder(clip)   # clip (B, T, C, H, W) -> (B, D), (B, T, 196, D)

The evaluation below runs on v1 models with configs/model/levjepa_v1_vitl.yaml:

python -m eval.eval model=levjepa_v1_vitl checkpoint=galilai-group/LeVJEPA-1.5-Large
python -m eval.eval model=levjepa_v1_vitl checkpoint=/path/to/v1/last.ckpt   # ema=false probes the student

Setup

The project is managed with uv and runs from the repository root:

uv sync                   # training environment (CUDA 12.8 wheels on Linux)
uv sync --extra data      # + decord / yt-dlp, only to build the Walking Tours store (decord: Linux and Windows)
uv sync --extra notebook  # + matplotlib / jupyterlab / PyAV, for the notebooks

Data

Training and evaluation read Lance stores with one frame per row:

column type used by
frame binary encoded image (JPEG or PNG)
episode_idx int the video a row belongs to
label int class label (evaluation only)

All rows of one episode must be contiguous and in temporal order. Images are episodes of length 1. Stores written for v1, with schema (episode_idx, step_idx, frame, h, w, label), work unchanged.

Every training store needs an episode index, which you build once:

python scripts/build_episodes.py data/kinetics/train.lance   # writes data/kinetics/train.episodes.npz

Walking Tours

Walking Tours (Venkataramanan et al., Is ImageNet worth 1 video?, ICLR 2024) consists of 10 long (1–7 h), continuous, first-person city walks. It lets you reproduce video pretraining end to end from public data. The Hugging Face dataset ships only the YouTube URLs, so the build has two steps:

  1. Download the videos at 720p60 (~25 GB).
  2. Encode them into a Lance store (~33 GB) at 15 fps, short edge 384, JPEG quality 90, in 128-frame episodes. The episode index is written at the end.
bash scripts/download_walking_tours.sh                                       # network-bound
uv run python scripts/build_lance_walking_tours.py --workers 16             # CPU-bound, use many cores

Both default to data/walking_tours/. To keep the data elsewhere, pass the paths explicitly and set LEVJEPA_DATA_ROOT=/path/to/data for training; the store is then read from $LEVJEPA_DATA_ROOT/walking_tours/train.lance.

Pretraining

python train.py dataset=walking_tours             # ViT-B on Walking Tours, clips at 7.5 fps
python train.py                                   # configs/config.yaml: ViT-B on configs/dataset/single.yaml
python train.py dataset=mixture                   # several stores, see configs/dataset/mixture.yaml
torchrun --nproc_per_node=4 train.py trainer.devices=4

If you'd rather start small, notebooks/training_workshop.ipynb walks through the whole method in miniature. It builds a ViT-Tiny from this repository's components and trains it inside the notebook on five minutes of a Walking Tours video, using the same views and loss as train.py. It runs on a CUDA GPU, an Apple Silicon Mac (MPS) or plain CPU.

Any config value can be overridden on the command line with Hydra syntax, for example data.batch_size=32 wandb.mode=offline. Under Slurm, launch one task per GPU with srun. Ranks are read from SLURM_PROCID / SLURM_NTASKS (or RANK / WORLD_SIZE under torchrun).

The main settings in configs/config.yaml:

Muon

When muon is set, the encoder's transformer blocks are trained with Muon. These are the attention qkv/proj matrices and the SwiGLU gate/up/down matrices, selected by MUON_MODULES in train.py. Muon keeps a momentum buffer per weight matrix and orthogonalises it with a few Newton–Schulz iterations before each update. The update therefore has the same strength in every direction, rather than being dominated by a few large singular directions. Muon is only defined for 2-D matrices, so every other parameter stays on AdamW: the patch embedding, readout token, norms and projector. Both optimizers use the same learning-rate schedule. With adjust_lr_fn: match_rms_adamw, Muon's update is rescaled to the RMS of an AdamW update, so the AdamW learning rate and weight decay can be reused:

muon: {lr: 4e-4, weight_decay: 0.04, momentum: 0.95, nesterov: true, adjust_lr_fn: match_rms_adamw}

Evaluation

The encoder stays frozen while an attentive probe is trained on its patch tokens. The probe is V-JEPA 2's AttentiveClassifier with depth 4: three self-attention blocks over the tokens, then one learned query that cross-attends to them, then a linear classifier. The datasets follow V-JEPA's frozen-evaluation protocols:

python -m eval.eval checkpoint=/path/to/last.ckpt                    # ImageNet-1k
python -m eval.eval checkpoint=/path/to/last.ckpt benchmark=ssv2     # Something-Something v2, 16x2x3

When a checkpoint was trained with an EMA, the probe uses the EMA weights unless you set ema=false.

Learning rate and training length. The default learning rate is 3e-5. For the best numbers, search over learning rates when compute allows:

python -m eval.eval checkpoint=/path/to/last.ckpt "optimizer.lr=[3e-5,1e-4,3e-4,1e-3]"

Each learning rate trains its own probe on the same frozen tokens. The encoder still runs once per batch, so a search costs only the extra probe compute. Each probe logs val/top1@<lr>, and val/best_top1 is the best value over all learning rates and epochs so far.

Probes train for up to 50 epochs with early stopping: the run ends once no probe has improved its val/top1 for 10 epochs. Change this with trainer.max_epochs=... and early_stopping.patience=..., or turn early stopping off with early_stopping=null.

Repository layout

train.py                     pretraining entry point (optimizers, schedule, loss step)
model.py                     v2 encoder (sliding-window causal ViT, readout token) and projector
loss.py                      SIGReg
data.py                      lance loading, episode / mixture sampling, GPU view augmentation
eval/eval.py                 frozen attentive-probe evaluation
eval/datasets.py             V-JEPA image and video evaluation datasets
eval/probe.py                V-JEPA 2 attentive probe (depth 4) and its lr / weight-decay schedule
legacy/vision_transformer.py v1 encoder (the paper's ViT), for v1 checkpoints
legacy/encoder.py            v1 checkpoint loading behind the v2 encoder interface
scripts/build_episodes.py    episode index of a lance store
scripts/*walking_tours*      Walking Tours download and Lance store build
configs/                     Hydra configs (model, dataset, benchmark)
notebooks/                   training workshop and feature visualization of the released checkpoint

Citation

@misc{kuhn2026levjepaefficientscalable,
      title={LeVJEPA: Efficient & Scalable Video Pretraining without the Heuristics},
      author={Lukas Kuhn and Lucas Maes and Giuseppe Serra and Quentin Le Lidec and Yann LeCun and Randall Balestriero and Florian Buettner},
      year={2026},
      eprint={2608.27395},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2608.27395},
}

License

MIT (see LICENSE). eval/probe.py is adapted from Meta's V-JEPA 2, which is also MIT-licensed. Code adapted from Meta's V-JEPA remains under CC BY-NC 4.0:

The released checkpoint is also under CC BY-NC 4.0.

LeVJEPA (MLO-lab/LeVJEPA)

Searching Database…

What is this?The official implementation of LeVJEPA — a self-supervised video encoder trained with LeJEPA's collapse-free objective. Unlike V-JEPA or VideoMAE it needs no EMA target encoder, stop-gradient, predictor, or pixel-reconstruction decoder: just an encoder, a small projector, and one loss hyperparameter.
Is this a library I can pip install, or a codebase I run myself?It's a research codebase you run from the repo, not an installable package: uv manages the environment, training goes through a Hydra entry point (main.py), and there are two Jupyter notebooks — one for feature visualization, one a guided mini training workshop.
How do I get it running?Clone the repo and run 'uv sync' (add '--extra notebook' for the notebooks). The fastest start is the released checkpoint: load LeVJEPA-VideoMix-Large from HuggingFace with trustremotecode=True, or open notebooks/featurevisualization.ipynb to inspect its features.
Any gotchas when using the released checkpoint?A few: it needs trustremotecode=True since the modeling code ships with the weights; inputs are 16 frames (~2 s at 7.5 fps) with ImageNet normalization, and a still image is repeated along the temporal axis; keep the blockcausal attention default — full attention runs but silently degrades features.
Is any of it non-commercial?The repository is MIT, but module.py (adapted from Meta's V-JEPA) and the released checkpoint weights are CC BY-NC 4.0 — so those parts are non-commercial.
Can I skip training and just download pretrained weights?Yes — LeVJEPA-VideoMix-Large (ViT-L/16, 303M parameters) is released, trained on 1.8M clips from Kinetics-710, Something-Something v2, Walking Tours, and PE-Video. It hits 69.5% top-1 on ImageNet-1K and 55.0% on SSv2 under frozen attentive probing, and is intended for frozen feature extraction — it has no classification head.
What data does the default recipe train on?The default config trains a ViT-B/16 on Walking Tours: 10 first-person city-walk videos (1-7 h each) downloaded from YouTube at 720p60 (~25 GB) and encoded into a ~33 GB Lance frame store, so pretraining reproduces end to end from public data. Other data only needs a yaml under conf/data/ for a Lance store with the same schema.
How does it compare to V-JEPA 2?Epoch-matched it matches or surpasses V-JEPA 2 across ViT-S/B/L at 5.6-20.8x less total pretraining compute — the LeVJEPA ViT-L costs less than half the compute of the V-JEPA 2 ViT-S. At an equal FLOP budget (ViT-B) it leads by +7.6 points on ImageNet-1K (61.0%) and takes the best Kinetics-400 linear probe (44.6%).
Why does it drop 95% of patch tokens during training?With the collapse-free objective, token dropping works as an augmentation rather than an approximation: uniform random dropping raises frozen ImageNet probing accuracy monotonically (33.9% with all tokens to 47.6% at 95% drop) while cutting per-step cost by up to 20x, whereas structured tube masking actively hurts (50.7% to 39.6%).
Creator
MLO-lab
Size
1.4 MB
Stars
293
Updated
CommitNov 02
Age
3mo
Commits · 90 Days