How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("fill-mask", model="priyaganesh2050/bert-tiny")
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("priyaganesh2050/bert-tiny", device_map="auto")
Quick Links

bert-tiny (mirror)

A 2-layer, 128-hidden BERT — about 4.4M parameters / 17 MB. Small enough to fine-tune on a laptop CPU in minutes, which makes it the go-to model for smoke tests, CI pipelines, unit tests for training code, and edge deployment.

This is a mirror. The weights and tokenizer files here are an unmodified copy of prajjwal1/bert-tiny, re-hosted on this profile for reproducibility and convenience. All credit for the original work belongs to its authors. The upstream license (mit) is preserved and applies to this copy. If you need the canonical version, please use the upstream repository.

Specs

Layers 2
Hidden size 128
Attention heads 2
Parameters ~4.4M
Vocab 30,522 (uncased WordPiece)
Disk ~17 MB

Usage

from transformers import AutoTokenizer, AutoModel

tok = AutoTokenizer.from_pretrained("priyaganesh2050/bert-tiny")
model = AutoModel.from_pretrained("priyaganesh2050/bert-tiny")

out = model(**tok("A tiny BERT for fast experiments.", return_tensors="pt"))
print(out.last_hidden_state.shape)   # torch.Size([1, 9, 128])

Fine-tuning for classification:

from transformers import AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained("priyaganesh2050/bert-tiny", num_labels=2)

When to use this

  • Good for: CI/CD tests of training loops, hyperparameter search, teaching, edge/mobile, latency-critical baselines.
  • Not good for: accuracy-sensitive production NLP. A 2-layer model gives up a lot of quality versus bert-base. Use it as a baseline, then scale up.

Citation

The tiny BERT variants come from the well-read-students line of work:

@misc{turc2019,
  title  = {Well-Read Students Learn Better: On the Importance of Pre-training Compact Models},
  author = {Turc, Iulia and Chang, Ming-Wei and Lee, Kenton and Toutanova, Kristina},
  year   = {2019},
  eprint = {1908.08962},
  archivePrefix = {arXiv}
}
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for priyaganesh2050/bert-tiny

Finetuned
(97)
this model

Space using priyaganesh2050/bert-tiny 1

Paper for priyaganesh2050/bert-tiny