Token Classification
Transformers
Safetensors
English
bert
ner
named-entity-recognition
text-classification
sequence-labeling
transformer
nlp
pretrained-model
dataset-finetuning
deep-learning
huggingface
conll2025
real-time-inference
efficient-nlp
high-accuracy
gpu-optimized
chatbot
information-extraction
search-enhancement
knowledge-graph
legal-nlp
medical-nlp
financial-nlp
Instructions to use boltuix/NeuroBERT-NER with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use boltuix/NeuroBERT-NER with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="boltuix/NeuroBERT-NER")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("boltuix/NeuroBERT-NER") model = AutoModelForTokenClassification.from_pretrained("boltuix/NeuroBERT-NER", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
Update README.md
Browse filesCode example updated
README.md
CHANGED
|
@@ -78,19 +78,47 @@ tags:
|
|
| 78 |
|
| 79 |
```python
|
| 80 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
```
|
| 91 |
|
| 92 |
### β¨ Output
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
## ποΈ Training Details
|
| 96 |
|
|
|
|
| 78 |
|
| 79 |
```python
|
| 80 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
| 81 |
+
import torch
|
| 82 |
+
|
| 83 |
+
# Load tokenizer and model from Hugging Face Hub
|
| 84 |
+
tokenizer = AutoTokenizer.from_pretrained("boltuix/bert-ner")
|
| 85 |
+
model = AutoModelForTokenClassification.from_pretrained("boltuix/bert-ner")
|
| 86 |
+
|
| 87 |
+
# Sample input text
|
| 88 |
+
text = "Barack Obama visited Microsoft headquarters in Seattle."
|
| 89 |
+
|
| 90 |
+
# Tokenize the input
|
| 91 |
+
inputs = tokenizer(text, return_tensors="pt")
|
| 92 |
+
outputs = model(**inputs)
|
| 93 |
+
|
| 94 |
+
# Get predictions
|
| 95 |
+
predictions = outputs.logits.argmax(dim=-1)
|
| 96 |
+
|
| 97 |
+
# Convert token IDs to tokens
|
| 98 |
+
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
|
| 99 |
+
|
| 100 |
+
# Get the label map from model config
|
| 101 |
+
label_map = model.config.id2label
|
| 102 |
+
|
| 103 |
+
# Map predicted IDs to labels
|
| 104 |
+
labels = [label_map[p.item()] for p in predictions[0]]
|
| 105 |
+
|
| 106 |
+
# Print token-label pairs (skip special tokens like [CLS], [SEP])
|
| 107 |
+
for token, label in zip(tokens, labels):
|
| 108 |
+
if token not in tokenizer.all_special_tokens:
|
| 109 |
+
print(f"{token:15} β {label}")
|
| 110 |
+
|
| 111 |
```
|
| 112 |
|
| 113 |
### β¨ Output
|
| 114 |
+
barack β B-PERSON
|
| 115 |
+
obama β I-PERSON
|
| 116 |
+
visited β O
|
| 117 |
+
microsoft β B-ORG
|
| 118 |
+
headquarters β O
|
| 119 |
+
in β O
|
| 120 |
+
seattle β B-GPE
|
| 121 |
+
. β O
|
| 122 |
|
| 123 |
## ποΈ Training Details
|
| 124 |
|