Text Classification
Transformers
Safetensors
PyTorch
roberta
news-classification
ag-news
nlp
text-embeddings-inference
Instructions to use MhoOmm/News_Classifier_Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MhoOmm/News_Classifier_Model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="MhoOmm/News_Classifier_Model")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("MhoOmm/News_Classifier_Model") model = AutoModelForSequenceClassification.from_pretrained("MhoOmm/News_Classifier_Model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 3,759 Bytes
cff1cbc edc574a cff1cbc a260066 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a 229d722 edc574a | 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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | ---
license: mit
library_name: transformers
pipeline_tag: text-classification
tags:
- transformers
- pytorch
- text-classification
- news-classification
- ag-news
- nlp
---
# News Classification using RoBERTa
## Model Description
This model is a fine-tuned RoBERTa model for multiclass news classification. It predicts the category of a news headline or article among four classes:
* World
* Sports
* Business
* Sci/Tech
The model was fine-tuned on the AG News dataset using Hugging Face Transformers and PyTorch.
### Model Details
* **Developed by:** MhoOmm
* **Model Type:** RoBERTa for Sequence Classification
* **Language:** English
* **License:** MIT
* **Finetuned From:** roberta-base
## Labels
| Label ID | Category |
| -------- | -------- |
| 0 | World |
| 1 | Sports |
| 2 | Business |
| 3 | Sci/Tech |
## Intended Use
### Direct Use
This model can be used for:
* News article categorization
* Content organization systems
* News recommendation pipelines
* NLP learning projects
* Text classification demonstrations
### Out-of-Scope Use
This model is not intended for:
* Medical diagnosis
* Financial advice
* Legal decision making
* Safety-critical systems
* Classification of non-English news
## Usage
```python
from transformers import AutoTokenizer
from transformers import AutoModelForSequenceClassification
import torch
model_name = "MhoOmm/news-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
text = "Apple launches a new AI-powered processor"
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True
)
with torch.no_grad():
outputs = model(**inputs)
prediction = outputs.logits.argmax(-1).item()
print(model.config.id2label[prediction])
```
## Training Data
The model was fine-tuned on the AG News dataset.
### Dataset Statistics
* Training Samples: 120,000
* Test Samples: 7,600
* Classes: 4
### Categories
* World
* Sports
* Business
* Sci/Tech
## Training Procedure
### Preprocessing
* RoBERTa tokenizer
* Maximum sequence length: 128
* Truncation enabled
* Dynamic padding
### Hyperparameters
* Learning Rate: 2e-5
* Batch Size: 16
* Epochs: 3
* Optimizer: AdamW
* Framework: PyTorch
* Trainer: Hugging Face Trainer
## Evaluation
### Metrics
The model was evaluated using classification accuracy.
### Example Predictions
| Input | Prediction |
| --------------------------------------------- | ---------- |
| India defeats Australia in the cricket final | Sports |
| Stock market reaches a new all-time high | Business |
| Apple unveils a new AI-powered device | Sci/Tech |
| Global leaders meet to discuss climate policy | World |
### Results
* Accuracy: **94.76%**
## Limitations
* Trained only on English-language news articles.
* May perform poorly on informal text such as tweets and social media posts.
* Restricted to the four AG News categories.
* Performance may decrease on domains significantly different from the training data.
## Architecture
* Base Model: RoBERTa Base
* Hidden Size: 768
* Transformer Layers: 12
* Attention Heads: 12
* Classification Head: Linear Layer (768 → 4)
## Software
* PyTorch
* Transformers
* Hugging Face Hub
* Gradio
## Author
Created by **MhoOmm** as an end-to-end NLP project demonstrating:
* Transformer fine-tuning
* Text classification
* Model deployment with Hugging Face
* Interactive inference using Gradio
## Citation
If you use this model, please cite the original RoBERTa paper:
**RoBERTa: A Robustly Optimized BERT Pretraining Approach**
Yinhan Liu, Myle Ott, Naman Goyal, et al.
https://arxiv.org/abs/1907.11692
|