Downloads · 30 days
11
17% of all-time downloads
dhyann2815/roberta-empathy-classifier
roberta-empathy-classifier is a text classification model from dhyann2815. Use it when you need a label for a piece of text.
This is a binary text classification model trained to detect empathy in text. It takes a piece of text and classifies it as either 1 (empathetic) or 0 (not empathetic). The model is built on top of roberta-base using…
Downloads · 30 days
11
17% of all-time downloads
All-time downloads
64
Public
Parameters
125M
1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors499 MB · 93%
From the Hugging Face model README
This is a binary text classification model trained to detect empathy in text. It takes a piece of text and classifies it as either 1 (empathetic) or 0 (not empathetic). The model is built on top of roberta-base using the simpletransformers library.
The primary goal of this model is to analyze text (like chat transcripts, forum posts, or user feedback) and identify whether the author is demonstrating empathy.
The model was trained on the AcnEmpathize_dataset.csv.
[1.0, 3.0]) to aggressively counteract the heavy dataset imbalance.The model was fine-tuned using simpletransformers with the following hyperparameters to optimize minority class detection:
FacebookAI/roberta-base[1.0, 3.0]Based on our 30% test split, the model achieved the following results after hyperparameter tuning:
Confusion Matrix Summary:
(Note: The model successfully learned to identify the minority empathetic class, dramatically improving True Positives (from 0 to 335) and AUROC while maintaining strong overall accuracy.)
You can load and use this model directly with the simpletransformers library:
from simpletransformers.classification import ClassificationModel
import numpy as np
# Initialize the model
model = ClassificationModel(
"roberta",
"dhyann2815/roberta-empathy-classifier",
use_cuda=False # Set to True if you have a GPU
)
# Define prediction function with confidence score
def predict_empathy(text):
predictions, raw_outputs = model.predict([text])
logits = raw_outputs[0]
probabilities = np.exp(logits) / np.sum(np.exp(logits))
confidence = np.max(probabilities) * 100
status = "empathetic" if predictions[0] == 1 else "not empathetic"
return status, round(confidence, 2)
# Run a prediction
status, confidence = predict_empathy("I'm so sorry you're going through this, that sounds really difficult.")
print(f"Prediction: {status} (Confidence: {confidence}%)")