๐Ÿ’ป Dev

ํ…์ŠคํŠธ ๊ฐ์ • ์ธ์‹ ๋ชจ๋ธ ํŒŒ์ธํŠœ๋‹

Gamddalki 2024. 5. 21. 19:06

 

1๏ธโƒฃ ๋ชจ๋ธ ์„ ์ • - RoBERTa

๋จผ์ € ํ…์ŠคํŠธ ๊ฐ์ • ์ธ์‹์— ์‚ฌ์šฉ๋˜๋Š” ๋‹ค์–‘ํ•œ ๋ชจ๋ธ ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ์ •ํ•˜๊ธฐ ์œ„ํ•ด XLnet, ELECTRA, BERT, RoBERTa๋ฅผ ๋Œ€์ƒ์œผ๋กœ ๋™์ผํ•œ ์กฐ๊ฑด ํ•˜์— ์ •ํ™•๋„๋ฅผ ์‹คํ—˜ํ–ˆ๋‹ค. ์ด ์ค‘ RoBERTa๊ฐ€ ๊ฐ€์žฅ ๋†’์€ ์„ฑ๋Šฅ์„ ๋ณด์˜€๊ธฐ์— RoBERTa๋ฅผ ์ฑ„ํƒํ•ด ํŒŒ์ธํŠœ๋‹์„ ํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ๊ณ , ์ด๋Š” ์„ ํ–‰์—ฐ๊ตฌ์™€ ๋™์ผํ•œ ๊ฒฐ๊ณผ์˜€๋‹ค.

