PavanDeepak/Topic_Classification
014
1---2license: mit3---4## BERT-based Text Classification Model5This model is a fine-tuned version of the bert-base-uncased model, specifically adapted for text classification across a diverse set of categories. The model has been trained on a dataset collected from multiple sources, including the News Category Dataset on Kaggle and various other websites.6 7The model classifies text into one of the following 12 categories:8 9* Food10* Videogames & Shows11* Kids and fun12* Homestyle13* Travel14* Health15* Charity16* Electronics & Technology17* Sports18* Cultural & Music19* Education20* Convenience21The model has demonstrated robust performance with an accuracy of 0.721459, F1 score of 0.659451, precision of 0.707620, and recall of 0.635155.22 23## Model Architecture24The model leverages the BertForSequenceClassification architecture, It has been fine-tuned on the aforementioned dataset, with the following key configuration parameters:25 26* Hidden size: 76827* Number of attention heads: 1228* Number of hidden layers: 1229* Max position embeddings: 51230* Type vocab size: 231* Vocab size: 3052232* The model uses the GELU activation function in its hidden layers and applies dropout with a probability of 0.1 to the attention probabilities to prevent overfitting.33 34## Example 35 36```python37from transformers import AutoModelForSequenceClassification, AutoTokenizer38import numpy as np39from scipy.special import expit40 41MODEL = "PavanDeepak/Topic_Classification"42tokenizer = AutoTokenizer.from_pretrained(MODEL)43model = AutoModelForSequenceClassification.from_pretrained(MODEL)44class_mapping = model.config.id2label45 46text = "I love chicken manchuria"47tokens = tokenizer(text, return_tensors="pt")48output = model(**tokens)49 50scores = output.logits[0][0].detach().numpy()51scores = expit(scores)52predictions = (scores >= 0.5) * 153 54for i in range(len(predictions)):55 if predictions[i]:56 print(class_mapping[i])57```58 59## Output:60 61* Food62* Videogames & Shows63* Homestyle64* Travel65* Health