Text Classification
Transformers
PyTorch
Safetensors
English
empathy_classifier
feature-extraction
empathy
mental-health
psychology
custom_code
Instructions to use RyanDDD/empathy-mental-health-reddit-ER with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RyanDDD/empathy-mental-health-reddit-ER with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="RyanDDD/empathy-mental-health-reddit-ER", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("RyanDDD/empathy-mental-health-reddit-ER", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- modeling_empathy.py +7 -1
modeling_empathy.py
CHANGED
|
@@ -9,7 +9,13 @@ import torch.nn.functional as F
|
|
| 9 |
import math
|
| 10 |
from torch.nn import CrossEntropyLoss
|
| 11 |
from transformers import PreTrainedModel, PretrainedConfig, RobertaModel, RobertaConfig
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
class Norm(nn.Module):
|
|
|
|
| 9 |
import math
|
| 10 |
from torch.nn import CrossEntropyLoss
|
| 11 |
from transformers import PreTrainedModel, PretrainedConfig, RobertaModel, RobertaConfig
|
| 12 |
+
|
| 13 |
+
# BertLayerNorm is deprecated, use nn.LayerNorm instead
|
| 14 |
+
try:
|
| 15 |
+
from transformers.models.bert.modeling_bert import BertLayerNorm
|
| 16 |
+
except ImportError:
|
| 17 |
+
# In newer versions, use LayerNorm directly
|
| 18 |
+
BertLayerNorm = nn.LayerNorm
|
| 19 |
|
| 20 |
|
| 21 |
class Norm(nn.Module):
|