Views
No views yet
| Split | Precision | Recall | F1 |
|---|---|---|---|
| Validation | 95.27% | 95.72% | 95.50% |
| Test | 91.02% | 92.31% | 91.66% |
| Epoch | Train Loss | Val F1 |
|---|---|---|
| 1 | 5.72 | 92.15% |
| 2 | 0.59 | 94.12% |
| 3 | 0.31 | 94.75% |
| 4 | 0.21 | 95.18% |
| 5 | 0.13 | 95.19% |
| 6 | 0.07 | 95.21% |
| 7 | 0.05 | 95.44% |
| 8 | 0.02 | 95.34% |
| 9 | 0.02 | 95.52% |
| 10 | 0.01 | 95.50% |
1from model import BertCrfForTokenClassification
2from transformers import AutoTokenizer
3from huggingface_hub import hf_hub_download
4import torch
5
6# Load model and tokenizer
7MODEL_REPO = "sebastiao-teixeira/bert-crf-ner-conll2003"
8tokenizer = AutoTokenizer.from_pretrained(MODEL_REPO)
9
10model = BertCrfForTokenClassification("bert-base-cased", num_labels=9)
11weights_path = hf_hub_download(repo_id=MODEL_REPO, filename="pytorch_model.bin")
12model.load_state_dict(torch.load(weights_path, map_location="cpu"))
13model.eval()
14
15# Inference
16sentence = "John works at Google in New York."
17inputs = tokenizer(sentence, return_tensors="pt")
18with torch.no_grad():
19 outputs = model(**inputs)
20 predictions = outputs["logits"][0].tolist()1@misc{bert-crf-ner,
2 author = {Sebastiao Teixeira},
3 title = {BERT + CRF for Named Entity Recognition},
4 year = {2026},
5 publisher = {Hugging Face},
6 journal = {Hugging Face Hub},
7}