HeyLucasLeao commited on
Commit
ec5f659
1 Parent(s): 8c66b04

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +68 -1
README.md CHANGED
@@ -1 +1,68 @@
1
- test
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Create README.md
2
+ ## ByT5 Small Portuguese Product Reviews
3
+
4
+ #### Model Description
5
+ This is a finetuned version from ByT5 by Google for Sentimental Analysis from Product Reviews in Portuguese.
6
+
7
+ #### Training data
8
+ It was trained from products reviews from a Americanas.com. You can found the data here: https://github.com/b2wdigital/b2w-reviews01.
9
+
10
+ #### Training Procedure
11
+ It was finetuned using the Trainer Class available on the Hugging Face library. For evaluation it was used accuracy, precision, recall and f1 score.
12
+
13
+ ##### Learning Rate: **2e-4**
14
+ ##### Epochs: **1**
15
+ ##### Colab for Finetuning: https://colab.research.google.com/drive/1EChTeQkGeXi_52lClBNazHVuSNKEHN2f
16
+ ##### Colab for Metrics: https://colab.research.google.com/drive/1o4tcsP3lpr1TobtE3Txhp9fllxPWXxlw#scrollTo=PXAoog5vQaTn
17
+ #### Score:
18
+ ```python
19
+ Training Set:
20
+ 'accuracy': 0.8699743370402053,
21
+ 'f1': 0.9072110777980404,
22
+ 'precision': 0.9432919284600922,
23
+ 'recall': 0.8737887200250071
24
+
25
+ Test Set:
26
+ 'accuracy': 0.8680854858365782,
27
+ 'f1': 0.9058389204786557,
28
+ 'precision': 0.9420980625799903,
29
+ 'recall': 0.8722673967229191
30
+
31
+ Validation Set:
32
+ 'accuracy': 0.8662624220987031,
33
+ 'f1': 0.9042450554751569,
34
+ 'precision': 0.9436194311603322,
35
+ 'recall': 0.8680250057883769
36
+ ```
37
+
38
+ #### Goals
39
+
40
+ My true intention was totally educational, thus making available a this version of the model as a example for future proposes.
41
+
42
+ How to use
43
+ ``` python
44
+ from transformers import AutoTokenizer, AutoModelForCausalLM
45
+ import torch
46
+
47
+ if torch.cuda.is_available():
48
+ device = torch.device('cuda')
49
+ else:
50
+ device = torch.device('cpu')
51
+ print(device)
52
+
53
+ tokenizer = AutoTokenizer.from_pretrained("HeyLucasLeao/byt5-small-pt-product-reviews")
54
+
55
+ model = AutoModelForCausalLM.from_pretrained("HeyLucasLeao/byt5-small-pt-product-reviews")
56
+ model.to(device)
57
+
58
+ def classificar_review(review):
59
+ inputs = tokenizer([review], padding='max_length', truncation=True, max_length=512, return_tensors='pt')
60
+ input_ids = inputs.input_ids.to(device)
61
+ attention_mask = inputs.attention_mask.to(device)
62
+ output = model.generate(input_ids, attention_mask=attention_mask)
63
+ pred = np.argmax(output.cpu(), axis=1)
64
+ dici = {0: 'Review Negativo', 1: 'Review Positivo'}
65
+ return dici[pred.item()]
66
+
67
+ classificar_review(review)
68
+ ```