Stanford CS224N NLP with Deep Learning | Spring 2022 | Guest Lecture: Scaling Language Models 강의 요약

2022. 7. 31. 00:19·AI/cs224n

https://www.youtube.com/watch?v=UFem7xa3Q2Q&list=PLoROMvodv4rOSH4v6133s9LFPRHjEmbmJ&index=24 

위 스탠퍼드 cs224n 강의를 듣고 요약한 글 입니다. 틀린 부분은 지적해주시면 감사하겠습니다.^^


outlines

1. motivations for LM,

2. Orders of Magnitude of Data,

3. Universality of Scaling Laws,

4. scale up LM - consiquencies

Fermi Estimates for LM

  • 문제, 기초지식+논리추론, 효율적 대략적 근사치 추정

Why you study language? — motivation

  1. AI : our species best attempt to encode everything about the world in as efficiently as possible.
    • Best way to encode books!
    • Best way to encode some text things!!!!
  2. Planty of datas in internet!!!!
  3. An AI that knows language can be asked anything, and we can get a lot of intuition from AI’s responses (compared to suggesting Go moves, classifying images.), which may help us to understand and align these models.
    • You can make these models align with what human performs
    • there’s really alot that you can explore.

Ingredients in ML

model, dataset, computational resources, loss function, choice of optimizer

So, how much of this stuff do we use?

Orders of Magnitude in Language Data

  • 내가 평생 읽는 책들보다, GPT-3 가 학습한 텍스트 양이 더 많음

Transformer LMs

actual NN to model language,

트랜스포머의 파라미터 개수
트랜스포머 계산량

대충, transformer의 모든 param들이

forward → 1add, 1 multiply

backwrad → 2add, 2 multiply

의 연산이 돼서, 계산양은 compute = 6PD 로 계산될 수 있다.

 

context length 는 크게 문제되지 않는다.

long sequences 를 처리할 때, 많은 계산이 일어날지 아닐지 궁금하다.

dense attention in transformer models = n^context_len (높은 편.)

하지만, 전체 transformer 계산에서 context_len 이 차지하는 비중을 보면 위의 수식처럼, N_context / 12*d_model 으로 크지 않다.

핵심: 모델이 커질수록, context의 길이는 항상 그렇게 크게 염려되는 대상은 아니다.

Transformer LMs and Orders of Magnitude

실제 transformer 계산을 위한 수치값은 뭘까?

GPU의 연산양을 고려하여 모델 학습 시간을 계산가능.

요즘은 1몰의 원자개수인 아보가드로 수 보다 큰 연산량을 연산할 수 도 있고 이건 엄청 흥미로운 지표이다.

Scaling Laws for Language Models

Scaling Laws

  • number of model parameters, dataset size, total compute used for training → performance of ML models
  • Performance = no bottleneck → less datasets, num_parameters, computation, bad information propagation in network
  • 최근 10년간 ML에서 유명한 논문들(ResNet, Layer Norm, Batch Nrom, …)을 압축해서 설명하라하면, they’re sort of alleviating bottlenecks where information wasn’t propagating nicely through your network.
    • NN은 matrix multiplication을 여러번 멋있게 하는 것 뿐이라는 점에서, 여러번 matrix multiplication을 수행한 결과는, projection onto its largest eigenspace 이다. very roughly 하게 말하면, 너가 가진 deep NN이 제대로 설정돼있지 않으면, 너는 signal 을 잃거나 information을 쉽게 잃을 수 있음.

Scaling Results

CORE RESULTS FOR SCALING LAWS FOR LANGUAGE MODELS

Compute — x_axis : Petaflops day unit. / 다양한 크기의 모델들을 서로다른 computing 자원?으로 학습한 결과.

computing이 느리면 학습속도도 느리고, Dataset, Parameter size가 충분하지 않으면 오류가 생기는 현상 = scaling law

내가 가진 computing power 와 budget이 한정되어있을 때,

batch size나 serial steps를 늘리는거보단, model size를 키우는게 더 좋다.

batch size를 키우면 serial steps를 더 늘릴 필요가 없다.

Q. 3개 그래프중 왼쪽꺼 보는 방법

