Factorized Random Synthesizer
- Factorized Random Synthesizer is a Transformer variant that replaces standard Q/K projections with a low-rank factorization of a learned alignment matrix.
- It achieves significant parameter savings by decomposing the full attention matrix into two smaller matrices while retaining competitive empirical performance.
- Empirical results show that low-rank approximations recover nearly full performance on tasks like machine translation and language modeling, despite being about 0.4 BLEU or 2 PPL behind vanilla Transformers.
A Factorized Random Synthesizer is a variant of the Synthesizer architecture that replaces the standard self-attention mechanism in Transformers with a synthetic attention pattern generated by low-rank, trainable matrices. Unlike dot-product attention, which computes attention weights via token-token (query-key) interactions, the Factorized Random Synthesizer employs a low-rank decomposition of a learned alignment matrix, resulting in reduced parameter costs while maintaining competitive empirical performance across diverse tasks such as machine translation, language modeling, and encoding benchmarks (Tay et al., 2020).
1. Mathematical Formulation
The standard Transformer self-attention employs query (), key (), and value () projections:
- , , for input (sequence of length and model dimension ).
- Attention weights: .
- Output: 0.
The (full) Random Synthesizer omits 1 and 2, introducing instead a learned alignment matrix 3:
- Attention: 4 (row-wise).
- Output: 5.
In the Factorized Random Synthesizer, 6 is approximated via a low-rank factorization:
7
The resultant attention weights and output are:
8
This replaces the 9 parameter matrix with two 0 matrices (1 parameters per head).
2. Architectural Differences and Parameter Analysis
Compared to the vanilla Transformer:
- Standard attention head (per-head dimension 2) requires 3 parameters for 4 projections.
- Full Random Synthesizer head forgoes 5, adds 6 trainable parameters for 7.
- Factorized Random Synthesizer head forgoes 8, adds 9 parameters for 0.
- In both Synthesizer variants, the 1 projection (dimension 2), output projection, and feed-forward sublayers are unchanged.
Relative to baseline, the factorized variant decreases parameter count (saving the 3 projections), trading it for low-rank factor parameters. When 4, the reduction is substantial.
| Method | Project Q/K | Alignment Matrix | #Parameters (per head) |
|---|---|---|---|
| Vanilla Self-Attention | Yes | None | 5 |
| Full Random Synthesizer | No | 6 | 7 |
| Factorized Random Synthesizer | No | 8 | 9 |
3. Complexity Analysis
Let 0 and 1:
- Dot-product Attention: Time 2 (for 3 and 4), memory 5 for 6, parameters 7.
- Full Random Synthesizer: Time 8, identical memory, parameters 9.
- Factorized Random Synthesizer: Forms 0 (1), softmax, multiply 2 (3); total 4.
- If 5 is not stored but contractively applied, memory/time can reduce to 6 and 7, though the reference implementation does not exploit this.
The factorized form maintains 8 time/memory complexity when 9 is small relative to 0, but with lower parameter cost.
4. Empirical Performance Across Tasks
The Factorized Random Synthesizer mirrors the full random variant's performance with much lower parameter overhead:
- Machine Translation (WMT’14 En→De, En→Fr; BLEU): Factorized Random (r=8) yields 27.30 (EnDe) and 41.12 (EnFr), nearly matching full random (27.27/41.12) and falling ~0.4 BLEU below vanilla Transformer (27.67/41.57).
- Language Modeling (LM1B, PPL): Factorized Random (r=8) PPL=42.40, versus full random 40.60, and vanilla 38.21; thus, 12 PPL worse than vanilla.
- Masked LM on C4: Full Random Synthesizer achieves log PPL=1.972 at 4.26 steps/sec (about 60% faster than Dynamic Convolution, which gets log PPL=2.040 at 2.65 steps/sec).
- Multi-task Fine-tuning (GLUE/SuperGLUE): Pure Random or Dense Synthesizers underperform on cross-sentence tasks due to lack of cross-attention mechanisms, but mixture models (Random+Vanilla, Dense+Vanilla) outperform base T5 (e.g., GLUE: T5=83.5, +Random+Vanilla=84.1; SuperGLUE: T5=70.3, +Random+Vanilla=72.2).
- Encoding Tasks/Comparison to Linformer: On AG News and MR Reviews (Linformer at 2 yields 86.50%/82.86%), Factorized Random (r=32) matches or slightly exceeds (86.53%/83.39%).
These results indicate that for a wide range of tasks, low-rank Synthesizers achieve competitive or superior results to efficient attention baselines such as Dynamic Convolution and Linformer, with similar or improved speed (Tay et al., 2020).
5. Effect of Factorization Rank and Learned Patterns
Empirical ablations varying rank 3 show minor performance degradation up to 4 or 5; at 6, nearly the full performance of full-rank random Synthesizer is recovered. Visualizations demonstrate that, following training, the learned 7 matrices exhibit both local and global alignment patterns analogous to those produced by dot-product attention. This suggests that low-rank random attention can spontaneously capture structurally meaningful alignments. Mixture models that combine small amounts of Dense Synthesizer or vanilla self-attention restore or exceed base Transformer performance, underscoring that the factorized global structure is the principal contributor to alignment (Tay et al., 2020).
6. Limitations and Observed Constraints
Pure Random and Dense Synthesizer models (lacking 8) underperform on cross-sentence tasks, reflecting their inability to model certain long-range dependencies when cross-attention is required. Mixture architectures mitigate this deficiency. Since the reference implementation does not exploit memory-efficient computation exploiting low-rank structure for 9, memory and time complexity remain 0 for long sequence lengths, although parameter savings are realized. A plausible implication is that specialized kernels leveraging factorization could further scale efficiency for extreme 1.
7. Relationship to Efficient-Attention and Transformer Variants
The factorized random approach contrasts with other efficient-attention architectures by decoupling attention construction from input-dependent (2) products, instead generating synthetic alignment through learned low-rank interactions. Compared to Linformer, which projects key/value matrices along the sequence axis to reduce sequence length, and Dynamic Convolution, which uses localized convolutions, the Factorized Random Synthesizer achieves similar or better accuracy and throughput on encoding-based tasks. Compositional variants—combining factorized random with dot-product attention—consistently surpass Transformer and alternative baselines in aggregate benchmarks, as evidenced by improvements on GLUE/SuperGLUE (Tay et al., 2020).