Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attention Is All You Need #1

Closed
subinium opened this issue Jan 26, 2021 · 4 comments
Closed

Attention Is All You Need #1

subinium opened this issue Jan 26, 2021 · 4 comments
Labels

Comments

@subinium
Copy link
Owner

subinium commented Jan 26, 2021

Concept

Structure

  • Multi-head self-attention
    • Scaled Dot-Product Attention
  • Residual connection
  • Layer nomalization
  • Masked
  • Positional Encoding

Optimizer

  • Adam (warm up steps = 4000)

Regularization

  • Residual Dropout
  • Label Smoothing
@subinium
Copy link
Owner Author

참고할 내용

  • Encoder/Decoder 개수인 6에는 큰 의미가 없다고 함
  • 실제 구현차이 참고 https://tunz.kr/post/4
    • Sublayer 순서
    • Decoder에서 캐시 사용으로 (불필요한 계산을 줄여) 최적화
    • Data Sharding (한번에 데이터를 가져오는 게 아니라 하나씩 가져오고 셔플링을 작게 함)
    • 임베딩 레이어 가중치 초기화
    • Positional Encoding에 디테일한 차이

@subinium
Copy link
Owner Author

subinium commented Jan 26, 2021

Positional Encoding에 대해

  • 논문에서는 Convolutional Sequence to Sequence Learning을 참고논문으로 사용하며 positional encoding을 언급

    • 이 논문에서 직접적인 언급은 없지만 일부 stackoverflow를 보면 one-hot vector를 사용한 것으로 보인다.
  • 그럼 왜 Transformer에서는 sin, cos을 사용하여 positional encoding을 했을까? (sinusoidal singal)

    • 논문 3.5에서는 다음과 같이 언급이 되어 있다.
    • We chose this function because we hypothesized it would allow the model to easily learn to attend by relative positions, since for any fixed offset $k, PE_{pos+k}$ can be represented as a linear function of $PE_pos.$

    • 즉 위치 A와 위치 A+k는 상대적인 위치 k에만 영향(선형변환)을 받고 싶다는 뜻이다.
    • 이에 대한 증명 및 답은 이 링크가 잘 설명해준다. https://timodenk.com/blog/linear-relationships-in-the-transformers-positional-encoding/
  • 이후에 나온 논문에서는 absolute position이 아닌 다음과 같이 pairwise relative position을 추가해주는 게 성능이 더 좋다고 한다.

@subinium
Copy link
Owner Author

갑자기 든 의문 Multi-head Attention?

  • 여러 번 어텐션을 봐서 좀 더 성능을 높이는 느낌으로 Multi-head Attention을 사용하는 걸로 이해 (앙상블)
  • 이와 관련한 NIPS2019 논문

Label Smoothing이 왜 잘될까?

  • 관련하여 제프리 힌튼 교수 연구팀이 발표한 NIPS2019 When Does Label Smoothing Help? 논문
    • 잘 정리해준 ratsgo님의 블로그 Label Smoothing 이해하기
    • Knowledge Distillation보다는 안된다고 한다. (상호정보량의 감소)
    • 뭔가 관련하여 연구하면 재밌을 것 같은데 아이디어가 번뜩이지는 않는다ㅠ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant