NeuroBERT-Pro is a flagship lightweight NLP model derived from BERT-base-uncased, optimized for edge AI, IoT, and mobile applications. With a quantized size of ~150MB and ~50M parameters, it delivers near-BERT-base accuracy across tasks like question answering (QA), intent classification, sentiment analysis, named entity recognition (NER), multi-class/open-domain classification, semantic similarity, token classification, and masked language modeling (MLM). Built for real-time, offline operation, it’s ideal for privacy-first, high-performance NLP on resource-constrained devices.
NeuroBERT-Pro redefines edge NLP with flagship performance and unmatched efficiency.
Extract precise answers from text for offline assistants in smart devices.
from transformers import pipeline
# Initialize QA pipeline
qa_pipeline = pipeline("question-answering", model="boltuix/NeuroBERT-Pro")
# Example
context = "In 1969, Neil Armstrong became the first human to walk on the moon."
question = "Who was the first human to walk on the moon?"
result = qa_pipeline(question=question, context=context)
print(result["answer"])
Output: Neil Armstrong
Classify user intents for IoT or chatbots, e.g., detecting commands like “Play music.”
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model
model_name = "boltuix/NeuroBERT-Pro"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval()
# Example
text = "Play some music"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
pred = torch.argmax(probs, dim=1).item()
labels = ["Play", "Stop", "Pause"]
print(f"Predicted intent: {labels[pred]}")
Output: Play
Detect positive/negative sentiment, ideal for feedback apps.
from transformers import pipeline
# Initialize sentiment pipeline
sentiment_pipeline = pipeline("sentiment-analysis", model="boltuix/NeuroBERT-Pro")
# Example
text = "I love this new smartwatch!"
result = sentiment_pipeline(text)
print(result)
Output: [{'label': 'POSITIVE', 'score': 0.97}]
Categorize queries with multiple labels, e.g., travel intents.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model
model_name = "boltuix/NeuroBERT-Pro"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=4)
model.eval()
# Example
text = "Book a flight to Paris"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
pred = torch.argmax(probs, dim=1).item()
labels = ["Book", "Cancel", "Check", "Modify"]
print(f"Predicted class: {labels[pred]}")
Output: Book
Fine-tune for dynamic label sets, e.g., clustering customer support queries.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model
model_name = "boltuix/NeuroBERT-Pro"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=3)
model.eval()
# Example
text = "I need help with my account"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
pred = torch.argmax(probs, dim=1).item()
labels = ["Account Issue", "Payment Issue", "General Inquiry"]
print(f"Predicted class: {labels[pred]}")
Output: Account Issue
Identify entities like names or locations with high precision.
from transformers import pipeline
# Initialize NER pipeline
ner_pipeline = pipeline("ner", model="boltuix/NeuroBERT-Pro")
# Example
text = "Elon Musk visited Paris"
result = ner_pipeline(text)
print(result)
Output: [{'entity': 'PERSON', 'word': 'Elon Musk'}, {'entity': 'LOCATION', 'word': 'Paris'}]
Measure text similarity for clustering or search on edge devices.
from transformers import AutoTokenizer, AutoModel
import torch
import torch.nn.functional as F
# Load model
model_name = "boltuix/NeuroBERT-Pro"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)
model.eval()
# Example texts
text1 = "I want to book a flight"
text2 = "Reserve a plane ticket"
inputs1 = tokenizer(text1, return_tensors="pt", padding=True, truncation=True)
inputs2 = tokenizer(text2, return_tensors="pt", padding=True, truncation=True)
# Get embeddings
with torch.no_grad():
outputs1 = model(**inputs1).last_hidden_state.mean(dim=1)
outputs2 = model(**inputs2).last_hidden_state.mean(dim=1)
similarity = F.cosine_similarity(outputs1, outputs2).item()
print(f"Similarity score: {similarity:.4f}")
Output: Similarity score: 0.9105
Classify tokens for tasks like part-of-speech tagging.
from transformers import pipeline
# Initialize token classification pipeline
token_pipeline = pipeline("token-classification", model="boltuix/NeuroBERT-Pro")
# Example
text = "The quick brown fox jumps"
result = token_pipeline(text)
print(result)
Output: [{'entity': 'DET', 'word': 'The'}, {'entity': 'ADJ', 'word': 'quick'}, ...]
Predict missing words in IoT or general contexts.
from transformers import pipeline
# Initialize MLM pipeline
mlm_pipeline = pipeline("fill-mask", model="boltuix/NeuroBERT-Pro")
# Example
result = mlm_pipeline("The train arrived at the [MASK] on time.")
print(result[0]["sequence"])
Output: The train arrived at the station on time.
pip install transformers torch datasets
Requires Python 3.6+, ~150MB storage.
Fine-tune for tasks like QA, NER, or classification:
#!pip uninstall -y transformers torch datasets
#!pip install transformers==4.44.2 torch==2.4.1 datasets==3.0.1
import torch
from transformers import BertTokenizer, BertForSequenceClassification, Trainer, TrainingArguments
from datasets import Dataset
import pandas as pd
# Prepare dataset
data = {
"text": ["Book a flight", "Cancel my ticket", "Check flight status", "Modify booking"],
"label": [0, 1, 2, 3]
}
df = pd.DataFrame(data)
dataset = Dataset.from_pandas(df)
# Load tokenizer and model
model_name = "boltuix/NeuroBERT-Pro"
tokenizer = BertTokenizer.from_pretrained(model_name)
model = BertForSequenceClassification.from_pretrained(model_name, num_labels=4)
# Tokenize dataset
def tokenize_function(examples):
return tokenizer(examples["text"], padding="max_length", truncation=True, max_length=64)
tokenized_dataset = dataset.map(tokenize_function, batched=True)
# Training arguments
training_args = TrainingArguments(
output_dir="./neurobert_pro_results",
num_train_epochs=5,
per_device_train_batch_size=2,
logging_dir="./neurobert_pro_logs",
logging_steps=10,
save_steps=100,
eval_strategy="no",
learning_rate=1e-5
)
# Initialize trainer
trainer = Trainer(
model=model,
args=training_args,
train_dataset=tokenized_dataset
)
# Train
trainer.train()
# Save model
model.save_pretrained("./fine_tuned_neurobert_pro")
tokenizer.save_pretrained("./fine_tuned_neurobert_pro")
Deploy using ONNX or TensorFlow Lite for edge devices.
Evaluated on 10 IoT-related MLM sentences, achieving ~10/10 pass rate:
Sentence | Expected Word |
---|---|
She is a [MASK] at the local hospital. | nurse |
Please [MASK] the door before leaving. | shut |
The drone collects data using onboard [MASK]. | sensors |
The fan will turn [MASK] when the room is empty. | off |
Turn [MASK] the coffee machine at 7 AM. | on |
The hallway light switches on during the [MASK]. | night |
The air purifier turns on due to poor [MASK] quality. | air |
The AC will not run if the door is [MASK]. | open |
Turn off the lights after [MASK] minutes. | five |
The music pauses when someone [MASK] the room. | enters |
Model | Parameters | Size | Edge/IoT Focus | Tasks |
---|---|---|---|---|
NeuroBERT-Pro | ~50M | ~150MB | High | MLM, QA, NER, Classification, Similarity |
bert-mini | ~8M | ~15MB | High | MLM, QA, NER, Classification, Similarity |
NeuroBERT-Mini | ~7M | ~35MB | High | MLM, NER, Classification |
DistilBERT | ~66M | ~200MB | Moderate | MLM, QA, NER, Classification |
TinyBERT | ~14M | ~50MB | Moderate | MLM, Classification |
Learn advanced fine-tuning and deployment techniques:
Fine-Tune Faster, Deploy Smarter — Full Guide
MIT License: Free to use. See LICENSE.
NeuroBERT-Pro is the ultimate lightweight NLP model, delivering near-BERT-base performance for QA, NER, intent detection, and more on edge devices. From smart homes to wearables, it powers advanced AI in 2025. Explore it on Hugging Face!