Learn theory in (.txt) Write a paper in markdown of the best AI compression techniques in (.txt) # A Comprehensive Survey of AI Compression Techniques: From Discretization to Neural Representation ## Abstract This paper presents a comprehensive overview of compression strategies for Artificial Intelligence systems, specifically targeting model weights, activations, and structural components. Drawing inspiration from foundational pipelines—such as scalar quantization coupled with lossless index coding—we categorize and detail 100 distinct methodologies. These techniques range from classical signal processing approaches, such as transform coding and entropy reduction, to modern deep learning-specific strategies, including neural implicit representations and hybrid quantization-pruning pipelines. The survey underscores the universal trade-off between storage efficiency and reconstruction fidelity (MSE), offering a taxonomy for researchers and practitioners aiming to optimize model deployment. --- ## 1. Introduction The exponential growth of Deep Neural Network (DNN) parameters has necessitated the development of sophisticated compression techniques. The theoretical underpinning of many modern approaches can be traced to a classic **discretization → indexing → entropy coding** pipeline. In this paradigm: 1. **Discretization**: Continuous values (weights or activations) are mapped to a finite grid. 2. **Indexing**: Values are replaced by integer references (indices) pointing to a lookup table (codebook). 3. **Compression**: These indices are compressed using lossless algorithms (e.g., zlib, Huffman) to minimize storage. This paper explores 100 advanced compression ideas that extend this core philosophy, categorized by their mechanism of action. --- ## 2. Index & Lookup-Based Techniques Index-based methods rely on reducing data complexity by referencing shared codebooks or dictionaries. This is effective for reducing the dimensionality of stored parameters. 1. **Product Quantization (PQ)**: Split vectors into subvectors, each mapped to its own small codebook; store only sub-indices. 2. **Additive Quantization**: Represent vectors as sums of multiple codebook entries; store multiple index streams. 3. **Hierarchical Codebooks**: Use a coarse index to select a region and a fine index to refine precision within it. 4. **K-Means Centroid Indexing**: Cluster flattened weights; store cluster assignments alongside a centroid table. 5. **Hash-Based Weight Sharing**: Hash weight positions to shared indices; compress the hash table and index array. 6. **Pattern Dictionary Compression**: Extract recurring weight submatrices; store a dictionary and tile indices. 7. **Shared Embedding Tables**: Merge low-frequency token embeddings into shared lookup slots; store the mapping. 8. **Attention Mask Index Caching**: Store only active attention positions as compressed integer lists. 9. **Activation Function LUTs**: Replace costly functions (GELU/SiLU) with precomputed 1D lookup tables; compress indices. 10. **Token Embedding Delta Indexing**: Store a base embedding table; encode rare tokens as offsets and indices. --- ## 3. Quantization & Discretization Quantization reduces the precision of numerical values, trading accuracy for size. These methods focus on how values are mapped to discrete levels. 11. **Non-Uniform Log Quantization**: Use logarithmic grid spacing to match heavy-tailed weight distributions. 12. **Mixed-Precision Outlier Handling**: Keep top-1% weights in FP16; quantize the rest to INT4; store separate streams. 13. **Group-Wise Quantization**: Quantize per-channel or per-block; compress scale/zero-point arrays alongside indices. 14. **Stochastic Rounding**: Preserve expected values during quantization; compress deterministic rounding residuals. 15. **Adaptive Bit-Width Layers**: Allocate 2/4/8 bits per layer based on sensitivity; compress variable-width indices. 16. **Ternary Quantization {-1, 0, 1}**: Store signs and zero masks; compress with run-length encoding. 17. **Binary Weight Networks**: Store sign bits; compress magnitude scales per filter or channel. 18. **Block Floating Point**: Use a shared exponent per block; compress mantissa indices and the exponent array. 19. **Dynamic Range Tracking**: Stream quantization parameters; compress parameter deltas across layers. 20. **Error-Bounded Adaptive Quantization**: Adjust grid density to guarantee a maximum MSE; compress the density map and indices. --- ## 4. Entropy & Lossless Coding Once data is discretized or structured, entropy coding minimizes the storage footprint based on statistical probability. 21. **Huffman Coding for Weight Histograms**: Build optimal prefix codes from quantized weight frequencies. 22. **Arithmetic Coding for Indices**: Compress non-uniform index distributions with fractional-bit efficiency. 23. **ANS (Asymmetric Numeral Systems)**: Use fast entropy coding for large index arrays in model checkpoints. 24. **Golomb-Rice for Zero Runs**: Ideal for pruned or sparse weights; compress run lengths efficiently. 25. **CABAC for Weight Signs**: Use context-adaptive binary coding of sign bits based on neighbor patterns. 26. **BWT on Flattened Weights**: Apply Burrows-Wheeler transform to cluster similar values before zlib compression. 27. **LZ77/LZ4 on Serialized Models**: Apply dictionary-based compression on flat weight byte streams. 28. **Predictive Checkpoint Diffs**: Store weights as differences from a base model; compress deltas. 29. **COO/CSR + Entropy Coding**: Compress sparse index/value pairs separately with tailored coders. 30. **Bit-Packing for Low-Bit Indices**: Pack 4-bit indices into uint8 arrays; apply secondary lossless compression. --- ## 5. Sparsity & Pruning Sparsity techniques exploit the redundancy in neural networks by setting weights or activations to zero and storing only the non-zero elements efficiently. 31. **Unstructured Pruning + RLE Masks**: Store binary masks compressed via run-length encoding. 32. **N:M Structured Sparsity**: Enforce 2-of-4 zero patterns; store compact pattern bitmasks. 33. **Dynamic Top-K Activations**: Keep only highest-magnitude activations per layer; store indices and values. 34. **LSH Attention Bucketing**: Compress attention via locality-sensitive hashing bucket indices. 35. **Gradient Top-K Sparsification**: Transmit only largest gradient updates; compress index/value pairs. 36. **MoE Routing Table Compression**: Store sparse expert assignment indices per token. 37. **Layer Skipping Flags**: Use a binary array indicating active layers per input; compress with bit-packing. 38. **Token Pruning Indices**: Store only retained token positions in sequence compression. 39. **Magnitude Thresholding + Delta Encoding**: Keep weights above threshold; compress deltas from baseline. 40. **Lottery Ticket Subnet Paths**: Compress surviving weight coordinates and fine-tuned values. --- ## 6. Low-Rank & Factorization These methods exploit linear algebra to approximate large weight tensors with smaller, composite factors. 41. **Truncated SVD Storage**: Keep top-k singular vectors/values; compress each component stream. 42. **LoRA Adapter Compression**: Store low-rank matrices (A, B) independently; quantize and compress. 43. **Tensor Train (TT) Decomposition**: Factorize weight tensors into cores; compress core arrays. 44. **CP Decomposition**: Represent tensors as a sum of rank-1 components; compress factor matrices. 45. **Kronecker Product Factorization**: Approximate large matrices as Kronecker products of small ones. 46. **Block Low-Rank with Shared Bases**: Multiple blocks share basis vectors; store block coefficients. 47. **Random Projection Embeddings**: Compress embeddings via learned Johnson-Lindenstrauss projections. 48. **Tensor Sketching / Hashed Embeddings**: Map high-dim embeddings to low-dim via hash collisions. 49. **Circulant Matrix Factorization**: Represent weights as circulant shifts; store generating vector and FFT indices. 50. **Toeplitz Approximation**: Compress convolutional kernels via diagonal structures and offsets. --- ## 7. Residual & Differential Encoding Differential methods store the difference between data and a prediction, which often results in smaller magnitudes and better compressibility. 51. **Sequential Delta Encoding**: Store differences between adjacent weights; compress with an entropy coder. 52. **Multi-Scale Residual Quantization**: Use a base layer plus refinement layers; compress each scale separately. 53. **Momentum Residual Gradients**: Compress gradient updates relative to a running average. 54. **Epoch-to-Epoch Checkpoint Diffs**: Store only weight changes between training checkpoints. 55. **Activation Prediction + Residual**: Use a linear predictor from the previous layer; store compressed error. 56. **Layer-Wise Residual Coding**: Predict layer output from input; compress reconstruction error. 57. **Quantization Error Feedback Loops**: Store secondary indices representing quantization residuals. 58. **Inter-Frame Weight Deltas**: For temporal models, compress weight changes across timesteps. 59. **Prompt Embedding Deltas**: Store shifts from base token embeddings; compress delta indices. 60. **Teacher-Student Model Deltas**: Compress only differences between distilled and original models. --- ## 8. Frequency & Transform Domain Transforming data into the frequency domain often concentrates energy, allowing insignificant components to be discarded. 61. **DCT Patch Compression**: Transform image patches to frequency domain; threshold and compress coefficients. 62. **Wavelet Weight Compression**: Apply wavelet transform; keep significant coefficients; compress indices. 63. **Fourier Domain Pruning**: Remove low-energy frequency components from weight matrices. 64. **Hadamard Transform Mixing**: Convert weights to Hadamard domain; exploit sparsity for compression. 65. **Laplacian Pyramid Weight Storage**: Use a multi-resolution representation; compress detail levels. 66. **Sparse Frequency Masking**: Retain only dominant harmonics in embedding spectra. 67. **Spectral Quantization**: Cluster in frequency domain; store spectral indices and inverse transform. 68. **Transform-Domain Entropy Coding**: Model coefficient dependencies for context-adaptive compression. 69. **Block DCT + Run-Length for CNNs**: Adapt standard image compression to activation maps. 70. **Principal Frequency Basis Pruning**: Keep only top principal components in the transform domain. --- ## 9. Structured & Block-Based These techniques organize data into regular structures (blocks) to leverage local correlations and shared properties. 71. **Tiled Weights with Local Scales**: Split matrices into blocks; each has a scale and compressed indices. 72. **Shared Block Dictionaries**: Reuse weight blocks across layers; store block indices and a reuse map. 73. **Hierarchical Block Pruning**: Perform coarse block removal followed by fine-grained pruning within survivors. 74. **Block-Sparse CSR/CSC**: Compress row/col pointers and values separately for block patterns. 75. **ViT Patch Compression**: Group similar patches; store prototype and deviation indices. 76. **Sequence Chunk Context Vectors**: Compress long sequences by sharing context across chunks. 77. **Multi-Head Attention Sharing**: Store unique heads; duplicate via index mapping. 78. **Layer Grouping Compression**: Merge identical layers; store one copy and activation offsets. 79. **Parameter Tying with Offsets**: Use tied weights plus small delta matrices; compress deltas. 80. **Grid-Based Conv Filter Indexing**: Map 2D filters to 1D grid indices; compress spatial patterns. --- ## 10. AI-Native & Neural Compression This category involves using neural networks themselves to learn the compression representations. 81. **Weight Autoencoders**: Train small encoder/decoder networks to compress weight tensors. 82. **Hypernetwork Generation**: Store compact latent code; generate weights on-the-fly via a hypernetwork. 83. **Neural Implicit Weight Reps**: Represent weights as continuous functions (e.g., SIREN); store parameters. 84. **Knowledge Distillation + Compression**: Train a smaller student model; compress the teacher-student delta. 85. **Prompt Summary Tokens**: Replace long contexts with learned compressed tokens; store token indices. 86. **Activation Checkpointing Trade-off**: Store compressed checkpoints; recompute missing activations. 87. **Differentiable Compression Layers**: Train end-to-end with rate-distortion loss for minimal accuracy drop. 88. **RL Bit Allocation**: Use a reinforcement learning agent to optimize bit budget per layer/channel. 89. **Meta-Initialized Compressed Models**: Start from compressed priors; fine-tune with fewer updates. 90. **Federated Update Compression**: Compress client updates via quantization and sparse encoding. --- ## 11. Hybrid & Advanced Techniques Finally, the most effective pipelines often combine multiple modalities or introduce domain-specific logic. 91. **Quantization + Pruning + Entropy Pipeline**: Combine three stages for multiplicative compression gains. 92. **Dynamic Bit-Depth per Variance**: Allocate bits based on activation or weight variance maps. 93. **Cross-Modal Shared Codebooks**: Reuse embedding dictionaries across vision and text encoders. 94. **Streaming Sliding Window Compression**: Compress inference buffers in real-time with overlap. 95. **Learned Compressed Sensing**: Optimize measurement matrices for near-lossless weight recovery. 96. **Topological Pathway Compression**: Store only critical weight paths via graph traversal indices. 97. **Error-Guaranteed Adaptive Grids**: Adjust lookup resolution dynamically to bound reconstruction error. 98. **Multi-Resolution Model Pyramids**: Serve different compressed versions based on bandwidth or device. 99. **Secure Obfuscation + Compression**: Encrypt weight indices before entropy coding for IP protection. 100. **Neighbor-Index Prediction**: Train a tiny model to predict weight indices from spatial neighbors; store prediction errors. --- ## 12. Conclusion The landscape of AI compression is vast, spanning from classical Information Theory to modern Deep Learning research. As demonstrated by the 100 ideas surveyed above, the most effective strategies rarely rely on a single technique. Instead, they utilize hybrid pipelines—combining quantization, pruning, and entropy coding—to achieve significant reductions (>10x) in model size while maintaining performance. The core philosophy remains consistent: discretize continuous information, map it to efficient indices, and encode the result with optimal entropy. Yes, select 3 of these and go into detail # Detailed Analysis of Selected Compression Techniques Following the broad survey of 100 compression methodologies, this section provides an in-depth technical analysis of three selected techniques. These selections represent distinct paradigms in the compression landscape: **Index-Based Quantization** (classical signal processing), **Structural Factorization** (linear algebra), and **Generative Storage** (modern neural rendering). --- ## 1. Product Quantization (PQ) **Category:** Index & Lookup-Based (#1) ### Overview Product Quantization (PQ) is one of the most effective methods for compressing high-dimensional vectors (e.g., embeddings, weight rows) into compact codes. It extends the simple "lookup table" concept mentioned in the introduction to high-dimensional spaces by splitting vectors into subspaces, allowing for a combinatorial explosion in the number of possible representation values without exploding the memory footprint. ### Mechanism The core idea is to decompose a high-dimensional vector $x$ into $m$ distinct subvectors: $$x = [x^1, x^2, \dots, x^m]$$ 1. **Subquantizer Training**: For each subspace $j$ (of dimension $D/m$), a separate codebook $C_j$ is trained using K-Means clustering on the training data. Each codebook contains $k^*$ centroids. 2. **Encoding**: Given a vector $x$, each subvector $x^j$ is mapped to the nearest centroid index $i_j$ in its respective codebook $C_j$. 3. **Storage**: Instead of storing the float values, we store a sequence of indices $[i_1, i_2, \dots, i_m]$. If $k^*=256$ (8-bit indices), the storage for the subvector is simply 1 byte. ### Compression Ratio The power of PQ lies in its combinatorial nature. While the codebook effectively represents $k^m$ distinct centroids, we only store $m \times \log_2(k)$ bits. - **Example**: Compressing a 1024-dimensional `float32` vector using $m=8$ subvectors and $k=256$ centroids. - **Original Size**: $1024 \times 32 \text{ bits} = 32,768 \text{ bits}$. - **Compressed Size**: $8 \text{ subvectors} \times 8 \text{ bits} = 64 \text{ bits}$. - **Compression Factor**: $512\times$. ### Trade-offs - **Pros**: Massive compression ratios; efficient approximate nearest neighbor search (ANN) via Asymmetric Distance Computation (ADC). - **Cons**: Reconstruction error can be non-trivial. It introduces "boundary artifacts" where values straddling the split points between subvectors lose correlation context. --- ## 2. Truncated SVD & LoRA Adapter Compression **Category:** Low-Rank & Factorization (#41 & #42) ### Overview Singular Value Decomposition (SVD) exploits the inherent redundancy in weight matrices. Deep Neural Networks are often over-parameterized, meaning their weight matrices are "low-rank"—they effectively operate in a subspace much smaller than their full dimensionality. Truncated SVD provides a mathematically optimal low-rank approximation, while techniques like LoRA (Low-Rank Adaptation) utilize this structure for efficient fine-tuning and storage. ### Mechanism Given a pre-trained weight matrix $W \in \mathbb{R}^{d \times k}$, SVD factorizes it into: $$W = U \Sigma V^T$$ where $U$ and $V$ are orthogonal matrices and $\Sigma$ contains singular values sorted by magnitude. 1. **Truncation**: We keep only the top $r$ singular values ($r \ll \min(d, k)$). 2. **Reconstruction**: The original matrix $W$ is approximated by $\tilde{W} = U_r \Sigma_r V_r^T$. 3. **Storage Optimization**: Instead of storing $d \times k$ parameters, we store the two smaller matrices $A = U_r \Sigma_r^{1/2}$ and $B = \Sigma_r^{1/2} V_r^T$. ### Application in AI (LoRA) In modern Large Language Models (LLMs), Low-Rank Adaptation (LoRA) freezes the pre-trained weights $W_0$ and injects trainable rank-decomposition matrices $A$ and $B$ such that the update is $\Delta W = BA$. - **Compression Context**: While LoRA is often discussed for training, it acts as a compression technique for "adapters." Instead of storing a full fine-tuned model delta (which is dense and large), one stores the low-rank matrices $A$ and $B$. - **Hybrid Approach**: One can further quantize the $A$ and $B$ matrices (e.g., using 4-bit quantization) to create "QLoRA" checkpoints, achieving extreme compression of task-specific knowledge. ### Trade-offs - **Pros**: Preserves global structure well; mathematically grounded; improves inference speed if optimized for matrix multiplication order. - **Cons**: Truncation discards the "tail" of singular values, which often corresponds to high-frequency features or rare knowledge, potentially degrading performance on outlier tasks. --- ## 3. Neural Implicit Weight Representations **Category:** AI-Native & Neural Compression (#83) ### Overview This represents a paradigm shift from *explicit storage* (storing the grid of numbers) to *implicit storage* (storing the function that generates the numbers). Instead of a weight matrix $W$ being stored in memory, a small neural network (often a Multi-Layer Perceptron or MLP) is trained to output the weight value at a specific coordinate index. ### Mechanism Imagine a convolutional kernel or a weight matrix. We can view the indices $(i, j)$ as coordinates and the weight value $w_{ij}$ as the signal value at that coordinate. 1. **Coordinate-Based MLP**: We define a small neural network $f_\theta$ (parameters $\theta$). 2. **Overfitting**: We train $f_\theta$ to minimize the reconstruction loss: $$ \mathcal{L} = \sum_{(i,j)} || f_\theta(i, j) - w_{ij} ||^2 $$ The network inputs are the coordinate embeddings (e.g., Fourier features or positional encodings), and the output is the scalar weight value. 3. **Storage**: We discard the original weight matrix $W$. We only store the parameters $\theta$ of this small generator network. ### Compression Logic If a weight matrix is $1000 \times 1000$ (1 million parameters), storing it in FP32 requires 4MB. If we can fit a small MLP with, for instance, 2 hidden layers of 64 neurons each, the parameter count of the generator is tiny: - Input dim: 2 (coordinates) $\to$ Hidden: 64 $\to$ Hidden: 64 $\to$ Output: 1. - Total params $\approx 2\times64 + 64\times64 + 64\times1 \approx 4,300$ parameters. - **Compression**: 4,300 params vs 1,000,000 params ($>200\times$ compression). ### Trade-offs - **Pros**: Extreme compression ratios for smooth or structured weight distributions; naturally resolution-agnostic (weights can be queried at fractional indices). - **Cons**: Inference overhead (computing weights via MLP is slower than a simple memory read); training the compressor is computationally expensive; difficult to compress "noisy" or random weights (random initialization) effectively.