Comparative analyses of bert, roberta, distilbert, and xlnet for text-based emotion recognition (IEEE ICCWAMTIP'20)
Exploring transformers models for emotion recognition: A comparision of BERT, DistilBERT, RoBERTa, XLNET and ELECTRA (Proceedings of the 2022 3rd International Conference on Control, Robotics and Intelligent System)

 

2๏ธโƒฃ ๋ฐ์ดํ„ฐ ์…‹ ์„ ์ • - Empathetic Dialogues

ํ•ด๋‹น ๋ฐ์ดํ„ฐ ์…‹์€ ํŠน์ • ๊ฐ์ •์„ ํฌํ•จํ•˜๋Š” ์‹ค์ œ ๋Œ€ํ™” ์ƒํ™ฉ์„ ์—ฐ์ถœํ•œ ๊ฒƒ์œผ๋กœ, ๋ฐ์ดํ„ฐ๊ฐ€ ๋น„๊ต์  clean ํ•œ ๊ฒƒ์œผ๋กœ ์•Œ๋ ค์ ธ ์žˆ๋‹ค. ์ผ์ƒ ์ƒํ™œ์˜ ๋Œ€ํ™” ๋ฐ ์ƒํ™ฉ ์†์—์„œ ๊ฐ์ •์„ ์ธ์‹ํ•˜๊ณ ์ž ํ•˜๋Š” ์šฐ๋ฆฌ์˜ ๋ชฉํ‘œ์™€ ๋งž๊ธฐ์— ํ•ด๋‹น ๋ฐ์ดํ„ฐ ์…‹์„ ์ฑ„ํƒํ•˜์˜€๋‹ค.

๋ฐ์ดํ„ฐ ์…‹์˜ head๋ฅผ ์ฐ์–ด๋ณด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

conv_id utterance_idx context prompt speaker_idx utterance selfeval tags
hit:0_conv:1 1 sentimental I remember going to the fireworks with my best friend. There was a lot of people_comma_ but it only felt like us in the world. 1 I remember going to see the fireworks with my best friend. It was the first time we ever spent time alone together. Although there was a lot of people_comma_ we felt like the only people in the world. 5|5|5_2|2|5  
hit:0_conv:1 2 sentimental I remember going to the fireworks with my best friend. There was a lot of people_comma_ but it only felt like us in the world. 0 Was this a friend you were in love with_comma_ or just a best friend? 5|5|5_2|2|5  
hit:0_conv:1 3 sentimental I remember going to the fireworks with my best friend. There was a lot of people_comma_ but it only felt like us in the world. 1 This was a best friend. I miss her. 5|5|5_2|2|5  
hit:0_conv:1 4 sentimental I remember going to the fireworks with my best friend. There was a lot of people_comma_ but it only felt like us in the world. 0 Where has she gone? 5|5|5_2|2|5  
hit:0_conv:1 5 sentimental I remember going to the fireworks with my best friend. There was a lot of people_comma_ but it only felt like us in the world. 1 We no longer talk. 5|5|5_2|2|5  

ํ•˜๋‚˜์˜ ๋Œ€ํ™”์— ์ฐธ์—ฌํ•˜๋Š” ๋‘ speaker๊ฐ€ ์žˆ๊ณ , ์ด ์ค‘ ํ•ด๋‹น ๊ฐ์ •์— ๊ด€ํ•œ ๋ฐœํ™”๋ฅผ ์ง„ํ–‰ํ•˜๋Š” ์‚ฌ๋žŒ์€ 1์ด๋‹ค.

๋ฐ์ดํ„ฐ์…‹์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ–ˆ์„ ๊ฒฝ์šฐ์˜ ๋ชจ๋ธ ์ •ํ™•๋„๋Š” Test Loss: 1.4786 | Test Accuracy: 0.5771์˜€๋‹ค.

์šฐ๋ฆฌ๋Š” ์œ„ ๋ฐ์ดํ„ฐ ์…‹ ์ค‘ context (emotion), utterance, prompt๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค. prompt์˜ ๊ฒฝ์šฐ์—๋Š” EDA ์‹œ์— ํ™œ์šฉํ–ˆ๋‹ค.
๋˜ํ•œ, conv_id ๊ฐ€ ๋™์ผํ•œ ํ…์ŠคํŠธ๋Š” ํ•˜๋‚˜์˜ ๋ฐ์ดํ„ฐ๋กœ ๋ณด๋„๋ก ํ•˜์˜€์œผ๋ฉฐ, speaker_idx๊ฐ€ 1์ธ ๋ฐ์ดํ„ฐ๋งŒ์„ ๋ชจ์•„ ํ•˜๋‚˜๋กœ ํ†ตํ•ฉํ•˜์—ฌ monologue๋กœ ๋งŒ๋“ค์—ˆ๋‹ค.

 

3๏ธโƒฃ ๊ฐ์ • ์žฌ๋ผ๋ฒจ๋ง

Empathetic Dialogues ๋ฐ์ดํ„ฐ ์…‹์€ ์ด 32๊ฐœ์˜ ๊ฐ์ •์œผ๋กœ ๋ผ๋ฒจ๋ง์ด ๋˜์–ด์žˆ๋‹ค.

์ด๋ฅผ Anger, Disgust, Fear, Sadness, Contentment, Excitement, Awe, Amusement์˜ 8๊ฐœ ๋ผ๋ฒจ๋กœ ์žฌ๋ผ๋ฒจ๋งํ•˜์˜€๋‹ค.
๋ถ€์ •์  ๊ฐ์ •์— ํ•ด๋‹นํ•˜๋Š” Anger, Disgust, Fear, Sadness๋Š” ๋„๋ฆฌ ์•Œ๋ ค์ง„ Plutchick์˜ ๊ฐ์ • ๋ถ„๋ฅ˜๋ฅผ ๋”ฐ๋ฅธ ๊ฒƒ์ด๋‹ค.
๊ธ์ •์  ๊ฐ์ •์˜ ๊ฒฝ์šฐ, ๋ถ€์ •์  ๊ฐ์ •์˜ ๋ผ๋ฒจ์˜ ์ˆ˜์™€ ๋™์ผํ•˜๊ฒŒ๋”
Contentment, Excitement, Awe, Amusement๋ฅผ ์‚ฌ์šฉํ•˜์˜€๋Š”๋ฐ, ์ด๋Š” ์„ ํ–‰ ์—ฐ๊ตฌ์—์„œ ์ œ์•ˆ๋˜์—ˆ๋˜ Happiness์˜ finer grained version์— ํ•ด๋‹นํ•œ๋‹ค.
์ด์™€ ๊ฐ™์€ 8๊ฐœ ๊ฐ์ • ๋ผ๋ฒจ๋กœ์˜ ๋ถ„๋ฅ˜ ๋˜ํ•œ ์„ ํ–‰ ์—ฐ๊ตฌ์—์„œ ์ œ์•ˆ ๋ฐ ์‚ฌ์šฉ๋œ ์ ์ด ์žˆ๋‹ค.

๊ฐ์ • ์žฌ๋ผ๋ฒจ๋ง์€ SenticNet์˜ knowledge graph, BERT, spaCy, ๊ทธ๋ฆฌ๊ณ  Word2vec์„ ์ด์šฉํ•œ ๋ฒกํ„ฐ ์ž„๋ฒ ๋”ฉ์˜ ์œ ์‚ฌ๋„ ๊ณ„์‚ฐ์„ ํ†ตํ•ด ์ง„ํ–‰ํ•˜์˜€๋‹ค. ์‚ฌ์šฉ๋œ ๋ฉ”์†Œ๋“œ๋งˆ๋‹ค ์„œ๋กœ ๋‹ค๋ฅธ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์˜€๋˜ context์˜ ๊ฒฝ์šฐ์—๋Š” ๋ชจํ˜ธํ•œ ๊ฒƒ์œผ๋กœ ํŒ๋‹จ, ์‚ฌ์šฉํ•  ๋ฐ์ดํ„ฐ ์…‹์—์„œ ์ œ์™ธ(10๊ฐœ ๋ผ๋ฒจ - 'anticipating', 'prepared', 'caring', 'hopeful', 'confident', 'nostalgic', 'disappointed', 'sentimental', 'trusting', 'faithful')ํ•˜์˜€๋‹ค.

emotion_mapping = {
    'anger': 0, 'disgust': 1, 'fear': 2, 'sadness': 3, 'contentment': 4, 'excitement': 5, 'awe': 6, 'amusement': 7
}
emotion_to_label = {
    'surprised': 6, 'excited': 5, 'angry': 0, 'pround': 6 'sad': 3,
    'annoyed': 1, 'grateful': 6, 'lonely': 3, 'afraid': 2, 'terrified': 2,
    'guilty': 1, 'impressed': 6, 'disgusted': 1, 'furious': 0, 'anxious': 2,
    'joyful': 7, 'jealous': 1, 'content': 4,
		'devastated': 3, 'embarassed': 1, 'ashamed': 1, 'apprehensive': 2,
}
emotion_except = {
	'anticipating', 'prepared', 'caring', 'hopeful', 'confident', 'nostalgic', 'disappointed', 'sentimental', 'trusting', 'faithful'
}

์ด ๊ณผ์ •์„ ํ†ตํ•ด ์ •ํ™•๋„๋ฅผ Test Loss: 0.5743 | Test Accuracy: 0.8159๊นŒ์ง€ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

 

4๏ธโƒฃ ํ•˜์ดํผํŒŒ๋ผ๋ฏธํ„ฐ ์กฐ์ •

RoBERTa ๋…ผ๋ฌธ์—์„œ ์ œ์•ˆ๋œ ์ตœ์ ์˜ ํ•˜์ดํผ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

  • batch size : 16, 32
  • ํ•™์Šต๋ฅ (Adam): 5e-5, 3e-5, 2e-5
  • epoch numbers: 2, 3, 4

์ด๋“ค์˜ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ์กฐํ•ฉ์„ ํ…Œ์ŠคํŠธํ•˜์˜€๊ณ , ๊ทธ ๊ฒฐ๊ณผ ๊ฐ€์žฅ ๋†’์€ ์ •ํ™•๋„๋ฅผ ๋ณด์ธ ๊ฒƒ์€ ์•„๋ž˜์˜ ์กฐํ•ฉ์ด์—ˆ๋‹ค.

  • batch size 16
  • ํ•™์Šต๋ฅ (Adam): 2e-5
  • epoch: 2

์ถ”๊ฐ€๋กœ ์•„๋ž˜ ํ•˜์ดํผ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ด์šฉํ–ˆ๋‹ค. 

  • LR ์Šค์ผ€์ค„๋Ÿฌ: get_linear_schedule_with_warmup (warmup ratio = 0.06)
  • weight decay: 0.1
  • eps: 1e-8
  • max length: 128

์ด์— Test Loss: 0.5362 | Test Accuracy: 0.8258์˜ ์ •ํ™•๋„๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

 

5๏ธโƒฃ EDA

๋ฐ์ดํ„ฐ ๋ถˆ๊ท ํ˜•์˜ ํ•ด๊ฒฐ์„ ์œ„ํ•ด Empathetic Dialogues์˜ prompt์™€ GoEmotions ๋ฐ์ดํ„ฐ ์…‹์„ ํ™œ์šฉํ•˜์˜€๋‹ค.

GoEmotions ๋ฐ์ดํ„ฐ ์…‹์˜ ๊ฒฝ์šฐ,  Empathetic Dialogues์™€ ๊ฐ™์ด ๊ฐ์ • ์žฌ๋ผ๋ฒจ๋ง์„ ์ง„ํ–‰ํ•˜์˜€๊ณ  ๊ทธ ์ค‘ amusement๋งŒ์„ ์‚ฌ์šฉํ–ˆ๋‹ค.

๊ทธ๋ฆฌํ•˜์—ฌ ์ตœ์ข…์ ์œผ๋กœ Test Loss: 0.3050 | Test Accuracy: 0.8973

์˜ ์ •ํ™•๋„๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

Classification Report for the Entire Test Set:
              precision    recall  f1-score   support

       anger       0.70      0.66      0.68       151
     disgust       0.86      0.84      0.85       467
        fear       0.87      0.92      0.89       292
     sadness       0.90      0.94      0.92       231
 contentment       0.83      0.82      0.82       342
  excitement       0.72      0.66      0.69        91
         awe       0.82      0.85      0.83       176
   amusement       0.96      0.95      0.96      1776

    accuracy                           0.90      3526
   macro avg       0.83      0.83      0.83      3526
weighted avg       0.90      0.90      0.90      3526

Test Accuracy (anger): 0.6623
Test Accuracy (disgust): 0.8437
Test Accuracy (fear): 0.9247
Test Accuracy (sadness): 0.9351
Test Accuracy (contentment): 0.8158
Test Accuracy (excitement): 0.6593
Test Accuracy (awe): 0.8523
Test Accuracy (amusement): 0.9544