Skip to content

[BOOSTCAMP AI 3rd][NLP][🥉3등] 문장의 단어(Entity)에 대한 속성과 관계를 예측하는 인공지능 만들기

Notifications You must be signed in to change notification settings

jujeongho0/Relation_Extraction

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 

Repository files navigation

[NLP] 문장 내 개체간 관계 추출 대회 WrapUP 리포트 : KLUE_NLP_팀 리포트(10조).pdf

👋 팀원 소개

Members

김남현 민원식 전태양 정기원 주정호 최지민
Github Github Github Github Github Github

문장 내 개체간 관계 추출

  • train.csv: 총 32470개

  • test_data.csv: 총 7765개

  • Data 16bc4f53-f355-4b9d-968f-657bb5d9b5e5

  • Class 3f0beeb4-199e-412c-9a41-a4423582b506

  1. EDA

    • label
      Untitled

    • 문장 분포 확인
      output1

    • label별 문장 분포 확인
      output5

    • 학습 데이터의 Subject, Object 단어의 type 분포 확인 output6

    • 테스트 데이터의 Subject, Object 단어의 type 분포 확인
      output7

    • 학습 데이터 : id-subj_info-obj_info-sen-label-label_num 순서로 구조 재구성
      개선된 df JPG

    • 중복 데이터 : 84개의 중복 데이터 확인 후 제거

    • 오태깅 데이터 제거 : 5개의 오태깅 데이터 확인 후 제거

    • 데이터 교정 : 학습 데이터 중 subj_type, obj_type, label 이 잘못된 데이터를 교정 → 오히려 성능이 떨어져 원래의 학습 데이터를 사용

    • Easy Data Augmentation : KoEDA 라이브러리를 사용하여 Random Insertion, Random Deletion, Random Swap, Synonym Replacement 적용 → 성능 개선 효과 없었음

  2. Preprocess

    • Typed Entity marker(punct)

      • 논문 “An Improved Baseline for Sentence-level Relation Extraction” 참고 1 (11)

      원본 : 〈Something〉는 조지 해리슨이 쓰고 비틀즈가 1969년 앨범 《Abbey Road》에 담은 노래다.

      → Typed Entity marker(punct) : 〈Something〉는 # ^ [PER] ^ 조지 해리슨 # 이 쓰고 @ * [PER] * 비틀즈 @ 가 1969년 앨범 《Abbey Road》에 담은 노래다.

      ⇒ [CLS] 〈Something〉는 # ^ [PER] ^ 조지 해리슨 # 이 쓰고 @ * [PER] * 비틀즈 @ 가 1969년 앨범 《Abbey Road》에 담은 노래다. [SEP]

    • Typed Entity marker(punct) + Query

      • 논문 “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding” 참고 1 (12)

      ⇒ 기존 BERT의 Pretain 방식과 유사한 input으로 만들어줌

      원본 : 〈Something〉는 조지 해리슨이 쓰고 비틀즈가 1969년 앨범 《Abbey Road》에 담은 노래다.

      → Typed Entity marker(punct) : 〈Something〉는 # ^ [PER] ^ 조지 해리슨 # 이 쓰고 @ * [PER] * 비틀즈 @ 가 1969년 앨범 《Abbey Road》에 담은 노래다.

      → Query : @ * [PER] * 비틀즈 @ 와 # ^ [PER] ^ 조지 해리슨 # 의 관계

      ⇒ [CLS] @ * [PER] * 비틀즈 @ 와 # ^ [PER] ^ 조지 해리슨 # 의 관계 [SEP] 〈Something〉는 # ^ [PER] ^ 조지 해리슨 # 이 쓰고 @ * [PER] * 비틀즈 @ 가 1969년 앨범 《Abbey Road》에 담은 노래다. [SEP]

    • Standard with Entity Location Token

      • 논문 “엔티티 위치 정보를 활용한 한국어 관계 추출 모델 비교 및 분석” 참고 1 (13)

      원본 : 〈Something〉는 조지 해리슨이 쓰고 비틀즈가 1969년 앨범 《Abbey Road》에 담은 노래다.

      → Standard with Entity Location Token : 〈Something〉는 [OBJ] 조지 해리슨 [/OBJ] 이 쓰고 [SUB] 비틀즈 [/SUB] 가 1969년 앨범 《Abbey Road》에 담은 노래다.

      ⇒ [CLS] 〈Something〉는 [OBJ] 조지 해리슨 [/OBJ] 이 쓰고 [SUB] 비틀즈 [/SUB] 가 1969년 앨범 《Abbey Road》에 담은 노래다. [SEP]

    • Backtranslation : Selenium을 활용한 크롤링을 통해 한국어 → 영어 → 한국어 번역

      원본 : 〈Something〉는 조지 해리슨이 쓰고 비틀즈가 1969년 앨범 《Abbey Road》에 담은 노래다.

      → "Something" is a song written by George Harrison and included by the Beatles on their 1969 album Abbey Road.

      ⇒ "Something"은 조지 해리슨이 작곡하고 비틀즈가 1969년 앨범 Abbey Road에 포함시킨 노래입니다.

    • 성능 비교(micro f1)

      (AutoModelForSequenceClassification.from_pretrained("klue/roberta-large"))

      • Typed Entity marker(punct) : 71%
      • Typed Entity marker(punct) + Query : 73%
      • Standard with Entity Location Token : 70%
      • Backtranslation : 72% → 생성 문장을 살펴보면 저품질 문장이 많음
  3. Model

    • Pretrained Model

      • klue/bert-base
      • klue/roberta-large
    • Additional Layer

      • AutoModelForSequenceClassification fc

      • FC fc1

      • BiLSTM bilstm

      • BiGRU bigru

      • BiGRU + Multi-Head-Attention + BiGRU

        • 논문 “UO UP V2 at HAHA 2019: BiGRU Neural Network Informed with Linguistic Features for Humor Recognition” 참고 mha
  • 성능 비교(micro f1)

    (Typed Entity marker(punct) + Query)

    • AutoModelForSequenceClassification : 74.9%
    • FC : 74.3%
    • BiLSTM : 75.6%
    • BiGRU : 75.1%
    • BiGRU + Multi-Head-Attention + BiGRU : 74.4%
  1. Hyper Parameter

    • Learning Rate

      • 3e - 5
      • warmup_ratio : 0.1
      • decay to 0
      • weight decay : 0.01 → overfitting 방지

      → 논문 “An Improved Baseline for Sentence-level Relation Extraction” 참고 1 (14)

    • Batch Size

      • 64
      • 32

      Out Of Memory가 일어나지 않는 선에서 Batch Size는 클수록 성능이 좋았음

    • max_len : 입력 Sentence의 최대 길이

      • 160
      • 256

      성능은 비슷했지만, 256은 batch size를 64로 했을 때, Out Of Memory가 발생해 160을 사용

    • Epoch

      • 5
      • 10

      똑같은 조건에서 Epoch가 10일 때, 성능이 더 떨어졌고, Overfitting이 발생했다고 판단

    • Loss Function

      • Cross Entropy : Transformer의 Default
      • Focal Loss : Class Imabalance를 개선하지만 CE와 성능 차이가 없었음
      • Label Smoothing : 0.1 → Class Imbalance 개선
    • Optimizer

      • AdamW : Transformer의 Default
  2. Train

    • StratifiedKFold : 성능 개선 효과 없었음
  3. SOTA 모델

    • Preprocess : Typed Entity marker(punct) + Query

    • Model

      • Pretrained Model : “klue/roberta-large”
      • Additional Layer : BiLSTM
    • Hyper Parameter

      • Learning Rate

        • 3e - 5
        • warmup_ratio : 0.1
        • decay to 0
        • weight decay : 0.01
      • Batch Size : 64

      • max_len : 160

      • Epoch : 5

      • Loss Function

        • Cross Entropy
        • Label Smoothing : 0.1
      • Optimizer : AdamW

  4. Ensemble

    • Soft Voting
      • 5개의 모델 : 75.5%
        • AutoModelForSequenceClassification : 74.9%
        • FC : 74.3%
        • BiLSTM : 75.6%
        • BiGRU : 75.1%
        • BiGRU + Multi-Head-Attention + BiGRU : 74.4%
      • 상위 3개의 모델 : 76.7338%
        • AutoModelForSequenceClassification : 74.9%
        • BiLSTM : 75.6%
        • BiGRU : 75.1%
  5. 최종 결과

    • Public(11팀 中 2등) 1 (15)

    • Private(11팀 中 3등) 1 (16)

  6. 프로토타입 (streamlit) GIF 2022-05-19 오후 1-24-24

About

[BOOSTCAMP AI 3rd][NLP][🥉3등] 문장의 단어(Entity)에 대한 속성과 관계를 예측하는 인공지능 만들기

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 94.3%
  • Python 5.7%