Quantization reduces the memory footprint of neural networks by replacing high-precision weights with smaller integers. In a standard 16-bit format, a model with seven billion weights occupies 14 gigabytes of memory. By converting these weights to 4-bit integers, the memory usage is reduced by a factor of four.
The process involves dividing weights by a scale factor and rounding the result to the nearest integer. The scale is determined by dividing the maximum absolute weight value by the maximum allowed integer value for the given bit depth. This technique allows models to run on hardware with limited memory, such as laptops.
Beyond memory savings, quantization accelerates model inference. Because modern processors perform calculations faster than memory can supply data, reducing the bit depth per weight decreases the amount of data transferred, thereby shortening wait times during text generation.
Tests on a neural network trained on the MNIST dataset show that reducing precision to 8 or 6 bits does not impact accuracy. At 5 bits, accuracy drops by 0.4 percentage points, while at 4 bits, the decline is less than 2 percentage points. At 3 bits, accuracy falls by 5 percentage points, and at 2 bits, the model's performance becomes nearly random.






