1defemotion_extraction_chain(context, target):2# Setup labels.3 labels_list =["anger","disgust","fear","joy","sadness","surprise","neutral"]4# Setup Chain-of-Thought5 step1 =f"Given the conversation {context}, which text spans are possibly causes emotion on {target}?"6 span = ask(step1)7 step2 =f"{step1}. The mentioned text spans are about {span}. Based on the common sense, what "+f"is the implicit opinion towards the mentioned text spans that causes emotion on {target}, and why?"8 opinion = ask(step2)9 step3 =f"{step2}. The opinion towards the text spans that causes emotion on {target} is {opinion}. "+f"Based on such opinion, what is the emotion state of {target}?"10 emotion_state = ask(step3)11 step4 =f"{step3}. The emotion state is {emotion_state}. Based on these contexts, summarize and return the emotion cause only."+"Choose from: {}.".format(", ".join(labels_list))12# Return the final response.13return ask(step4)
Initialize device, model and tokenizer as follows:
1# setup history context (conv_turn_1)2conv_turn_1 ="John: ohh you made up!"3# setup utterance.4conv_turn_2 ="Jake: yaeh, I could not be mad at him for too long!"5context = conv_turn_1 + conv_turn_2
6# Target is considered as the whole conv-turn mentioned in context.7target = conv_turn_2
8flant5_response = emotion_extraction_chain(context, target)9print(f"Emotion state of the speaker of `{target}` is: {flant5_response}")
The response is as follows:
Emotion state of the speaker of Jake: yaeh, I could not be mad at him for too long! is: anger
This model represent a fine-tuned version of the Flan-T5 on ECAC-2024 competition dataset of conversations from the F.R.I.E.N.D.S. TV Show.
Since dataset represent three-scale output answers ["anger", "disgust", "fear", "joy", "sadness", "surprise", "neutral"]
the behavior in general might be biased to this particular task.
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Simply follow the Direct Use secion or proceed with the following GoogleColab notebook.
Training Details
Training Data
We purely rely on the data provided by ECAC-2024 competition organizers.