Skip to content

Video understanding, tracking, generation, and world models · Video generation · VID051 · Model

VideoGPT

Compresses videos into discrete codes with a spatiotemporal VQ-VAE, then learns an autoregressive transformer over those codes.

Runs as a notebook Complete calculation CodeSplash's run and the reference's record

In CodeSplash

No method yet, but the reference's example runs here as a notebook.

Do it in CodeSplash Open the reference's example as a Python or R notebook.

Availability
Runs as a notebook
Code example
Complete calculation
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Compresses videos into discrete codes with a spatiotemporal VQ-VAE, then learns an autoregressive transformer over those codes. It separates perceptual compression from sequence modeling and makes video generation resemble token generation.

Question / objective

Learn a conditional distribution over videos, with useful visual quality, temporal coherence and controllability. This is a learning or inference objective, not a test of a statistical null hypothesis.

Method type and supervision

model · Video generation. Generative distribution learning, commonly with text/image conditioning; adversarial and token objectives differ.

Architecture / computational structure

3D VQ-VAE encoder/codebook/decoder and autoregressive latent-token transformer.

Assumptions

Inputs must satisfy the temporal, modality and annotation protocol described below. Compression sets an upper bound on recovered detail. Autoregressive generation can be slow, and likelihood in token space is not directly comparable across tokenizers.

Formula / computational definition

p(z)=∏ipθ(zi∣z<i)p(z)=\prod_i p_\theta(z_i\mid z_{<i}) models discrete latent tokens; x^=D(z)\hat x=D(z) decodes them. The tokenizer has reconstruction and vector-quantization objectives, while the transformer minimizes token negative log-likelihood.

Parameters and notation

Learned/estimated quantities: Tokenizer, denoiser/generator, temporal and conditioning weights are learned as applicable; sampled latents are random variables rather than fitted model weights. Symbols specific to the objective are defined with the equation. Hyperparameters and design choices: Codebook size, spatial/temporal compression, token order, context length, sampling temperature and decoder fidelity matter.

Fitting, fine-tuning, and adaptation

Freeze the tokenizer while adapting token dynamics first. Retokenizing data after codebook adaptation is essential because code IDs change meaning; assess reconstruction before generation. Use a separate adaptation validation split, monitor the target metric and retention of previously useful behavior, and save the exact preprocessing and training configuration.

How to use and calibrate

Fix the input protocol and target before fitting; choose design settings on held-out source videos, then freeze the evaluation procedure. Report reconstruction quality separately from generated-video quality, diversity, temporal consistency and sampling cost.

Example application

Generate short videos as sequences of learned discrete visual codes.

Interpretation / pitfalls

Watch out

An optimized training objective or a favorable example does not establish generalization. Report reconstruction quality separately from generated-video quality, diversity, temporal consistency and sampling cost. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.

Python and R code examples

Component: Evaluate an autoregressive discrete-video token sequence. Dependencies: NumPy in Python; base R in R; run the shared setup above. Python component: executed successfully. R component: unexecuted. No complete model training or pretrained inference was executed.

Full implementation route — Python: Implement or reproduce the 3D VQ-VAE before fitting the token transformer; freeze and version the tokenizer. R: Compute autoregressive token losses and sampling in R; bridge neural tokenization and decoding through Python.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Complete calculation — Evaluate an autoregressive discrete-video token sequence.

Shared setup for this chapter
import numpy as np

def softmax(x):
    z = np.asarray(x, dtype=float)
    e = np.exp(z - z.max())
    return e / e.sum()
tokens = np.array([0,1,2])
conditional_probabilities = np.array([[.7,.2,.1],[.2,.6,.2],[.1,.2,.7]])
selected = conditional_probabilities[np.arange(3),tokens]
print("token NLL",-np.log(selected).sum(),"perplexity",np.exp(-np.log(selected).mean()))
R

Complete calculation — Evaluate an autoregressive discrete-video token sequence.

Shared setup for this chapter
softmax <- function(x) {
  e <- exp(x - max(x))
  e / sum(e)
}
tokens <- c(1L,2L,3L)
probabilities <- rbind(c(.7,.2,.1),c(.2,.6,.2),c(.1,.2,.7))
selected <- probabilities[cbind(1:3,tokens)]
print(c(NLL=-sum(log(selected)),perplexity=exp(-mean(log(selected)))))

Sources

From the CodeSplash reference, entry VID051.