--- license: apache-2.0 tags: - quantization - binary-neural-network - ternary-weights - knowledge-distillation - gradio --- # BitForge 1-bit BitForge trains and compares a full-precision digit classifier, a strict one-bit weight model, and a ternary-weight model. The low-bit students use straight-through quantization during training and learn from both labels and the full-precision teacher's softened output distribution. The binary deployment artifact stores each matrix weight as one packed sign bit, plus one floating-point scale per output channel and floating-point biases. The project reports both classification accuracy and the measured inference payload. Activations, scales, and biases remain floating point, so this is specifically a one-bit **matrix-weight** experiment rather than a claim that every operation or parameter is one bit. ## Verified results | Variant | Test accuracy | Accuracy change | | --- | ---: | ---: | | FP32 teacher | 95.78% | reference | | Packed binary matrix weights | 94.22% | -1.56 points | | Ternary matrix weights | 95.11% | -0.67 points | Each network has 4,810 parameters, including 4,736 matrix weights. The measured inference payload fell from 19,240 bytes for FP32 parameters to 1,184 bytes for packed signs, per-channel scales, and biases, a 16.25 times reduction. The `.npz` container itself is 3,270 bytes because it also carries names, shapes, and archive metadata. An independent reload of the packed signs reproduced 94.22% accuracy. ## Reproduce ```powershell uv run python projects/bitforge-1bit/train.py ```