Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
A model fine-tuned for sentiment analysis based on [vinai/phobert-base](https://huggingface.co/vinai/phobert-base).
|
2 |
+
|
3 |
+
Labels:
|
4 |
+
- NEG: Negative
|
5 |
+
- POS: Positive
|
6 |
+
- NEU: Neutral
|
7 |
+
|
8 |
+
Dataset: Comments on Shoppe (https://shopee.vn/)
|
9 |
+
## Usage
|
10 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
11 |
+
import torch
|
12 |
+
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained("lamsytan/sentiment-analysis-base-phobert")
|
14 |
+
model = AutoModelForSequenceClassification.from_pretrained("lamsytan/sentiment-analysis-base-phobert")
|
15 |
+
|
16 |
+
sentence = "Áo đẹp lắm nhá lần sau sẽ ghé tiếp ạ"
|
17 |
+
|
18 |
+
inputs = tokenizer(sentence, return_tensors="pt", padding=True, truncation=True)
|
19 |
+
|
20 |
+
with torch.no_grad():
|
21 |
+
outputs = model(**inputs)
|
22 |
+
logits = outputs.logits
|
23 |
+
probabilities = torch.softmax(logits, dim=-1)
|
24 |
+
|
25 |
+
print(probabilities.tolist())
|
26 |
+
# Output:
|
27 |
+
# [[0.010827462188899517, 0.9538241624832153, 0.035348404198884964]]
|
28 |
+
# ^ ^ ^
|
29 |
+
# NEG POS NEU
|
30 |
+
|