Views
No views yet
| Epoch | Training Loss | Validation Loss | Accuracy |
|---|---|---|---|
| 1 | 0.163500 | 0.511470 | XX% |
| 2 | 0.517700 | 0.581499 | XX% |
| 3 | 0.312900 | 0.526096 | XX% |
2e-581from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load the fine-tuned Khmer financial sentiment model
5model_name = "songhieng/khmer-sentiment-xlm-roberta-base"
6
7# Load tokenizer and model
8tokenizer = AutoTokenizer.from_pretrained(model_name)
9model = AutoModelForSequenceClassification.from_pretrained(model_name)
10
11# Example Khmer financial text
12text = "ការប្រកាសចំណូលរបស់ក្រុមហ៊ុនមានការកើនឡើងយ៉ាងច្រើន"
13inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
14outputs = model(**inputs)
15
16# Get predicted sentiment (0 = Negative, 1 = Positive)
17predicted_class = outputs.logits.argmax(dim=1).item()
18labels_mapping = {0: "Negative", 1: "Positive"}
19print(f"Predicted Sentiment: {labels_mapping[predicted_class]}")