lucasresck
commited on
Commit
•
3535a9e
1
Parent(s):
78f0e71
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
license: mit
|
5 |
+
tags:
|
6 |
+
- bert
|
7 |
+
- classification
|
8 |
+
datasets:
|
9 |
+
- ag_news
|
10 |
+
metrics:
|
11 |
+
- accuracy
|
12 |
+
- f1
|
13 |
+
- recall
|
14 |
+
- precision
|
15 |
+
widget:
|
16 |
+
- text: "Is it soccer or football?"
|
17 |
+
example_title: "Sports"
|
18 |
+
- text: "A new version of Ubuntu was released."
|
19 |
+
example_title: "Sci/Tech"
|
20 |
+
---
|
21 |
+
|
22 |
+
# bert-base-cased-ag-news
|
23 |
+
|
24 |
+
BERT model fine-tuned on AG News classification dataset using a linear layer on top of the [CLS] token output, with 0.945 test accuracy.
|
25 |
+
|
26 |
+
### How to use
|
27 |
+
|
28 |
+
Here is how to use this model to classify a given text:
|
29 |
+
```python
|
30 |
+
from transformers import AutoTokenizer, BertForSequenceClassification
|
31 |
+
tokenizer = AutoTokenizer.from_pretrained('lucasresck/bert-base-cased-ag-news')
|
32 |
+
model = BertForSequenceClassification.from_pretrained('lucasresck/bert-base-cased-ag-news')
|
33 |
+
text = "Is it soccer or football?"
|
34 |
+
encoded_input = tokenizer(text, return_tensors='pt', truncation=True, max_length=512)
|
35 |
+
output = model(**encoded_input)
|
36 |
+
```
|
37 |
+
|
38 |
+
### Limitations and bias
|
39 |
+
|
40 |
+
Bias were not assessed in this model, but, considering that pre-trained BERT is known to carry bias, it is also expected for this model. BERT's authors say: "This bias will also affect all fine-tuned versions of this model."
|
41 |
+
|
42 |
+
## Evaluation results
|
43 |
+
|
44 |
+
```
|
45 |
+
precision recall f1-score support
|
46 |
+
|
47 |
+
0 0.9539 0.9584 0.9562 1900
|
48 |
+
1 0.9884 0.9879 0.9882 1900
|
49 |
+
2 0.9251 0.9095 0.9172 1900
|
50 |
+
3 0.9127 0.9242 0.9184 1900
|
51 |
+
|
52 |
+
accuracy 0.9450 7600
|
53 |
+
macro avg 0.9450 0.9450 0.9450 7600
|
54 |
+
weighted avg 0.9450 0.9450 0.9450 7600
|
55 |
+
```
|