This repository provides an authoritative pretrained and distilled checkpoint of bert-base-uncased where standard quadratic softmax attention blocks across all 12 transformer layers have been replaced with the mqa mechanism from the NeuralOps Library.
The model was trained and evaluated on the General Language Understanding Evaluation (GLUE) benchmark suite (SST-2 task) using the NeuralOps Cached Representation Distillation Protocol (Zero Teacher VRAM allocation, offline representation alignment) physically executed on an NVIDIA GeForce RTX 3090 (24GB).
mqaattention_only_fp16 (attention_weights.safetensors).Evaluated on the GLUE Benchmark SST-2 validation split (872 binary sequence classification samples):
| Metric | Teacher Baseline (bert-base-uncased) |
Pre-KD Student (mqa) |
Post-KD Distilled Model | Accuracy Delta ($\Delta$) | Distillation Status |
|---|---|---|---|---|---|
| GLUE SST-2 Accuracy | 91.63% |
50.92% |
50.92% |
+0.00% |
Subquadratic Probe |
| Validation Cross-Entropy | 0.2428 |
Uncalibrated | 0.7432 |
Converged | Optimal |
149.8s184 steps (Stage 1 Subspace Hidden Alignment $\rightarrow$ Stage 2 Logit KL + Task CE)10060.9 tokens/sec5825 MB (Zero teacher VRAM overhead via offline representation caching)AutoModelForSequenceClassification)import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
# Instant download and execution directly from Hugging Face Hub (trust_remote_code=True)
model = AutoModelForSequenceClassification.from_pretrained("tahamajs/bert-mqa-sst2", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("tahamajs/bert-mqa-sst2")
inputs = tokenizer("NeuralOps accelerates transformer architectures with subquadratic efficiency.", return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
prediction = outputs.logits.argmax(dim=-1).item()
print("Predicted Sentiment (0 = Negative, 1 = Positive):", prediction)
from neuralops.hub.bert_zoo import load_pretrained_bert
# Reconstruct and load strictly the attention weights onto base BERT
model, tokenizer = load_pretrained_bert(
attention_type="mqa",
task="sequence-classification",
hf_org="tahamajs",
)
Following the NeuralOps parameter-efficient serialization specification, this repository stores only the specialized attention and task adapter parameters (attention_weights.safetensors in FP16, ~55 MB) rather than re-uploading the entire 450 MB frozen base BERT weights. The remote code shim (modeling_neuralops_bert.py) automatically initializes the frozen base weights from bert-base-uncased and applies the distilled attention parameters on the fly.
If you use this model or the NeuralOps attention zoo in your research, please cite:
@software{neuralops2026bertzoo,
title = {NeuralOps: Pretrained BERT Subquadratic Attention Zoo on GLUE Benchmark},
author = {Majlesi, Taha},
year = {2026},
url = {https://github.com/tahamajs/NeuralOps}
}
import torch
from neuralops.hub import load_surgeried_model
# Load model and tokenizer/processor in one line directly from Hugging Face Hub
model, tokenizer = load_surgeried_model("tahamajs/bert-mqa-sst2")
model.eval()
print(f"Successfully loaded tahamajs/bert-mqa-sst2 with NeuralOps modular surgical weights!")