File size: 2,649 Bytes
27cda1d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# RoBERTa-Base Quantized Model for Named Entity Recognition (NER)
This repository contains a quantized version of the RoBERTa model fine-tuned for Named Entity Recognition (NER) on the WikiANN (English) dataset. The model is particularly suitable for **tagging named entities in news articles**, such as persons, organizations, and locations. It has been optimized for efficient deployment using quantization techniques.
## Model Details
- **Model Architecture:** RoBERTa Base
- **Task:** Named Entity Recognition
- **Dataset:** WikiANN (English)
- **Use Case:** Tagging news articles with named entities
- **Quantization:** Float16
- **Fine-tuning Framework:** Hugging Face Transformers
## Usage
### Installation
```sh
pip install transformers torch
```
### Loading the Model
```python
from transformers import RobertaTokenizerFast, RobertaForSequenceClassification, Trainer, TrainingArguments
import torch
# Load tokenizer
tokenizer = RobertaTokenizerFast.from_pretrained("roberta-base")
# Create NER pipeline
ner_pipeline = pipeline(
"ner",
model=model,
tokenizer=tokenizer,
aggregation_strategy="simple"
)
# Sample news headline
text = "Apple Inc. is planning to open a new campus in London by the end of 2025."
# Inference
entities = ner_pipeline(text)
# Display results
for ent in entities:
print(f"{ent['word']}: {ent['entity_group']} ({ent['score']:.2f})")
```
## Performance Metrics
- **Accuracy:** 0.923422
- **Precision:** 0.923052
- **Recall:** 0.923422
- **F1:** 0.923150
## Fine-Tuning Details
### Dataset
The dataset is taken from Hugging Face WikiANN (English).
### Training
- Number of epochs: 5
- Batch size: 16
- Evaluation strategy: epoch
- Learning rate: 3e-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
```
.
βββ config.json
βββ tokenizer_config.json
βββ sepcial_tokens_map.json
βββ tokenizer.json
βββ model.safetensors # Fine Tuned 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.
|