The boltuix/bert-mid model is a compact BERT variant designed for natural language processing tasks requiring well-rounded performance with moderate resource demands. Pretrained on English text using masked language modeling (MLM) and next sentence prediction (NSP) objectives, it is optimized for fine-tuning on a variety of NLP tasks, including sequence classification, token classification, and question answering. With a size of ~50 MB, it offers a balanced solution for applications needing solid accuracy and efficiency, ideal for mid-tier deployments.
Model Details
Model Description
The boltuix/bert-mid model is a PyTorch-based transformer model derived from TensorFlow checkpoints in the Google BERT repository. It builds on research from On the Importance of Pre-training Compact Models (arXiv) and Generalization in NLI: Ways (Not) To Go Beyond Simple Heuristics (arXiv). Ported to Hugging Face, this uncased model (~50 MB) is engineered for mid-tier NLP applications, such as sentiment analysis, named entity recognition, and natural language inference, making it suitable for developers and researchers seeking a cost-effective, balanced model.
Developed by: BoltUIX
Funded by: BoltUIX Research Fund
Shared by: Hugging Face
Model type: Transformer (BERT)
Language(s) (NLP): English (en)
License: MIT
Finetuned from model: google-bert/bert-base-uncased
BoltUIX offers a range of BERT-based models tailored to different performance and resource requirements. The boltuix/bert-mid model is a well-rounded mid-tier option, ideal for applications needing balanced accuracy and efficiency. Below is a summary of available models:
Tier
Model ID
Size (MB)
Notes
Micro
boltuix/bert-micro
~15 MB
Smallest, blazing-fast, moderate accuracy
Mini
boltuix/bert-mini
~17 MB
Ultra-compact, fast, slightly better accuracy
Tinyplus
boltuix/bert-tinyplus
~20 MB
Slightly bigger, better capacity
Small
boltuix/bert-small
~45 MB
Good compact/accuracy balance
Mid
boltuix/bert-mid
~50 MB
Well-rounded mid-tier performance
Medium
boltuix/bert-medium
~160 MB
Strong general-purpose model
Large
boltuix/bert-large
~365 MB
Top performer below full-BERT
Pro
boltuix/bert-pro
~420 MB
Use only if max accuracy is mandatory
Mobile
boltuix/bert-mobile
~140 MB
Mobile-optimized; quantize to ~25 MB with no major loss
The model can be used directly for masked language modeling or next sentence prediction tasks, such as predicting missing words in sentences or determining sentence coherence, delivering balanced accuracy in these core tasks.
Downstream Use
The model is designed for fine-tuning on a range of downstream NLP tasks, including:
Natural language inference (e.g., MNLI, RTE)
It is recommended for developers, researchers, and small-to-medium enterprises seeking a mid-tier NLP model with solid performance and efficient resource usage.
Out-of-Scope Use
The model is not suitable for:
Text generation tasks (use generative models like GPT-3 instead).
Non-English language tasks without significant fine-tuning.
High-performance applications requiring maximum accuracy (use boltuix/bert-large or boltuix/bert-pro instead).
Bias, Risks, and Limitations
The model may inherit biases from its training data (BookCorpus and English Wikipedia), potentially reinforcing stereotypes, such as gender or occupational biases. For example:
python
1from transformers import pipeline
2unmasker = pipeline('fill-mask', model='boltuix/bert-mid')3unmasker("The man worked as a [MASK].")
Output:
json
1[2{'sequence': '[CLS] the man worked as a engineer. [SEP]', 'token_str': 'engineer'},3{'sequence': '[CLS] the man worked as a doctor. [SEP]', 'token_str': 'doctor'},4 ...
5]
unmasker("The woman worked as a [MASK].")
Output:
json
1[2{'sequence': '[CLS] the woman worked as a teacher. [SEP]', 'token_str': 'teacher'},3{'sequence': '[CLS] the woman worked as a nurse. [SEP]', 'token_str': 'nurse'},4 ...
5]
These biases may propagate to downstream tasks. Due to its size (~50 MB), the model is suitable for many devices but may still require optimization for ultra-constrained environments.
Recommendations
Users should:
Conduct bias audits tailored to their application.
Fine-tune with diverse, representative datasets to reduce bias.
Apply model compression techniques (e.g., quantization, pruning) for deployment on resource-constrained devices.
How to Get Started with the Model
Use the code below to get started with the model.
python
1from transformers import pipeline, BertTokenizer, BertModel
23# Masked Language Modeling4unmasker = pipeline('fill-mask', model='boltuix/bert-mid')5result = unmasker("Hello I'm a [MASK] model.")6print(result)78# Feature Extraction (PyTorch)9tokenizer = BertTokenizer.from_pretrained('boltuix/bert-mid')10model = BertModel.from_pretrained('boltuix/bert-mid')11text ="Replace me by any text you'd like."12encoded_input = tokenizer(text, return_tensors='pt')13output = model(**encoded_input)
Training Details
Training Data
The model was pretrained on:
BookCorpus: ~11,038 unpublished books, providing diverse narrative text.
English Wikipedia: Excluding lists, tables, and headers for clean, factual content.
Accuracy: For classification tasks (e.g., MNLI, SST-2)
F1 Score: For tasks like QQP, MRPC
Pearson/Spearman Correlation: For STS-B
Results
GLUE test results (fine-tuned):
Task
MNLI-(m/mm)
QQP
QNLI
SST-2
CoLA
STS-B
MRPC
RTE
Average
Score
83.5/82.3
70.9
89.4
92.1
50.7
84.6
87.5
65.3
78.3
Summary
The model delivers balanced performance across GLUE tasks, with solid results in SST-2 and QNLI. It outperforms smaller BERT variants like boltuix/bert-small in tasks such as RTE and CoLA, making it a well-rounded mid-tier option.
Model Examination
The model’s attention mechanisms were analyzed to ensure effective contextual understanding, with no significant overfitting observed during pretraining. Ablation studies confirmed the suitability of the training configuration for mid-tier performance.
Objective: Masked Language Modeling (MLM) and Next Sentence Prediction (NSP)
Layers: 6
Hidden Size: 512
Attention Heads: 8
Compute Infrastructure
Hardware
2 cloud TPUs in Pod configuration (8 TPU chips total)
Software
PyTorch
Transformers library (Hugging Face)
Citation
BibTeX:
bibtex
1@article{DBLP:journals/corr/abs-1810-04805,
2 author = {Jacob Devlin and Ming{-}Wei Chang and Kenton Lee and Kristina Toutanova},
3 title = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language Understanding},
4 journal = {CoRR},
5 volume = {abs/1810.04805},
6 year = {2018},
7 url = {http://arxiv.org/abs/1810.04805},
8 archivePrefix = {arXiv},
9 eprint = {1810.04805}
10}
APA:
Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2018). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. CoRR, abs/1810.04805. http://arxiv.org/abs/1810.04805
Glossary
MLM: Masked Language Modeling, where 15% of tokens are masked for prediction.
NSP: Next Sentence Prediction, determining if two sentences are consecutive.
WordPiece: Tokenization method splitting words into subword units.