eriktks/conll2003
Updated β’ 45.2k β’ 184
This is the fine-tuned cased DistilBERT model for English Named Entity Recognition (NER) trained on the CoNLL-2003 corpus. It detects and classifies tokens into four entity categories:
It achieved the winning score in an architectural comparison against LSTM, BiLSTM, and BiLSTM + CRF models.
Evaluated with seqeval in strict IOB2 mode (requiring exact boundary and category match):
| Entity Type | Precision | Recall | Strict F1 |
|---|---|---|---|
| Overall | 89.39% | 90.98% | 90.18% |
Person (PER) |
95.34% | 95.03% | 95.18% |
Organization (ORG) |
86.81% | 88.75% | 87.77% |
Location (LOC) |
92.51% | 92.23% | 92.37% |
Miscellaneous (MISC) |
78.43% | 80.57% | 79.49% |
from transformers import pipeline
ner = pipeline("ner", model="Solayman-Sameh/named-entity-recognition", aggregation_strategy="simple")
text = "Sara works at Google in Cairo."
entities = ner(text)
for ent in entities:
print(f"{ent['word']} -> {ent['entity_group']} ({ent['score']:.2%})")
import torch
from transformers import AutoTokenizer, AutoModelForTokenClassification
model_id = "Solayman-Sameh/named-entity-recognition"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(model_id).eval()
text = "Mohamed studies at MIT in USA."
inputs = tokenizer(text, return_tensors="pt")
with torch.inference_mode():
outputs = model(**inputs)
predictions = outputs.logits.argmax(dim=-1)[0].tolist()
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
for token, pred in zip(tokens, predictions):
if token not in [tokenizer.cls_token, tokenizer.sep_token, tokenizer.pad_token]:
print(f"{token}: {model.config.id2label[pred]}")
The complete source code, exploratory data analysis, architectural comparison (LSTM, BiLSTM, BiLSTM+CRF vs. DistilBERT), test reports, and an interactive Gradio web demo are available at: