CoolFace
Modelpublic

dstefa/roberta-base_topic_classification_nyt_news

sourceHugging Facemitupdated 3y agoView on Hugging Face
11likes2.1kdownloads
Model Card

roberta-basetopicclassificationnytnews

This model is a fine-tuned version of roberta-base on the NYT News dataset, which contains 256,000 news titles from articles published from 2000 to the present (https://www.kaggle.com/datasets/aryansingh0909/nyt-articles-21m-2000-present). It achieves the following results on the test set of 51200 cases:

  • Accuracy: 0.91
  • F1: 0.91
  • Precision: 0.91
  • Recall: 0.91

Training data

Training data was classified as follow:

classDescription
0Sports
1Arts, Culture, and Entertainment
2Business and Finance
3Health and Wellness
4Lifestyle and Fashion
5Science and Technology
6Politics
7Crime

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 5e-05
  • trainbatchsize: 8
  • evalbatchsize: 8
  • seed: 42
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lrschedulertype: linear
  • lrschedulerwarmup_steps: 500
  • num_epochs: 5

Training results

Training LossEpochStepValidation LossAccuracyF1PrecisionRecall
0.31921.0204800.40780.88650.88590.88920.8865
0.28632.0409600.42710.89720.89700.89820.8972
0.19793.0614400.37970.90940.90920.90980.9094
0.12394.0819200.39810.91170.91130.91140.9117
0.14725.01024000.40330.91370.91350.91340.9137

Model performance

-precisionrecallf1support
Sports0.970.980.976400
Arts, Culture, and Entertainment0.940.950.946400
Business and Finance0.850.840.846400
Health and Wellness0.900.930.916400
Lifestyle and Fashion0.950.950.956400
Science and Technology0.890.830.866400
Politics0.930.880.906400
Crime0.850.930.896400
accuracy0.9151200
macro avg0.910.910.9151200
weighted avg0.910.910.9151200

How to use roberta-basetopicclassificationnytnews with HuggingFace

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from transformers import pipeline

tokenizer = AutoTokenizer.from_pretrained("dstefa/roberta-base_topic_classification_nyt_news")
model = AutoModelForSequenceClassification.from_pretrained("dstefa/roberta-base_topic_classification_nyt_news")
pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)

text = "Kederis proclaims innocence Olympic champion Kostas Kederis today left hospital ahead of his date with IOC inquisitors claiming his innocence and vowing."
pipe(text)

[{'label': 'Sports', 'score': 0.9989326596260071}]

Framework versions

  • Transformers 4.32.1
  • Pytorch 2.1.0+cu121
  • Datasets 2.12.0
  • Tokenizers 0.13.2