--- language: - en tags: - text-classification - news - bert - ag-news license: apache-2.0 datasets: - ag_news model-index: - name: bert-base-uncased-agnews4-v01 results: - task: type: text-classification name: Text Classification dataset: name: AG News type: ag_news metrics: - name: Accuracy type: accuracy value: 0.855 - name: F1 Score type: F1 Score value: 0.856 --- # bert-base-uncased-agnews4-v01 ## Model description This model is a fine-tuned version of [bert-base-uncased](https://huggingface.co/bert-base-uncased) on the [AG News dataset](https://huggingface.co/datasets/ag_news). It classifies English news headlines or articles into **four categories**: | Label | Category | Description | |--------|-----------|-------------| | 0 | World | International and world news | | 1 | Sports | Sports-related news | | 2 | Business | Financial and economic news | | 3 | Sci/Tech | Science and technology news | The model was trained for text classification using the `transformers` library from Hugging Face. --- ## Intended uses & limitations ### Intended uses - News topic classification - Benchmarking or educational purposes - Text categorization for NLP pipelines ### Limitations - The model is trained on English text only. - It may perform poorly on informal or domain-specific text (e.g., social media). - The dataset contains news articles up to 2015; recent topics or events may be underrepresented. --- ## How to use ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch tokenizer = AutoTokenizer.from_pretrained("Vantish/bert-based-uncased-agnews4-v01") model = AutoModelForSequenceClassification.from_pretrained("Vantish/bert-based-uncased-agnews4-v01") text = "NASA launches a new satellite to study climate change." inputs = tokenizer(text, return_tensors="pt") outputs = model(**inputs) pred = torch.argmax(outputs.logits, dim=-1).item() label_map = { 0: "World", 1: "Sports", 2: "Business", 3: "Sci/Tech" } print("Predicted label:", label_map[pred]) ```` --- ## Training procedure * **Base model:** `bert-base-uncased` * **Dataset:** AG News * **Task:** Text classification (4 classes) * **Optimizer:** AdamW * **Learning rate:** 2e-5 * **Batch size:** 16 * **Epochs:** 3 * **Loss function:** CrossEntropyLoss * **Evaluation metric:** Accuracy ### Hardware Trained on a single NVIDIA GPU (e.g., T4 or V100). --- ## Evaluation results | Metric | Score | | F1 Score | 85.6% | | Accuracy | 85.5% | > ⚠️ Replace with your actual evaluation results if available. --- ## Citation If you use this model, please cite: ```bibtex @misc{bert_agnews_finetune, title={BERT Base Uncased Fine-Tuned on AG News}, author={Vantish}, year={2025}, howpublished={\url{https://huggingface.co/Vantish/bert-based-uncased-agnews4-v01}}, } ``` --- ## License * Base model: [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0) * Fine-tuned weights: Apache 2.0 --- ## Author **Author:** [Vantish] ```