Audio inputs: how can a language model listen?
A recording is a stream of measurements, not words. What should an audio position contain so a language model can use it?
We want a language model to answer a question about a recording. A microphone gives us thousands of measurements per second, but what could a position in that sequence tell us?
Let a position describe a short sound
One instant’s amplitude tells us little; a stretch reveals repeated changes. Could we describe that stretch by measuring energy across frequency bands?
A 32 ms window, moved 10 ms at a time, gives us 128 mel-frequency measurements per frame. Overlap keeps a sound crossing a window boundary in view. These are local descriptions, rather than words.
Give attention fewer positions to connect
A frame is still ambiguous without its surroundings, but we now have roughly 100 frames per second. Could convolution learn useful local combinations at a lower time resolution before we ask attention to connect them?
Two stride-two stages leave about 25 positions per second. A learned projection gives each position 1,536 coordinates; the time axis gets shorter while the representations get wider.
Ask earlier frames for more information
Could the familiar attention operation let these positions request missing context? How far back a sound occurred could help too, alongside what it contains.
The query contributes both content scores and relative timing scores before masking and softmax. In this worked encoder, each position can read itself and 12 earlier positions, with no future positions; it uses eight heads of width 192.
The 12-query chunks organise computation, rather than fixing recording length. Relative sinusoidal timing features avoid a learned table of absolute recording slots; padding and processor limits remain separate considerations.
Combine requests with local patterns
Attention can request information from earlier sound, while a short convolution can recognise nearby patterns directly. Could we use both, with feed-forward layers to transform their results?
This combination is a Conformer. After 12 such blocks, keeping one position in four leaves about 6.25 outputs per second, trading some temporal detail for less language-model work.
Inside a Conformer block
The attention branch above sits between two feed-forward branches, alongside a gated causal convolution. Each branch adds to the downward residual stream; the feed-forward contributions are scaled by one half.
The convolution’s GLU splits its projection into content and a sigmoid gate, then a five-position depthwise kernel processes each channel over time. This diagram follows Gemma 3n’s RMSNorm and SiLU choices; other Conformers can arrange their normalisation and operations differently.
Give the audio vectors the text width
Our audio vectors are now 1,536 coordinates wide, while the text vectors need 2,048. Could a learned projection make them fit together?
The position count stays the same. Changing vector width is separate from reducing time resolution.
Follow sound into the language model
Local frequency measurements gave us a manageable starting point. Attention and convolution added context; time reduction shortened the sequence; projection made it fit beside the text.
This is the input path used by Gemma 3n, with 12 Conformer blocks combining local attention and convolution. The language model can use the recording alongside text, without discarding tone and other sounds in a transcription first. How would we give it a path for producing sound too?
Choose a different audio encoder
The goal is useful audio vectors, rather than one particular encoder. The model catalogue contains several choices:
| Path | What changes | Examples |
|---|---|---|
| Conformer | Attention and convolution build context together; widths and normalisation vary. | Gemma 3n uses width 1,536; Gemma 4 E2B and E4B use width 1,024. |
| Whisper-based transformer | A speech encoder prepares features, with frame stacking and a learned connector into the language model. | Apriel Voice |
| Other convolution/attention stacks | The layer layout, time reduction and receptive field differ from our worked Conformer. | LFM3, Liquid D1 and Nemotron 3 Nano Omni |
| Convolutional pyramid | A hierarchy of convolutions prepares audio features. | Muse Spark |
| Audio tokenizer and patch encoder | Audio passes through a different two-stage representation path. | MiMo-V2 |
The full diagram expands one worked attention design, rather than assigning its causal mask, relative positions or eight heads to every audio encoder. Audio generation also needs its own output path; an input encoder alone does not provide one.
Sources and worked example
- Conformer, Gulati et al., 2020, and Universal Speech Model, Zhang et al., 2023.
- Gemma 3n documentation.
- Gemma 3n feature extractor: 16 kHz input, 32 ms windows, 10 ms hops and 128 mel bands.
- Audio configuration: 12 Conformer blocks of width 1,536, eight attention heads, a 12-query chunk, left-context setting 13 (12 past positions plus the current one), right context zero, five-position convolution, half-scaled feed-forward branches and final reduction factor 4.
- Model implementation: learned per-coordinate query scaling, projected relative sinusoidal positions, logit soft-cap 50, causal/padding masks, the Conformer residual paths and multimodal embedding projection.
F labels feature-frame count and A valid audio-output positions. Sampling-rate conversions, pre-emphasis, framing boundaries and padding affect exact lengths. Gemma 3n’s formatter pads audio soft-token slots separately from valid audio content. The waveform and feature cells are illustrations, not a measured recording. The shared picker covers Gemma 3n E2B and E4B; their audio tower is the same. The attention drawing shows a full 12-query chunk with 24 gathered context slots; each row reads 13 slots before sequence-boundary and padding masks. Queries are scaled by softplus(θ) / (√192 × softplus(0)), with one learned 192-coordinate scale shared across heads. The relative-position projection maps 1,536 sinusoidal coordinates to eight 192-coordinate heads. “Clip” denotes the implementation’s activation clamp at ±10¹⁰. Subsampling convolutions can use a short forward receptive field; the no-future attention mask does not imply zero audio-front-end lookahead. The optional block diagram labels operation order and representative weight shapes; masks also zero padded inputs to its local convolution. Other encoders in the comparison follow their own sourced architecture records.