Skip to content

About

Machine Learning Model Compression techniques

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

model_compression_2026

Python 3.11 PyTorch 2.14.1 scikit-learn 1.9.1 pandas 3.1.0 NumPy 2.5.4 Docker Compose

A simple Model Compression Lab.

Overview

Train one large baseline Multilayer Perceptron (MLP) on a randomized CSV dataset, then shrink it with four techniques and compare size, accuracy, and latency:

Technique What it does File
Dynamic range quantization int8 weights; activations quantized at inference from their observed range (no calibration data) quantization.py
Weight pruning Global magnitude pruning at several sparsities, with and without masked fine-tuning pruning.py
Model distillation Small student trained on a teacher's softened logits vs. hard labels only distillation.py
Dimensionality reduction PCA input compression (64 → 32/16/8/4 features) dimensionality_reduction.py

Stages run sequentially: generate data → train baseline → each technique. Models are written to lab/models, results to lab/metrics (CSV + JSON).

Use

docker compose up

What to look for

  • Quantization: ~3.8x smaller, accuracy nearly unchanged. Dynamic quantization is simulated in float (portable); real latency gains need an int8 kernel.
  • Pruning: accuracy collapses at high sparsity before fine-tuning and largely recovers after. Sparse weights only shrink the file once compressed (gzip_size_kb) or stored in a sparse format.
  • Distillation: the student has ~1.7% of the teacher's parameters; distillation gives a modest edge over hard labels only (small and seed-dependent).
  • Dimensionality reduction: 16 components keep ~97.6% variance with no accuracy loss; 8 or fewer drop sharply. Note the parameter savings are small since only the first layer shrinks.

Generated data, models, and metrics are included for study; they are recreated on each run.

The above frequently show up in the GCP PMLE but there aren't that many hands-on labs for these in skills.google.

Resources and Links

  1. https://www.skills.google/

About

Machine Learning Model Compression techniques

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages