Unified Audio-Visual-Language Modeling › Modality Encoders
Language AI HandbookAll chapters A model cannot use a waveform or a frame until it has a representation for it. A text tokenizer produces integer IDs, each associated with an embedding row. Audio and video encoders instead often produce real-valued feature vectors. In both cases the transformer receives vectors, but the audio and video positions do not need an ID in the text vocabulary.
Why not feed raw audio or pixels directly
At 16,000 samples per second, 30 seconds of audio gives 480,000 samples. A 30-second video at 30 frames per second gives 900 frames. If each RGB frame contributes one sequence position per color value, the video has 135,475,200 positions. This is a deliberately inefficient raw encoding for comparison. An ordinary dense attention head computes pairwise scores for up to query-key positions before considering a mask. One head on the raw audio would therefore have about position pairs in one layer. A causal mask has fewer allowed pairs, with the same quadratic growth. An optimized kernel can avoid storing a dense score matrix while doing the underlying pairwise computation.
PythonIn [3]Expand
# For a 30-second clip, compute raw sizes from the stated sampling and frame
# rates. Use one pooled video feature per frame. The 1,500 audio positions
# come from the Whisper large model configuration.
SAMPLE_RATE = 16_000 # Hz, speech
AUDIO_SECONDS = 30.0
VIDEO_FPS = 30
VIDEO_SECONDS = 30.0
FRAME_PIXELS = 224 * 224 * 3
raw_audio_samples = int(SAMPLE_RATE * AUDIO_SECONDS)
raw_video_values = int(VIDEO_FPS * VIDEO_SECONDS) * FRAME_PIXELS
# Compressed representations: Whisper-large (1500 vectors / 30s) and a
# per-frame ViT at 1 token per frame.
compressed_audio = 1500
compressed_video = int(VIDEO_FPS * VIDEO_SECONDS) # 1 token per frame
compressed_total = compressed_audio + compressed_video
seq_lengths = {
"Raw audio samples": raw_audio_samples,
"Raw video values": raw_video_values,
"Audio feature vectors": compressed_audio,
"Video feature vectors": compressed_video,
}
print({k: f"{v:,}" for k, v in seq_lengths.items()})
print(f"Combined compressed length: {compressed_total:,}")ConsoleOut [3]Expand
{'Raw audio samples': '480,000', 'Raw video values': '135,475,200', 'Audio feature vectors': '1,500', 'Video feature vectors': '900'}
Combined compressed length: 2,400VisualizationOut [4]Expand

This figure compares counts of positions, not bytes or measured latency. Restricting video to one vector per frame is an illustrative pooling choice. A vision encoder can also preserve a patch sequence per frame, or keep multiple spatial regions. Pooling saves positions while making it harder to recover within-frame detail. Speech recognition features can also retain information about the speaker. Whisper-PMFA used features from Whisper encoder blocks for speaker verification.
Audio encoders
A common front end divides the waveform into overlapping windows, computes a spectrum for each window, and aggregates spectral energy into mel-filterbank bins. The resulting mel spectrogram has one axis for time and one for frequency bins. For an actual model, check the exact window, hop, padding and feature stride before converting a time span into a number of output positions.
If denotes a spectrogram with frequency bins and frames, the audio encoder produces time-indexed vectors
Here counts output positions, and counts components per position. A stride-two convolution can reduce the time resolution without changing the duration of the underlying clip. The Whisper paper uses 30-second input segments and a convolutional stem with stride two. The released large model configuration lists hidden width 1,280 and up to 1,500 source positions. Padding and trimming affect which positions represent the actual clip near its boundaries.
Video encoders
One option runs a vision encoder on each frame and preserves the time ordering of the frame features. A frame encoder can describe the frame at its own timestamp without encoding motion between frames. A later model can still infer motion by comparing the ordered outputs. Another option projects spatiotemporal patches across consecutive frames. For frames of height and width , with nonoverlapping patches of temporal extent and spatial extent , exactly divisible dimensions yield
This is a count before pooling or adding markers. At 300 frames of , with and , it is . Real encoders may sample fewer frames or merge patches after encoding. Those are separate choices with separate effects on what timing or spatial detail reaches the language model.
Text tokenizer
A tokenizer such as byte-pair encoding maps input text to a sequence of vocabulary IDs. The embedding lookup maps each ID to a fixed-width vector. Token counts depend on the vocabulary and normalization rules. An encoder can retain continuous features at input positions while a generation head selects discrete IDs at its output.
A position filled by an audio or video encoder is sometimes called a token. This usage describes its place in the sequence. It does not mean the encoder emitted an ID from the text vocabulary.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!