CoolFace
Modelpublic

rudrakshrakeshzodage/nllb-200-distilled-600M-int8-cpu

sourceHugging Facecc-by-nc-4.0updated 2mo agoView on Hugging Face
0likes15downloads
Model Card

NLLB-200 Distilled 600M โ€” INT8 CPU Quantized (PyTorch Dynamic)

[!NOTE] ๐ŸŒ Live Web Demo: Try 100% offline in your browser at `huggingface.co/spaces/rudrakshrakeshzodage/nllb-200-onnx-browser-demo`
[!NOTE] This model is part of a suite of optimized/quantized versions of the base model. Other variants in this direction: FP32 (Full Precision / Base): [`facebook/nllb-200-distilled-600M`](https://huggingface.co/facebook/nllb-200-distilled-600M) FP16 (Half Precision): `facebook/nllb-200-distilled-600M` INT8 (Dynamic Quantization - CPU): [`rudrakshrakeshzodage/nllb-200-distilled-600M-int8-cpu`](https://huggingface.co/rudrakshrakeshzodage/nllb-200-distilled-600M-int8-cpu) (Current) NF4 (4-bit GPU Quantization): `rudrakshrakeshzodage/nllb-200-distilled-600M-nf4-4bit-gpu`

Base model: `facebook/nllb-200-distilled-600M` Quantization: PyTorch INT8 Dynamic (torch.quantization.quantize_dynamic) Languages: 200 (all NLLB-200 supported languages)


๐Ÿ’พ Model Size Reduction Comparison (FP32 vs FP16 vs INT8 vs NF4)

[image]

๐Ÿ“ˆ 200+ Language Performance Benchmark Chart

[image]

Quantization Architecture Details

  • โ€”Target Layers: torch.nn.Linear inside Encoder & Decoder Self-Attention / FFN modules.
  • โ€”Weight Precision: qint8 (8-bit signed integers).
  • โ€”Activation Quantization: Calculated dynamically at inference runtime per batch.
  • โ€”No GPU Needed: Optimized for x86 CPU SIMD / AVX2 / AVX-512 instructions.

๐Ÿ“Š Model Performance & Benchmarks

MetricINT8 Dynamic (CPU)FP16 Base (CPU)Speedup / Savings
RAM Footprint~800 MB~2,400 MB66.7% RAM reduction
Avg Latency (Per Lang)~1,097 ms~3,950 ms3.6ร— Faster
Throughput55 languages / min~15 languages / min3.6ร— Higher
200-Lang Benchmark Run~3.7 minutes~13.3 minutes9.6 min saved
Loop Anomalies0 โœ…1 (Central Kanuri)Fully stable
BLEU Score (vs FP16)~42.0~42.1< 0.1 BLEU loss

๐Ÿ’ป Hardware Requirements

  • โ€”CPU: Intel Core i3 (10th Gen+), AMD Ryzen 3 (3000U+), Apple Silicon (M1+)
  • โ€”RAM: 4 GB System RAM minimum (800 MB active model memory)
  • โ€”GPU: None required (100% CPU inference)

๐Ÿš€ Usage

python
import torch
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

# Load base architecture
model = AutoModelForSeq2SeqLM.from_pretrained(
    "facebook/nllb-200-distilled-600M"
)

# Apply PyTorch INT8 Dynamic Quantization
model = torch.quantization.quantize_dynamic(
    model, {torch.nn.Linear}, dtype=torch.qint8
)

tokenizer = AutoTokenizer.from_pretrained(
    "YOUR_USERNAME/nllb-200-distilled-600M-int8-cpu"
)

# Translate English to Hindi (hin_Deva)
inputs = tokenizer("Hello world, how are you?", return_tensors="pt")
translated_tokens = model.generate(
    **inputs, 
    forced_bos_token_id=tokenizer.lang_code_to_id["hin_Deva"], 
    max_length=100
)
print(tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0])

๐Ÿ“œ Citation & Credits

Quantization research and benchmarking by RudrakshRakeshZodage.