Introduction of distilbert-base-uncased_token_classification
Model Details of distilbert-base-uncased_token_classification
Model Overview
This model is a Named Entity Recognition (NER) system fine-tuned on the WNUT 17 dataset using DistilBERT. It predicts entity types such as persons, organizations, locations, and more from text.
Model Details
Model Type: Transformer-based NER
Base Model: DistilBERT (distilbert-base-uncased)
Dataset: WNUT 17
Training Framework: PyTorch & Hugging Face Transformers
Training Epochs: 3
Batch Size: 16
Learning Rate: 2e-5
Optimizer: AdamW
Weight Decay: 0.01
Evaluation Strategy: Per epoch
Training Data
The model is trained on the WNUT 17 dataset, which contains challenging named entities in social media and conversational text. The dataset provides annotations for named entity recognition, including entity categories such as:
person
location
corporation
product
creative-work
group
Inference and Usage
#Loading the Modelfrom transformers import DistilBertForTokenClassification, DistilBertTokenizerFast
import torch
model_name = "AventIQ-AI/distilbert-base-uncased_token_classification"defpredict_entities(text, model, tokenizer):
"""Predict Named Entities from the quantized model"""
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
# Convert to FP32 if needed (for stability)with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits.float(), dim=2) # Convert logits to float32
predicted_labels = [model.config.id2label[t.item()] for t in predictions[0]]
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
# Remove special tokens and align subwords
entities = []
current_entity = Nonefor token, label inzip(tokens, predicted_labels):
if token in [tokenizer.cls_token, tokenizer.sep_token, tokenizer.pad_token]:
continueif token.startswith("##"): # Handle subwordsif current_entity:
current_entity["text"] += token[2:]
continueif label == "O":
if current_entity:
entities.append(current_entity)
current_entity = Noneelse:
if label.startswith("B-"):
if current_entity:
entities.append(current_entity)
current_entity = {"text": token, "type": label[2:]}
elif label.startswith("I-") and current_entity:
current_entity["text"] += " " + token
if current_entity:
entities.append(current_entity)
return entities
Example Usage
test_sentence = ["Apple CEO Tim Cook announced the new iPhone 14 at their headquarters in Cupertino."]
for sentence in test_sentences:
print(f"\nInput: {sentence}")
entities = predict_entities(sentence, model, tokenizer)
print("Detected entities:")
for entity in entities:
print(f"- {entity['text']} ({entity['type']})")
print("-" * 50)
📊 Evaluation Results for Quantized Model
🔹 Overall Performance
Accuracy
:
97.10%
✅
Precision
:
89.52%
Recall
:
90.67%
F1 Score
:
90.09%
🔹 Performance by Entity Type
Entity Type
Precision
Recall
F1 Score
Number of Entities
LOC
(Location)
91.46%
92.07%
91.76%
3,000
MISC
(Miscellaneous)
71.25%
72.83%
72.03%
1,266
ORG
(Organization)
89.83%
93.02%
91.40%
3,524
PER
(Person)
95.16%
94.04%
94.60%
2,989
⏳
Inference Speed Metrics
Total Evaluation Time
: 15.89 sec
Samples Processed per Second
: 217.26
Steps per Second
: 27.18
Epochs Completed
: 3
Fine-Tuning Details
Dataset
The Hugging Face's
wnut_17
dataset was used, containing texts and their ner tags.
📊 Training Details
Number of epochs
: 3
Batch size
: 16
Evaluation strategy
: epoch
Learning Rate
: 2e-5
⚡ Quantization
Post-training quantization was applied using PyTorch's built-in quantization framework to reduce the model size and improve inference efficiency.
📂 Repository Structure
.
├── model/ # Contains the quantized model files
├── tokenizer_config/ # Tokenizer configuration and vocabulary files
├── model.safetensors/ # Quantized Model
├── README.md # Model documentation
⚠️ Limitations
The model may not generalize well to domains outside the fine-tuning dataset.
Quantization may result in minor accuracy degradation compared to full-precision models.
🤝 Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.
Runs of AventIQ-AI distilbert-base-uncased_token_classification on huggingface.co
16
Total runs
8
24-hour runs
8
3-day runs
8
7-day runs
10
30-day runs
More Information About distilbert-base-uncased_token_classification huggingface.co Model
distilbert-base-uncased_token_classification huggingface.co is an AI model on huggingface.co that provides distilbert-base-uncased_token_classification's model effect (), which can be used instantly with this AventIQ-AI distilbert-base-uncased_token_classification model. huggingface.co supports a free trial of the distilbert-base-uncased_token_classification model, and also provides paid use of the distilbert-base-uncased_token_classification. Support call distilbert-base-uncased_token_classification model through api, including Node.js, Python, http.
distilbert-base-uncased_token_classification huggingface.co is an online trial and call api platform, which integrates distilbert-base-uncased_token_classification's modeling effects, including api services, and provides a free online trial of distilbert-base-uncased_token_classification, you can try distilbert-base-uncased_token_classification online for free by clicking the link below.
AventIQ-AI distilbert-base-uncased_token_classification online free url in huggingface.co:
distilbert-base-uncased_token_classification is an open source model from GitHub that offers a free installation service, and any user can find distilbert-base-uncased_token_classification on GitHub to install. At the same time, huggingface.co provides the effect of distilbert-base-uncased_token_classification install, users can directly use distilbert-base-uncased_token_classification installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
distilbert-base-uncased_token_classification install url in huggingface.co: