Skip to content

The code for the paper "ECR-Chain: Advancing Generative Language Models to Better Emotion Cause Reasoners through Reasoning Chains" (IJCAI-2024).

Notifications You must be signed in to change notification settings

hzp3517/ECR-Chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECR-Chain

The code for the paper "ECR-Chain: Advancing Generative Language Models to Better Emotion Cause Reasoners through Reasoning Chains" (IJCAI-2024).

The Appendix mentioned in the paper is present in here.

The code of "Supervised CEE" part is based on this version of lm-sys/FastChat.

Requirements

  • python==3.10
  • torch==1.13.1+cu116
  • transformers==4.28.1
  • fschat==0.2.15
  • deepspeed==0.9.0
  • peft==0.4.0.dev0
  • openai==0.27.8

Datasets

RECCON-DD Dataset

The original RECCON dataset can be found at this link.

We preprocessed the original RECCON-DD dataset and saved on RECCON_all_data.json. Note that there are some repetitive positive causal pairs in the original dataset, which are removed in our preprocessing process, following the KBCIN.

ECR-Chain Set

Follow the code or instructions in chatgpt/chatgpt_generation_for_construction.py to perform the 4-stage process on the RECCON-DD training set and construct the ECR-Chain Set.

Our constructed ECR-Chain Set can be found at here.

Few-shot CEE

Run the code chatgpt/chatgpt_generation_for_fewshot_cee.py to perform few-shot prompting with ECR-Chain on ChatGPT.

Other Prompts for CEE

You need to modify template_name in the above code if use other prompts:

  • Baseline Few-shot Prompt (directly predict the answer): CEE_fewshot
  • ECR-Chain: CEE_backward_v2_fewshot
  • ECR-Chain (without theme): CEE_backward_v3_fewshot
  • ECR-Chain (without theme and reactions): CEE_backward_v4_fewshot
  • ECR-Chain (without reactions): CEE_backward_v5_fewshot
  • ECR-Chain (only with stimuli): CEE_stimuli_fewshot

Supervised CEE

Train Scripts

  • Answer: EmoReasonLlama/scripts/lora_train_answer.sh
  • Reasoning: EmoReasonLlama/scripts/lora_train_reasoning.sh
  • Multi-task: EmoReasonLlama/scripts/lora_train_multitask.sh

Inference Scripts

  • Answer: EmoReasonLlama/scripts/inference_answer.sh
  • Reasoning: EmoReasonLlama/scripts/inference_reasoning.sh

Explainable ECR

Compare and analyze the quality of reasoning chains generated by two models via GPT-4. First save the two models' generated chains into json file and then get the GPT-4 analysis results via gpt4_eval/gpt4_generation.py.

About

The code for the paper "ECR-Chain: Advancing Generative Language Models to Better Emotion Cause Reasoners through Reasoning Chains" (IJCAI-2024).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published