Downloads · 30 days
13
17% of all-time downloads
yiwenX/bert-finetuned-ner-accelerate
bert-finetuned-ner-accelerate is a token classification model from yiwenX. Use it when you need labels on individual words, such as names. It is set up for transformers. The card lists the license as apache-2.0.
This model is a fine-tuned version of bert-base-cased on the WikiANN (WikiNER) English dataset for Named Entity Recognition (NER). The model can identify and classify named entities in text into predefined categories.
Downloads · 30 days
13
17% of all-time downloads
All-time downloads
77
Public
Parameters
108M
431 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors431 MB · 100%
From the Hugging Face model README
This model is a fine-tuned version of bert-base-cased on the WikiANN (WikiNER) English dataset for Named Entity Recognition (NER). The model can identify and classify named entities in text into predefined categories.
The model achieves strong performance on the WikiANN English validation set:
The model recognizes 3 main entity types with BIO tagging:
O: Outside of any entityB-PER: Beginning of a person entityI-PER: Inside a person entityB-ORG: Beginning of an organization entityI-ORG: Inside an organization entityB-LOC: Beginning of a location entityI-LOC: Inside a location entityfrom transformers import pipeline
# Load the NER pipeline
nlp = pipeline("ner", model="yiwenX/bert-finetuned-ner-accelerate")
# Example text
text = "Apple Inc. was founded by Steve Jobs in Cupertino, California."
# Get predictions
results = nlp(text)
print(results)
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("yiwenX/bert-finetuned-ner-accelerate")
model = AutoModelForTokenClassification.from_pretrained("yiwenX/bert-finetuned-ner-accelerate")
# Example text
text = "Apple Inc. was founded by Steve Jobs in Cupertino, California."
# Tokenize and predict
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
# Get predictions
predictions = torch.argmax(outputs.logits, dim=-1)
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
# Map predictions to labels
label_list = model.config.id2label
entities = []
for token, pred in zip(tokens, predictions[0]):
if pred != 0: # 0 is 'O' (outside)
entities.append((token, label_list[pred.item()]))
print(entities)
The model was trained on the WikiANN (WikiNER) English dataset, which contains:
WikiANN is a multilingual named entity recognition dataset derived from Wikipedia, providing annotated text with named entity labels.
The following hyperparameters were used during training:
| Epoch | Training Loss | Validation Loss | Precision | Recall | F1 | Accuracy |
|---|---|---|---|---|---|---|
| 1.0 | 0.3066 | 0.2636 | 78.23% | 81.86% | 80.00% | 91.89% |
| 2.0 | 0.2059 | 0.2566 | 79.60% | 83.37% | 81.44% | 92.42% |
| 3.0 | 0.1455 | 0.2777 | 80.92% | 84.07% | 82.47% | 92.50% |
The model was evaluated on the WikiANN English validation set (10,000 samples).
The model is evaluated using standard NER metrics:
Final model performance (Epoch 3):
If you use this model in your research, please cite:
@misc{bert-finetuned-ner-accelerate,
author = {yiwenX},
title = {BERT Fine-tuned for Named Entity Recognition},
year = {2024},
publisher = {HuggingFace},
url = {https://huggingface.co/yiwenX/bert-finetuned-ner-accelerate}
}
This model is licensed under the Apache 2.0 License.