Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,119 @@
|
|
1 |
---
|
2 |
license: cc-by-4.0
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-4.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
pipeline_tag: text-classification
|
6 |
---
|
7 |
+
|
8 |
+
# Model Card for Model ID
|
9 |
+
|
10 |
+
<!-- Based on https://huggingface.co/t5-small, model generates SQL from text given table list with "CREATE TABLE" statements.
|
11 |
+
This is a very light weigh model and could be used in multiple analytical applications. -->
|
12 |
+
|
13 |
+
Based on [bert-base-uncased](https://huggingface.co/bert-base-uncased) . This model takes in news summary/news headlines/news article and classifies into one of 40 categories (listed below) . Dataset used to traing this model is from [Kaggle](www.kaggle.com) called [News Category Dataset](https://www.kaggle.com/datasets/rmisra/news-category-dataset) porvided by [ rishabhmisra.github.io/publications]( rishabhmisra.github.io/publications).
|
14 |
+
Contact us for more info: [email protected].
|
15 |
+
### Below are the output labels:
|
16 |
+
- arts = 0, arts & culture =1, black voices = 2, business = 3, college = 4, comedy = 5, crime = 6, culture & arts = 7, education = 8, entertainment = 9,environment = 10
|
17 |
+
- fifty=11, food & drink = 12 ,good news = 13, green = 14, healthy living = 15, home & living = 16, impact = 17, latino voices = 18 , media = 19, money = 20 , parenting = 21 , parents = 22
|
18 |
+
- politics = 23, queer voices = 24, religion = 25, science = 26, sports = 27, style = 28, style & beauty = 29 ,taste = 30 ,tech = 31, the worldpost = 32,travel = 33
|
19 |
+
- u.s. news = 34, weddings = 35, weird news = 36, wellness = 37, women = 38 , world news = 39 , worldpost = 40
|
20 |
+
## Model Details
|
21 |
+
|
22 |
+
### Model Description
|
23 |
+
|
24 |
+
<!-- Provide a longer summary of what this model is. -->
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
- **Developed by:** cssupport ([email protected])
|
29 |
+
- **Model type:** Language model
|
30 |
+
- **Language(s) (NLP):** English
|
31 |
+
- **License:** Apache 2.0
|
32 |
+
- **Finetuned from model :** [bert-base-uncased](https://huggingface.co/bert-base-uncased)
|
33 |
+
|
34 |
+
### Model Sources
|
35 |
+
|
36 |
+
<!-- Provide the basic links for the model. -->
|
37 |
+
|
38 |
+
Please refer [bert-base-uncased](https://huggingface.co/bert-base-uncased) for Model Sources.
|
39 |
+
|
40 |
+
## How to Get Started with the Model
|
41 |
+
|
42 |
+
Use the code below to get started with the model.
|
43 |
+
|
44 |
+
```python
|
45 |
+
from transformers import BertTokenizer, BertForSequenceClassification
|
46 |
+
import torch
|
47 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
48 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
49 |
+
model = BertForSequenceClassification.from_pretrained ("cssupport/bert-news-class").to(device)
|
50 |
+
|
51 |
+
def predict(text):
|
52 |
+
id_to_class = {0: 'arts', 1: 'arts & culture', 2: 'black voices', 3: 'business', 4: 'college', 5: 'comedy', 6: 'crime', 7: 'culture & arts', 8: 'education', 9: 'entertainment', 10: 'environment', 11: 'fifty', 12: 'food & drink', 13: 'good news', 14: 'green', 15: 'healthy living', 16: 'home & living', 17: 'impact', 18: 'latino voices', 19: 'media', 20: 'money', 21: 'parenting', 22: 'parents', 23: 'politics', 24: 'queer voices', 25: 'religion', 26: 'science', 27: 'sports', 28: 'style', 29: 'style & beauty', 30: 'taste', 31: 'tech', 32: 'the worldpost', 33: 'travel', 34: 'u.s. news', 35: 'weddings', 36: 'weird news', 37: 'wellness', 38: 'women', 39: 'world news', 40: 'worldpost'}
|
53 |
+
# Tokenize the input text
|
54 |
+
inputs = tokenizer(text, return_tensors='pt', truncation=True, max_length=512, padding='max_length').to(device)
|
55 |
+
with torch.no_grad():
|
56 |
+
logits = model(inputs['input_ids'], inputs['attention_mask'])[0]
|
57 |
+
# Get the predicted class index
|
58 |
+
pred_class_idx = torch.argmax(logits, dim=1).item()
|
59 |
+
return id_to_class[pred_class_idx]
|
60 |
+
|
61 |
+
|
62 |
+
text ="The UK’s growing debt burden puts it on shaky ground ahead of upcoming assessments by the three main credit ratings agencies. A downgrade to its credit rating, which is a reflection of a country’s creditworthiness, could raise borrowing costs further still, although the impact may be limited."
|
63 |
+
predicted_class = predict(text)
|
64 |
+
print(predicted_class)
|
65 |
+
#OUTPUT : business
|
66 |
+
```
|
67 |
+
|
68 |
+
|
69 |
+
## Uses
|
70 |
+
|
71 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
72 |
+
|
73 |
+
[More Information Needed]
|
74 |
+
|
75 |
+
### Direct Use
|
76 |
+
|
77 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
78 |
+
Could used in application where natural language is to be converted into SQL queries.
|
79 |
+
[More Information Needed]
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
### Out-of-Scope Use
|
84 |
+
|
85 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
86 |
+
|
87 |
+
[More Information Needed]
|
88 |
+
|
89 |
+
## Bias, Risks, and Limitations
|
90 |
+
|
91 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
92 |
+
|
93 |
+
[More Information Needed]
|
94 |
+
|
95 |
+
### Recommendations
|
96 |
+
|
97 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
98 |
+
|
99 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
## Technical Specifications
|
104 |
+
|
105 |
+
### Model Architecture and Objective
|
106 |
+
|
107 |
+
[bert-base-uncased](https://huggingface.co/bert-base-uncased)
|
108 |
+
|
109 |
+
### Compute Infrastructure
|
110 |
+
|
111 |
+
|
112 |
+
|
113 |
+
#### Hardware
|
114 |
+
|
115 |
+
one P6000 GPU
|
116 |
+
|
117 |
+
#### Software
|
118 |
+
|
119 |
+
Pytorch and HuggingFace
|