/KLUE-NLI

๐Ÿ… Top 10 in "ํ•œ๊ตญ์–ด ๋ฌธ์žฅ ๊ด€๊ณ„ ๋ถ„๋ฅ˜ ๊ฒฝ์ง„๋Œ€ํšŒ" - Dacon

Primary LanguagePython

KLUE-NLI

๋Œ€ํšŒ ์„ค๋ช…

  • Premise๋ฌธ์žฅ์„ ์ฐธ๊ณ ํ•˜์—ฌ hypothesis ๋ฌธ์žฅ์˜ ์ฐธ, ๊ฑฐ์ง“, ์ค‘๋ฆฝ์„ ํŒ๋ณ„ํ•ด์•ผํ•œ๋‹ค.
premise: ์”จ๋ฆ„์€ ์ƒ๊ณ ์‹œ๋Œ€๋กœ๋ถ€ํ„ฐ ์ „ํ•ด์ ธ ๋‚ด๋ ค์˜ค๋Š” ๋‚จ์ž๋“ค์˜ ๋Œ€ํ‘œ์ ์ธ ๋†€์ด๋กœ์„œ, ์†Œ๋…„์ด๋‚˜ ์žฅ์ •๋“ค์ด ๋„“๊ณ  ํ‰ํ‰ํ•œ ๋ฐฑ์‚ฌ์žฅ์ด๋‚˜ ๋งˆ๋‹น์—์„œ ๋ชจ์—ฌ ์„œ๋กœ ํž˜๊ณผ ์Šฌ๊ธฐ๋ฅผ ๊ฒจ๋ฃจ๋Š” ๊ฒƒ์ด๋‹ค.
hypothesis: ์”จ๋ฆ„์˜ ์—ฌ์ž๋“ค์˜ ๋†€์ด์ด๋‹ค.

label: contradiction

ํ‰๊ฐ€๋ฐฉ๋ฒ•

  • Accuracy
  • Public: Test Data ์ค‘ Random sampling 60%
  • Private: ์ „์ฒด Test Data

Dataset

  • Train: 24998
  • Test: 1666

Hardware

  • GPU: Colab Pro P100

์‹คํ–‰

Install Requirements and Data Unzip

pip install -r requirements.txt
unzip -q './data/open.zip' -d './data'

Run

# Train
python train.py --explain

# Inference
python inference.py --explain

Code

+- data
|   +- klue-nli-v1.1.tar.gz (klue_dev ์ œ์ž‘์— ์‚ฌ์šฉ)
|   +- klue_dev.csv (KLUE OFFICAL dev dataset)
|   +- kor_nli_valid.csv (kakaobrain - kornli dataset) 
|   +- open.zip (Original Dataset)
+- EDA
|   +- EDA.ipynb (Dataset EDA)
|   +- aug_dataset.ipynb (Dataset augmentation => klue_dev.csv & kor_nli_valid.csv)
+- utils
|   +- collate_functions.py
|   +- loss.py
|   +- mk_data.py
|   +- nlpdata_eda.py
|   +- random_seed.py
+- requirements.txt
+- dataset.py
+- model.py
+- train.py
+- train_kfold.py
+- inference.py

Core Strategy

  • KLUE/RoBERTa-large + Classifier Head with Hyperparmeter Tuning (Baseline์œผ๋กœ ์ง€์ •)
    • KLUE/RoBERTa-large๋ฅผ backbone์œผ๋กœ ํ™œ์šฉํ•œ NLI ๋ชจ๋ธ ์ ์šฉ
    • ๋‹ค์–‘ํ•œ HyperParameter Tuning ์‹คํ—˜์„ ํ†ตํ•œ ์„ฑ๋Šฅ ํ–ฅ์ƒ
  • Self-Explaining Structures Improve NLP Models (Paper Review ์ฐธ๊ณ )
    • KLUE/RoBERTa-large๋ฅผ backbone์œผ๋กœ ํ™œ์šฉ (intermediate layer)
    • SIC layer์ถ”๊ฐ€ (backbone model์—์„œ์˜ output layer๋“ค ์‚ฌ์ด์˜ ์กฐํ•ฉ ์ƒ์„ฑ) => span ์ •๋ณด ์ „๋‹ฌ
    • Interpreatation layer๋ฅผ ์ถ”๊ฐ€ => span์—์„œ์˜ ๊ฐ€์ค‘์น˜ ์ถ”์ถœ
    • ์ถ”์ถœ๋œ ๊ฐ€์ค‘์น˜์™€ span ์ •๋ณด๋ฅผ weighted sumํ•˜์—ฌ ์ตœ์ข… output ์ถœ๋ ฅ
  • ์™ธ๋ถ€ Dataset ์ •์ œ ๋ฐ ํ™œ์šฉ
    • KLUE OFFICIAL Dev Dataset ํ™œ์šฉ
    • KakaoBrain KorNLI Dataset ์ค‘ Human Trnaslated Data๋งŒ ํ™œ์šฉ (Original Dataset๊ณผ ์œ ์‚ฌํ•œ Data ์ถ”๊ฐ€)
  • Out of Fold Ensemble
    • Stratified KFold๋ฅผ Ensemble ์ง„ํ–‰
    • Baseline + Explaining Model Ensemble

๊ฒฐ๊ณผ

Single Baseline(train:valid=8:2) Single Self-Explaining(train:valid=8:2)
Accuracy 0.872 0.864
Baseline KFold Self-Explaining KFold Baseline + Self-Explaining(Public) Baseline + Self-Explaining(Private)
Accuracy 0.888 0.874 0.89 0.89015

๊ณผ์ œ

  • Self-Explaining์— ๋Œ€ํ•œ Error Analysis
    • ์–ด๋–ค ๋ถ€๋ถ„์— weight๋ฅผ ์ฃผ์–ด ์˜ˆ์ธก์„ ์ง„ํ–‰ํ–ˆ๋Š”๋ฐ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