Upload Vietnamese sentiment analysis model
Browse files- README.md +2 -2
- model.safetensors +1 -1
README.md
CHANGED
@@ -43,12 +43,12 @@ model = AutoModelForSequenceClassification.from_pretrained("Khoa/vietnamese-sent
|
|
43 |
def predict_sentiment(text, entity, model, tokenizer):
|
44 |
combined_text = f"Đối với {entity}, {text}"
|
45 |
inputs = tokenizer(combined_text, return_tensors="pt", truncation=True, padding=True)
|
46 |
-
|
47 |
with torch.no_grad():
|
48 |
outputs = model(**inputs)
|
49 |
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
50 |
predicted_class = torch.argmax(predictions, dim=-1).item()
|
51 |
-
|
52 |
sentiment_labels = {0: "NEGATIVE", 1: "NEUTRAL", 2: "POSITIVE"}
|
53 |
return sentiment_labels[predicted_class], predictions[0].tolist()
|
54 |
|
|
|
43 |
def predict_sentiment(text, entity, model, tokenizer):
|
44 |
combined_text = f"Đối với {entity}, {text}"
|
45 |
inputs = tokenizer(combined_text, return_tensors="pt", truncation=True, padding=True)
|
46 |
+
|
47 |
with torch.no_grad():
|
48 |
outputs = model(**inputs)
|
49 |
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
50 |
predicted_class = torch.argmax(predictions, dim=-1).item()
|
51 |
+
|
52 |
sentiment_labels = {0: "NEGATIVE", 1: "NEUTRAL", 2: "POSITIVE"}
|
53 |
return sentiment_labels[predicted_class], predictions[0].tolist()
|
54 |
|
model.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 540026460
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:edddbbc9016343493781924f0fd036e32e3e3c152f75b5308a1888a066089762
|
3 |
size 540026460
|