Khriis commited on
Commit
d8dee66
·
verified ·
1 Parent(s): 230f235

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +125 -0
README.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ tags:
6
+ - psychology
7
+ - emotion-recognition
8
+ - nlp
9
+ - question-answering
10
+ - trigger-extraction
11
+ datasets:
12
+ - daily_dialog
13
+ inference: false
14
+ ---
15
+
16
+ # RECCON: Emotional Trigger Extraction Model
17
+
18
+ **RECCON** (Recognizing Emotion Cause in CONversations) is a model designed to identify and extract the specific text spans (triggers) within a conversation that correspond to a labeled emotion.
19
+
20
+ This repository contains the weights and custom inference handler to deploy RECCON as a **Hugging Face Inference Endpoint**.
21
+
22
+ ## 🧠 Model Details
23
+
24
+ - **Task**: Extractive Question Answering (Span Extraction)
25
+ - **Base Model**: `roberta-base`
26
+ - **Training Dataset**: [RECCON Dataset](https://github.com/declare-lab/RECCON) (derived from DailyDialog)
27
+ - **Paper**: [Recognizing Emotion Cause in Conversations (Poria et al., 2021)](https://link.springer.com/article/10.1007/s12559-020-09790-7)
28
+
29
+ ## 🚀 Deployment (Inference Endpoints)
30
+
31
+ This repository is structured to be deployed directly to [Hugging Face Inference Endpoints](https://ui.endpoints.huggingface.co/).
32
+
33
+ ### Prerequisites
34
+ Ensure the following files are present in the root of this repository:
35
+ 1. `handler.py`: The custom inference logic (included).
36
+ 2. `requirements.txt`: Dependencies (included).
37
+ 3. `model.safetensors` (or `pytorch_model.bin`): The model weights.
38
+ 4. `config.json`: The RoBERTa model configuration.
39
+ 5. `tokenizer.json` / `vocab.json`: Tokenizer files.
40
+
41
+ ### Configuration
42
+ When creating the endpoint:
43
+ - **Task**: Select **Custom** or **Question Answering**.
44
+ - **Container Type**: The custom `handler.py` will automatically be detected and used.
45
+
46
+ ## 💻 API Usage
47
+
48
+ The endpoint accepts a JSON payload containing an `utterance` and its associated `emotion`. It returns the specific phrase(s) that triggered that emotion.
49
+
50
+ ### Request Format
51
+
52
+ **Single Input:**
53
+ ```json
54
+ {
55
+ "inputs": {
56
+ "utterance": "I'm so excited about the promotion!",
57
+ "emotion": "happiness"
58
+ }
59
+ }
60
+ ```
61
+
62
+ **Batch Input (Recommended):**
63
+ ```json
64
+ {
65
+ "inputs": [
66
+ {
67
+ "utterance": "I'm so excited about the promotion!",
68
+ "emotion": "happiness"
69
+ },
70
+ {
71
+ "utterance": "I really miss my family back home.",
72
+ "emotion": "sadness"
73
+ }
74
+ ]
75
+ }
76
+ ```
77
+
78
+ ### Response Format
79
+
80
+ The model returns a list of objects containing the extracted triggers.
81
+
82
+ ```json
83
+ [
84
+ {
85
+ "utterance": "I'm so excited about the promotion!",
86
+ "emotion": "happiness",
87
+ "triggers": [
88
+ "excited about the promotion"
89
+ ]
90
+ },
91
+ {
92
+ "utterance": "I really miss my family back home.",
93
+ "emotion": "sadness",
94
+ "triggers": [
95
+ "miss my family"
96
+ ]
97
+ }
98
+ ]
99
+ ```
100
+
101
+ ## 🛠️ logic (handler.py)
102
+
103
+ The custom handler performs the following steps:
104
+ 1. **Preprocessing**: Formats the input into a Question-Answering format: *"Extract the exact short phrase (<= 8 words) from the target utterance that most strongly signals the emotion {emotion}..."*
105
+ 2. **Inference**: Runs the RoBERTa model to predict start and end logits.
106
+ 3. **Post-processing**:
107
+ * Extracts the best text span.
108
+ * Filters out stopwords.
109
+ * Ensures the trigger is a valid substring of the original text.
110
+ * Deduplicates overlapping triggers.
111
+
112
+ ## 📚 Citation
113
+
114
+ If you use this model, please cite the original paper:
115
+
116
+ ```bibtex
117
+ @article{poria2021recognizing,
118
+ title={Recognizing Emotion Cause in Conversations},
119
+ author={Poria, Soujanya and Majumder, Navonil and Hazarika, Devamanyu and Ghosal, Deepanway and Bhardwaj, Rishabh and Jian, Samson Yu Bai and Hong, Pengfei and Ghosh, Romila and Roy, Abhinaba and Chhaya, Niyati and others},
120
+ journal={Cognitive Computation},
121
+ pages={1--16},
122
+ year={2021},
123
+ publisher={Springer}
124
+ }
125
+ ```