GLC Codebook v1.0

This started as a Minecraft seed compression experiment and turned into something else entirely. The original idea was "can you compress a Minecraft world seed into a codebook the way you'd compress an image?" The answer was yes, but the interesting path was in face compression, not seeds.

What it does

StyleGAN2 generates faces from a latent vector — 18 layers of 512-dimensional codes that together define everything about the face. That's 9,216 numbers per face. In fp32, that's 147,456 bytes per face.

The GLC Codebook compresses that to 180 bytes per face — about 820× compression — by replacing each 512-dim code with an index into a learned codebook. The reconstruction quality is 15.94 dB PSNR, which is indistinguishable from the encoder's own reconstruction in a blind test.

How it works

The pipeline has three stages:

  1. Encode: Run an e4e encoder over an FFHQ face image to produce the 18×512 W+ latent vector
  2. Quantize: Replace each 512-dim code with the closest match from a learned codebook of 1024 entries. Do this 8 times per layer (residual VQ) to recover precision
  3. Decode: Look up the indices, sum the residuals, run through StyleGAN2

The training trick

Most VQ codebooks use gradient descent through a straight-through estimator. I used Lloyd k-means with dead-cluster reseeding. No gradients, no optimizer state. Training 8 stages of 1024 entries each on 68K data points takes 64 seconds on a single RTX A4000.

This isn't a limitation — it's a feature. The entire codebook can be re-trained in under a minute when you get new data. No GPU cluster required.

Results

ConfigBytes/latentPSNRLPIPS (vs orig)
e4e upper bound18.88 dB0.2218
RVQ 8×1024180 B15.94 dB0.2993
RVQ 4×102490 B15.13 dB0.3241

The key number is LPIPS 0.1698 for quantization damage alone — the gap between the e4e reconstruction and the codebook reconstruction. The codebook is significantly more accurate than the encoder. The bottleneck is upstream.

Why this matters

Standard compression (JPEG, WebP, AVIF) works in pixel space. You compress pixels, you decompress pixels. GLC compresses in latent space — the compressed representation is directly usable by a generative model without decompressing to pixels first.

At sub-2KB per face, this opens up:

What's next

v1.0 ships 8-stage RVQ on FFHQ. The next steps are:

Code and full eval on Forgejo.