A. x-axis 에서 compute 선택해, 그 지점에 있는 blue-curve 에 해당하는 model-size가 이상적인 model size이다.

  • 실증분석(empirical analysis) : 이 가설이 맞는지 아닌지 확인하는 연구.

  1. 모델의 구조와 scale law 는 상관없다. 어떤 모델이라도 잘 따른다.
  2. Language model 에서 LSTM은 100tokens 이후론 발전안되고 평평해진다. transformer가 확실히 성능 좋다.

transformer models에서 다양한 hyperparameters

셋 다 좋은 성능 가지는 분지가 있다.

  1. feed forward 층의 hidden dimension size와 loss의 관계
  2. layers 개수 : wide range of architectures 가 비슷한 성능 가진다.
  3. attention head dimension

optimize 하지 말란건 아니지만, 이 요인들은 그렇게 enormous difference가 아니다.

More on Loss vs Position in the Context

위의 요인들이 language 에만 국한된게 아니라 universial 하게 적용된다.

  • 모든 모델들이 할 수 있는 첫번째 word 를 추론하는 방법은, predict the unigram distribution ?

Q.

A. context 길수록 compute 더됨. BUT, 계산 전체의 일부로 보면 큰부분 아님. , model hyperparameter따라 다르겠지만, 대부분의 계산은 Matrix Multiply for Feed Forward part & Matrix Multiply to make Q, K, V and etc

GPT-3 의 경우, 진짜 1-2% 차이라 생각한다.

Other kinds of Datasets

다른 데이터셋, Scaling Law OK

data의 domain은 서로 다르지만, 모델 크기에 따라서 최적인 모델 크기는 대부분 비슷하다!!!

data 달라도, 이상적인 모델크기 같다.

scale up LM - consiquencies

scale up model → better performance?

YES! => Parameters 많을수록 performance gets better

데이터를 더 세세하게 볼 수 있기때문에 어떻게 보면 당연한 것.

Some Lessons from Scaling Laws

  • Scans are Useful : D, D/2, D/4, D/8 전부시도해봐라. cost 보다 큰 info 얻는다.

small model 에서는 new idea가 차이없는데, large model 에선 차이있는 경우 있다.


What I Learned ?

  • 모델의 compute 를 계산하는 방법을 알았다.
    • matmul, add 의 수를 세는 것.
    • forward 시, backward 시 각각 그 computation을 계산하여 복잡도를 알 수 있다.
  • LSTM을 Language Model로 training 시켰을 때, 100 token 이상의 context는 잘 처리하지 못한다. BUT transformer은 잘 처리한다.
  • Scaling Law
    • 고정된 model_parameters, compute 상황에서, Dataset이 적을수록 성능은 안나온다.
    • 고정된 Dataset, compute 상황에서, molde_parameter 가 작을수록 성능은 안나온다.
                              •  

'AI > cs224n' 카테고리의 다른 글

Transformer Encoder 동작 분석  (0) 2022.07.31
'AI/cs224n' 카테고리의 다른 글
  • Transformer Encoder 동작 분석
jh-rrr
jh-rrr
기술의 깊이에 집중하며 성장하길 지향합니다.
  • jh-rrr
    Embedded World
    jh-rrr
  • 전체
    오늘
    어제
    • 분류 전체보기 (64)
      • 소프트웨어 (17)
        • 프로그래밍 (2)
        • C (10)
        • Python (1)
        • 운영체제 (3)
        • 네트워크 (0)
      • Embedded Systems (16)
        • 리눅스 (10)
        • MCU 기본 (2)
        • 임베디드 레시피 (0)
      • Projects (1)
        • Cortex-M3 (1)
        • 재난 구조 로봇 (0)
      • AI (11)
        • Computer Vision (2)
        • Deep Learning (3)
        • cs224n (2)
        • cs231n (2)
      • 취업 준비 (0)
        • 프로젝트 & 자격증 (1)
      • 엔지니어링 뉴스 (3)
      • Paper Reviews (4)
      • Insights (8)
        • Seminar ! (2)
        • 서평 (4)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    conda: command not found
    리눅스
    리눅스 오류
    커널 이미지
    커널 이미지란
    stm32f 시리즈를 이용한 arm cortex-m3/m4 구조와 응용
    OS 이미지
    essential deep learning paper reading
    일귀
    kernel image 란
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.5
jh-rrr
Stanford CS224N NLP with Deep Learning | Spring 2022 | Guest Lecture: Scaling Language Models 강의 요약
상단으로

티스토리툴바