A Time-Frequency Tokenizer is a preprocessing module that transforms a raw, one-dimensional time-series signal into a sequence of discrete tokens representing localized time-frequency patches. By applying a Short-Time Fourier Transform (STFT) or wavelet transform, the signal is decomposed into a two-dimensional spectrogram, which is then segmented into a grid of patches. Each patch is flattened into a vector and linearly projected into an embedding space, creating a token sequence that a standard transformer backbone can process natively.
Glossary
Time-Frequency Tokenizer

What is Time-Frequency Tokenizer?
A preprocessing module that converts a raw time-series signal into a sequence of tokens representing localized time-frequency patches, enabling a standard transformer backbone to process spectral content efficiently.
This approach bridges the gap between raw signal processing and sequence-based architectures like the Spectrogram Vision Transformer. The tokenizer inherently captures the non-stationary spectral content of signals, making it ideal for tasks like Automatic Modulation Classification and RF Fingerprinting. Unlike raw IQ sample tokenization, time-frequency tokens provide explicit frequency locality, allowing the transformer's self-attention mechanism to learn correlations between specific frequency bands and temporal events without requiring the model to infer the Fourier basis from scratch.
Key Features
The Time-Frequency Tokenizer bridges raw signal processing and transformer-based sequence models by converting continuous waveforms into discrete, learnable tokens that capture localized spectral energy.
Short-Time Fourier Transform (STFT) Frontend
The tokenizer begins with an STFT to decompose the raw IQ or real-valued time-series into a 2D time-frequency representation. This step localizes spectral content into overlapping or non-overlapping windows, producing a complex-valued spectrogram. The magnitude and phase components are then separated or processed jointly, depending on the downstream architecture. This frontend is critical for exposing the non-stationary characteristics of communication signals, such as frequency hops or transient pulses, that a raw waveform tokenizer would miss.
Patch Embedding and Linear Projection
Inspired by the Vision Transformer (ViT), the 2D spectrogram is divided into a grid of non-overlapping time-frequency patches. Each patch—a small matrix of spectral bins spanning a short time window—is flattened into a 1D vector. A learned linear projection then maps this vector to a fixed-dimensional embedding space, creating a patch token. This process aggressively compresses the raw spectrogram while preserving local correlations between adjacent frequency bins and time steps.
Learnable Frequency Positional Encoding
Standard positional encodings are insufficient for spectral data. The tokenizer injects a learnable frequency-domain positional encoding (FPE) that encodes the absolute center frequency of each patch. This allows the transformer backbone to understand the ordering of subcarriers or frequency bins. For multi-channel systems, a separate antenna index embedding can be added. This encoding ensures the model distinguishes between identical spectral patterns occurring at different carrier frequencies, a crucial capability for wideband spectrum analysis.
Complex-Valued Token Preservation
For applications requiring phase coherence, such as beamforming or digital pre-distortion, the tokenizer preserves the complex nature of the signal. Instead of separating magnitude and phase into two real channels, the patch embedding and subsequent linear projection operate in the complex domain using complex-valued neural network layers. This preserves the IQ imbalance and phase rotation information that would be lost in a real-valued conversion, enabling the transformer to learn physically meaningful representations of the wireless channel.
Overlapped Patching for Temporal Continuity
To avoid boundary artifacts and capture transient events that fall on patch borders, the tokenizer employs overlapped patching in the time dimension. Adjacent time-frequency patches share a percentage of their temporal bins. This redundancy ensures that a short pulse or frequency hop is fully captured within at least one token. The overlap ratio is a tunable hyperparameter, balancing the trade-off between token sequence length and the risk of missing critical, short-duration signal features.
Hierarchical Multi-Scale Tokenization
A single patch size cannot optimally capture both narrowband tones and wideband bursts. A hierarchical tokenizer generates tokens at multiple resolutions by using different STFT window lengths and patch sizes in parallel. Fine-scale tokens capture rapid micro-Doppler modulations, while coarse-scale tokens represent long-term spectral occupancy. These multi-scale token sequences are fused using cross-attention or concatenated before being fed to the transformer, providing a rich, scale-invariant representation of the electromagnetic environment.
Frequently Asked Questions
Core concepts and operational mechanics behind converting raw electromagnetic waveforms into discrete token sequences for transformer-based signal processing architectures.
A Time-Frequency Tokenizer is a preprocessing module that converts a raw time-series signal into a sequence of discrete tokens, each representing a localized time-frequency patch. The process begins by computing a time-frequency representation—typically a Short-Time Fourier Transform (STFT) or wavelet transform—which maps the 1D waveform into a 2D spectrogram. This spectrogram is then divided into a grid of overlapping or non-overlapping patches, analogous to how a Vision Transformer (ViT) processes images. Each patch is flattened into a vector, projected through a learned linear embedding layer, and combined with a Frequency-Domain Positional Encoding that encodes the temporal and spectral coordinates of the patch. The resulting sequence of token vectors is fed directly into a standard transformer backbone, enabling self-attention mechanisms to model both short-term spectral events and long-range temporal dependencies without requiring specialized recurrent or convolutional inductive biases.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The Time-Frequency Tokenizer is a critical preprocessing bridge between raw signal data and sequence models. The following concepts define the input representations, tokenization strategies, and positional encoding schemes that make this module effective.
Patchified Spectrogram
The primary input representation for a Time-Frequency Tokenizer. A raw spectrogram is divided into a grid of non-overlapping or overlapping 2D patches (e.g., 16x16 time-frequency bins). Each patch is flattened into a 1D vector and projected linearly to create a sequence of spectral tokens for a standard transformer encoder.
- Input: A spectrogram of shape
(F, T). - Process: Reshape into
Npatches of size(P_F, P_T). - Output: A sequence of
Ntoken embeddings. - Key Benefit: Reduces sequence length from
F*TtoN, making self-attention computationally tractable.
Frequency-Domain Positional Encoding
A specialized positional encoding that injects information about a token's absolute frequency index and relative temporal offset into the transformer. Unlike standard sinusoidal encodings for text, this method encodes the physical meaning of the token's location in the time-frequency plane.
- Frequency Encoding: A learned or fixed embedding for each frequency bin index.
- Time Encoding: A standard or rotary positional encoding for the time step.
- Combination: The two encodings are typically summed or concatenated before being added to the patch token.
- Purpose: Allows the model to distinguish a 1 GHz signal from a 2 GHz signal, preserving spectral structure.
Rotary Position Embedding (RoPE) for RF
An application of Rotary Position Embedding to complex-valued or real-valued RF tokens. RoPE encodes relative position by rotating the query and key vectors in the attention mechanism, which is particularly elegant for signals with inherent phase relationships.
- Mechanism: Applies a rotation matrix to token embeddings based on their time or frequency index.
- Relative Encoding: The dot-product attention score naturally depends only on the relative distance between tokens.
- RF Advantage: Preserves the complex-plane geometry of IQ samples and naturally handles the periodic nature of frequency-domain data.
- Use Case: Ideal for tokenizers processing raw IQ sequences or complex-valued spectrogram patches.
Causal Temporal Attention
An attention masking pattern that restricts the self-attention mechanism to only attend to past and present time steps. This is essential when the Time-Frequency Tokenizer is used in a streaming or real-time processing pipeline where future samples are unavailable.
- Mask: A lower-triangular matrix applied to the attention scores.
- Constraint: A token at time
tcan only attend to tokens at times≤ t. - Application: Real-time signal classification, adaptive filtering, and online anomaly detection.
- Contrast: Standard bidirectional attention is used for offline, recorded signal analysis.
Complex-Valued Attention
An extension of the standard attention mechanism that operates natively on complex numbers, preserving both magnitude and phase. When the tokenizer outputs complex-valued tokens (e.g., from raw IQ patches), this attention variant prevents information loss from separating real and imaginary components.
- Complex Dot-Product: Computes attention scores using complex-valued queries and keys.
- Complex Softmax: Applies softmax to the real-valued magnitudes of the complex scores.
- Weighted Sum: Aggregates complex value vectors using the real-valued attention weights.
- Benefit: Maintains the phase coherence critical for physical-layer signal processing tasks like beamforming and equalization.
Autocorrelation Embedding
A learned vector representation derived from the autocorrelation function of a signal segment. This embedding captures periodicities and cyclostationary features—such as symbol rates and carrier offsets—that are not immediately obvious in raw time-frequency patches.
- Pre-computed Feature: The autocorrelation is calculated for each token's corresponding signal segment.
- Embedding: A small neural network projects the autocorrelation vector into a dense embedding.
- Fusion: This embedding is concatenated or added to the standard patch token.
- Discriminative Power: Provides a strong inductive bias for tasks like automatic modulation classification and specific emitter identification.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us