Base model: distilbert/distilbert-base-uncased-finetuned-sst-2-english. This export uses INT8 asymmetric per-channel weight-only quantization. Asymmetric mode stores clamped INT8 zero points; symmetric mode uses an implicit zero point of 0. Stored weights use INT8; scales, biases, embeddings, normalization and final classifier remain FP32. Activations and multiplication use FP32. No retraining or pre-built quantization library was used.
Constraint: at least 45% smaller FP32 checkpoint, with at most 1.0 percentage point validation accuracy loss. Evaluated on 872 SST-2 validation examples; maximum token length 128. Winner chosen using these same validation results, not an independent test set.
| Configuration | MiB | Saved % | Weight RMSE | Accuracy % | Drop pp | ms/batch |
|---|---|---|---|---|---|---|
| FP32 | 255.45 | 0.00 | 0.000000 | 91.06 | 0.00 | 1216.7 |
| INT8 symmetric per-tensor | 132.28 | 48.22 | 0.006735 | 90.60 | 0.46 | 1278.3 |
| INT8 symmetric per-channel | 132.44 | 48.15 | 0.000484 | 90.94 | 0.11 | 1374.4 |
| INT8 symmetric per-group | 134.84 | 47.21 | 0.000276 | 91.06 | 0.00 | 1421.4 |
| INT8 asymmetric per-tensor | 132.29 | 48.21 | 0.004422 | 90.37 | 0.69 | 1347.0 |
| INT8 asymmetric per-channel | 132.49 | 48.13 | 0.000405 | 91.06 | 0.00 | 1547.9 |
| INT8 asymmetric per-group | 135.50 | 46.96 | 0.000242 | 91.06 | 0.00 | 1443.1 |
Size is the serialized weights/scales checkpoint, excluding tokenizer/config files. CPU timing uses a fixed 8-example, 128-token batch, 2 warm-ups and 7 measured runs with 2 threads; it excludes tokenization and includes reconstruction. It does not measure peak RAM or promise an INT8 compute speedup. See measurements.json for environment and revision details.
Install torch==2.5.1 and transformers==4.48.3. Download this model repository as a folder. Read the included quantizer.py, put it on your Python path, and use:
from quantizer import load_quantized
from transformers import AutoTokenizer
import torch
folder = "path/to/downloaded/model-folder"
model = load_quantized(folder)
tokenizer = AutoTokenizer.from_pretrained(folder, local_files_only=True)
inputs = tokenizer("I enjoyed this movie!", return_tensors="pt")
with torch.inference_mode():
label = model(**inputs).logits.argmax(-1).item()
print(model.config.id2label[label])
Standard AutoModel.from_pretrained does not load this custom checkpoint directly. The loader builds random FP32 layers before replacing them, so loading has temporary memory overhead. The model is for inference, not training.
Short English positive/negative sentiment only. Accuracy on SST-2 does not establish quality on other domains or languages. Small validation accuracy differences have sampling uncertainty. Floating-point reconstruction may reduce inference speed. The source model's limitations still apply.
Original model: DistilBERT fine-tuned on SST-2, distributed by the DistilBERT authors under Apache-2.0. This repository adds a custom quantized representation and loader. See the original model card for its training and distillation details.