Lesson 3.3
Reconstruction error
Decode a PQ code by stitching its chunk representatives back together. How far the result sits from the original is the error you traded for the space.
Stitching the representatives back
To decode a PQ code (the row of bytes encoding produced last lesson) means to reverse the encoding and recover a vector: look up each chunk's index in its codebook and paste the representatives back together in order. The result is a vector shaped like the original but built from a small set of stock pieces, so it never matches exactly. The distance between the two is the reconstruction error, and it is the price you paid in accuracy for the small code.
The demo uses the simplest possible representative, a chunk's average, so you can watch the idea cleanly. The grey line is the original; the coral line is the reconstruction. Add chunks and the coral line hugs the grey one, while the error falls and the byte count rises.
More chunks, closer reconstruction, smaller error
3 chunks · error 0.08 · 3 bytes
Reconstruction error is how far the decoded vector sits from the original. More chunks lower it; fewer chunks compress harder and raise it.
Debug the codebook, not the search
Reconstruction error is a gift when you are building this: it tests the codebooks completely on their own, before any search is involved. If the error does not shrink as you add chunks, or as you give the codebooks more entries, something is wrong with the quantizer itself. Get this curve healthy first, then move on to using the codes for search.
Predict it
In the demo, M = 1 means one chunk covering all 12 numbers with a single representative. Before you click it, what should the reconstruction look like, and why is its error the worst of all the settings?
Key takeaways
Decoding pastes each chunk's representative back together; the gap from the original is the reconstruction error.
More chunks (or richer codebooks) lower the error, at the cost of more stored bytes.
Reconstruction error tests the codebook alone, so debug it before bringing search into the picture.