이론

FNet으로 Text Classification 해보기

Simon Yoon 2022. 11. 3. 22:05

인공지능 팩토리 세미나 발표 by 김노은

 

Source:

https://keras.io/examples/nlp/fnet_classification_with_keras_nlp/

https://aifactory.space/learning/detail/2187

https://towardsdatascience.com/googles-fnet-mixing-tokens-with-fourier-transforms-f98778168c45


Introduction

  • FNet: Mixing Tokens w/ Fourier Transforms
    • Fourier Transforms(FTs)
    • 푸리에 변환은 한 신호(signal)을 수학적인 처리를 통해 진동수(frequency)의 성분으로 분해하는 것이다. 푸리에 변환을 통해 특정 시간 길이의 음성 조각들이 각각의 주파수 성분들을 얼마나 가지고 있는지를 의미하는 스펙트럼을 얻을 수 있다.
    • (추가 참고자료: towardsdatascience.com)

FNet - Self Attention - Architecture

  • Main idea
    • Self Attention 을 Fourier Transformation 으로 대체
    • Fourier Transformation 을 통한 Mixing 으로 Token 간 정보 파악 가능
    • Embedding Inputs 입력 시 Fourier Transformation 에서 2D DFT(2D Discrete Fourier Transform) 수행
  • Self Attention
    • NLP 분야 SOTA 모델의 근본 아이디어 → 트랜스포머(transformer)의 핵심 구성요소
    • 쿼리(Query), 키(Key), 밸류(Value)의 3개 요소를 통해 단어 사이의 관계(문맥적 관계성)를 파악하는 과정
    • 시퀀스의 길이에 따라 계산 복잡도가 증가하는 주의점 존재, 병목현상 관리 필요
      • transformers have quadratic complexity (O(N^2)) due to the non-linearity (However, Fourier transforms are linear)
    • (추가 참고자료: ratsgo.github.io)
  • FNet architecture

  • Fourier transform 을 통한 정보 교환 (The only difference is that self-attention layer of the encoder is replaced with a Fourier layer)
  • Frequency domain 의 각 성분은 모든 Token 들의 조합으로 표현
  • Result

→ Slightly lower accuracy than BERT

→ But much faster in training steps

(추가 참고자료: arxiv.org)

 

Code Example