Downloads · 30 days
7
32% of all-time downloads
AventIQ-AI/roberta-named-entity-recognition-for-content-tagging
roberta-named-entity-recognition-for-content-tagging is a machine learning model from AventIQ-AI. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository hosts a fine-tuned version of the RoBERTa model for Named Entity Recognition (NER) using the CoNLL-2003 dataset. The model is capable of identifying and classifying named entities such as people, organ…
Downloads · 30 days
7
32% of all-time downloads
All-time downloads
22
Public
Parameters
124M
248 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors248 MB · 98%
From the Hugging Face model README
This repository hosts a fine-tuned version of the RoBERTa model for Named Entity Recognition (NER) using the CoNLL-2003 dataset. The model is capable of identifying and classifying named entities such as people, organizations, locations, etc.
pip install datasets transformers seqeval torch --quiet
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load tokenizer and model
model = "roberta-base"
tokenizer = AutoTokenizer.from_pretrained(model)
model = AutoModelForSequenceClassification.from_pretrained(model)
# Define test sentences
sentences = [
"Barack Obama was born in Hawaii.",
"Elon Musk founded SpaceX and Tesla.",
"Apple is headquartered in Cupertino, California."
]
for sentence in sentences:
tokens = tokenizer(sentence, return_tensors="pt", truncation=True, is_split_into_words=False).to(device)
with torch.no_grad():
outputs = model(**tokens)
logits = outputs.logits
predictions = torch.argmax(logits, dim=2)
predicted_labels = predictions[0].cpu().numpy()
tokens_decoded = tokenizer.convert_ids_to_tokens(tokens["input_ids"][0])
print(f"Sentence: {sentence}")
for token, label_id in zip(tokens_decoded, predicted_labels):
label = label_list[label_id]
if token.startswith("Ġ") or not token.startswith("▁"):
token = token.replace("Ġ", "")
if label != "O":
print(f"{token}: {label}")
print("\n" + "-"*50 + "\n")
The dataset used is the CoNLL-2003 dataset, which contains labeled tokens for Named Entity Recognition (NER). Entities are categorized into classes such as PER (person), ORG (organization), LOC (location), and MISC (miscellaneous). It includes four columns: the word, part-of-speech tag, syntactic chunk tag, and NER tag.
The dataset is automatically loaded using the Hugging Face datasets library and is split into train, validation, and test sets.
epochTrainer APIPost-training quantization was applied using model.to(dtype=torch.float16) to reduce model size and speed up inference.
.
├── quantized-model/ # Directory containing trained model artifacts
│ ├── config.json
│ ├── merges.txt
│ ├── model.safetensors # (May appear as 'model' in UI)
│ ├── special_tokens_map.json
│ ├── tokenizer.json
│ ├── tokenizer_config.json
│ └── vocab.json
├── README.md
Feel free to open issues or submit pull requests to improve the model, training process, or documentation.