boostcampaitech2 / mrc-level2-nlp-14

mrc-level2-nlp-14 created by GitHub Classroom
MIT License
10 stars 8 forks source link

[Dev] Reader Module 개발노트 #5

Closed KimDaeUng closed 2 years ago

KimDaeUng commented 2 years ago

3 과 동일한 이유(코드 확장성)로 Reader Module에 대해서도 동일하게 추상화 작업을 진행합니다. 다음과 같이 추상화 클래스를 설계하였으며, Reader 모델의 학습 및 추론을 관리하는 객체(-Reader)와 Reader 모델(-ReaderModel) 객체를 두는 방식입니다.

  1. BaseReader: Reader 모델 학습 및 추론 전반에 필요한 객체와 데이터 메서드를 통합관리하는 객체의 추상 클래스. 이를 상속받아 Extractive, Generative 별로 다른 기능을 구현. 대표적으로 다음 attribute, method 들을 포함.

    • Attributes
    • args
    • model_config
    • backbone_model
    • tokenizer
    • metric
    • trainer
    • dataset
    • eval_dataset
    • post_process_function
    • Methods
    • set_retrieved_doc(dataset:datasets.DatasetDict) : retrieved dataset을 입력받아 validation set을 eval_dataset attribute에 저장
    • set_dataset(dataset:datasets.DatasetDict) : train, valid set 입력받아 dataset attribute에 저장
    • get_trainer() -> soultion.trainers.Trainer : 모델 학습을 위한 Trainer 리턴
    • predict() : post_process_function이 지정되어 있는 경우 post processing을 거친 출력값, 그 외의 경우 모델의 output
  2. ReaderModel : MRC 모델의 추상클래스. huggingface의 구현체를 기반으로 커스텀하는 것을 가정함. Head를 변경하거나 RETRO, SG-NET, HAN을 추가

    • ExtractiveReaderModel : Extraction-based MRC 모델의 추상 클래스. Encoder 기반 AutoModelForQuestionAnswering으로 불러온 모델의 입출력을 따름
    • GenerativeReaderModel : Extraction-based MRC 모델의 추상 클래스. AutoModelForSeq2SeqLM 또는 Decoder 또는 Seq2Seq 기반AutoModelForQuestionAnswering으로 불러온 모델의 입출력을 따름

image

모델 확장성 관련

Amber-Chaeeunk commented 2 years ago

Generative Model Baseline

finished work

scheduled work

※ 하람님 class Args 변경 작업 완료 후, 진행할 작업 목록
KimDaeUng commented 2 years ago

ReaderModelBase 폐기 #9 와 같이 처리함

KimDaeUng commented 2 years ago

9e3a88b6dcddec7ac2c4ce10faa9c078018e196a Retrieval 코드와 통합 후 dependency 문제 해결을 위해 constant.py 경로 변경(solution.reader -> utils)