Views
No views yet
| Score Range | Meaning |
|---|---|
| +0.6 ~ +1.0 | 강한 긍정 감정 |
| +0.2 ~ +0.6 | 약한 긍정 감정 |
| -0.2 ~ +0.2 | 중립 또는 감정 표현이 미약 |
| -0.6 ~ -0.2 | 약한 부정 감정 |
| -1.0 ~ -0.6 | 강한 부정 감정 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4MODEL_NAME = "LimYeri/HowRU-KoELECTRA-Emotion-Regression"
5
6tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
7model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
8
9device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
10model.to(device)
11model.eval()
12
13def predict_score(text: str):
14 """
15 Returns:
16 - emotion_score: 감정 강도 (-1.0 ~ 1.0)
17 """
18 inputs = tokenizer(
19 text,
20 return_tensors="pt",
21 truncation=True,
22 padding=True,
23 max_length=512
24 ).to(device)
25
26 with torch.no_grad():
27 outputs = model(**inputs).logits
28 score = outputs.item()
29
30 return {"text": text, "emotion_score": score}
31
32
33# Example
34result = predict_score("오늘은 정말 즐겁고 행복한 최고의 하루였어!")
35print(result)1from transformers import pipeline
2
3MODEL_NAME = "LimYeri/HowRU-KoELECTRA-Emotion-Regression"
4
5regressor = pipeline(
6 "text-classification", # Regression도 동일 Task로 동작
7 model=MODEL_NAME,
8 tokenizer=MODEL_NAME,
9 function_to_apply="none" # Softmax 제거 → raw value 그대로 사용
10)
11
12text = "오늘은 정말 즐겁고 행복한 최고의 하루였어!"
13result = regressor(text)[0]
14
15print("입력 문장:", text)
16print("감정 스코어:", result["score"])| Metric | Score |
|---|---|
| Eval MAE | 0.0461 |
| Eval Pearson Correlation | 0.9951 |
| Eval Loss | 0.00199 |
1@misc{HowRUEmotionRegression2025,
2 title={HowRU KoELECTRA Emotion Regression},
3 author={Lim, Yeri},
4 year={2025},
5 publisher={Hugging Face},
6 howpublished={\url{https://huggingface.co/LimYeri/HowRU-KoELECTRA-Emotion-Regression}}
7}