learning/Lectures

[강의] CS25 Transformers United V4 6강: From Large Language Models to Large Multimodal Models(Ming Ding, Zhipu AI)

silhumin9 2025. 1. 23. 14:54
  • 강의 출처:https://www.youtube.com/watch?v=cYfKQ6YG9Qo&t=797s

  • 강의 소개

    지난 5년간 대규모 언어 모델(LLMs)의 발전으로, 시각적 정보를 포함한 다른 감각적 모달리티를 LLM과 통합하려는 시도가 활발히 진행되고 있다. 이번 강연은 LLM의 기본 개념을 시작으로, 지난 1년간 학계에서의 멀티모달 모델과 구조적 업데이트 시도, CogVLM(17B 파라미터의 강력한 오픈소스 멀티모달 모델)과 CogAgent(GUI 및 OCR 작업용으로 설계된 모델)를 소개한다. 마지막으로 멀티모달 모델의 응용과 학계에서의 가능성 있는 연구 방향을 논의한다.

Why are we here?: LLM introduction and history

  1. BERT moment
  • better self-supervised method? = masked language model for understanding of model

    스크린샷 2025-01-22 오후 5.54.26.png

  • GPT: better for text generation → 하지만 오늘날 GPT가 거의 완벽한 해결책을 갖고 있음

  • T5: do the both, but redundant

  • 강연자: New self-supervised learning method를 찾기 위해 → GLM 논문 작성

    • 자기 회귀 모델 + 디코더 전용 스타일의 T5 통합
  1. Scaling Law(GPT-3 Moment)

    스크린샷 2025-01-22 오후 5.59.39.png

  • A bitter lesson: more compute, more intelligence(instead of arch/loss innovation)
  • performance have add more compute, guaranteed performance improvement
    • Scaling Law: assign compute with more parameters or tokens ↔ potential of money
  • 당시 언어 모델은 구조적 혁신이나, 알고리즘 혁신이 필요하지 않았음(돈만 필요)
  1. Alignment(ChatGPT Moment)

    스크린샷 2025-01-22 오후 6.01.10.png

  • Task adaptation is cheap: knowledge from pre-training is important
    • cf) task adaptation(작업 적응): 사전 학습(pre-training)을 통해 얻어진 지식을 활용하여 특정 작업(downstream tasks)에 모델을 쉽게 적응(fine-tuning)시키는 과정
    • cf) downstream task: 자기지도학습(self-supervised learning)에서 데이터의 표현을 학습하기 위해 구성한 문제를 pretext task라고 지칭하고, 실제로 풀고 싶은 문제를 downstream task
    • cf) self-supervised learning: 라벨링된 데이터 없이(untagged data) 학습 데이터를 자체적으로 생성하여 지도 학습(supervised learning)처럼 학습하는 방법. 모델이 스스로 데이터의 일부를 "정답(label)"으로 설정하고, 나머지 데이터를 활용하여 이를 예측하도록 훈련.
  • bitter lesson
    • 다양한 손실, 아키텍처를 설계하기 위해 다양한 pre-training task 시행
    • 그러나 오늘날 task adaptation을 하기 위해 fine-tune 하기만 하면 됨
  • 사진: InstructGPT - how can we align originally
    • 다운스트림 작업의 성능은 사전 훈련 손실(pre-training loss)과만 관련있음
    • 모델 크기와 직접적인 관련이 없음
      • 모델이 크면 학습이 부족하여 손실이 클 수 있음
      • 모델이 작을수록 더 많이 훈련해도 동일한 수준의 성과를 보임
    • emergent ability - 매개변수와 관련이 없음 ↔ only relevant to the loss of LM
    • LM은 curve fitting의 문제가 되었음

How did we get here?: Techniques for training LLMs

Transformer Achitecture

  • decoder only
    • 기존에 enco-deco 구조는 다른 매개변수를 통해 작업을 이해하는 방식을 학습해야 하므로 중복적
    • 오늘날 decoder-only architecture에만 관심있음
  • pre-layer norm(more stable gradients)
    • original transformer에서 pre-layer norm은 residual connection 뒤에 있음 → post-layer norm
    • 현재는 pre-layer norm 사용
    • Gradient 안정성 향상
  • rotary position embedding(faster convergence)
    • 논문이 아닌, 중국 블로그에서 게재됨
    • very efficient
  • group query attention(save inference memory)
    • 메모리 사용을 줄이고 효율성을 높임
  • GLU variants(better w.r.t. same number of params)
    • replace MLP, 동일한 파라미터 수로 더 나은 성능 제공
  • Mixture-of-Expert(the same FLOPs, more parameters, better performance)
    • 동일한 계산량(FLOPs)으로 더 많은 파라미터를 활용하여 성능 개선

Training Infra(Deep Speed)

스크린샷 2025-01-22 오후 6.18.32.png

  • library from microsoft
  • Training Memory: Parameter (Half), Gradient (Half), Master Weight (Float), Adam Optimizer States (2* Float)
    • 매우 큰 모델을 효율적으로 훈련하는 방법? → ZeRO
    • 몇 년 전까지만해도 매우 큰 모델에 대한 효율적인 훈련을 잘 몰랐음 - 가장 많은 메모리 소비는 Adam state
    • optimizer must keep precision in float
    • 매개변수와 기울기를 높은 정밀도로 유지하고, 속도를 높이고, 메모리를 절약할 수 있음
    • 데이터 parallel GPU 메모리 줄어듦
  • Activation checkpointing (recompute)
    • layer 활성화를 하나로 줄임
  • ZeRO1: scatter the master weight and optimizer states
  • ZeRO2: scatter gradient
    • GPU → CPU
  • CPU offload
  • ZeRO3 (FSDP)
  • Training Memory

Training Infra(Megatron)

스크린샷 2025-01-23 오후 12.02.28.png

  • The most available framework to train LLM

    • 1000억개가 넘는 parameter 가진 대규모 LM 훈련 가능
  • tensor parallel(split hidden size/heads)

    • 은닉된 은닉된 측면과 헤드를 다른 rank로 분할하고, attention과 MLP에 대해 추가 축소를 호출
    • computing consumption을 서로 다른 TP로 훈련
  • pipeline parallel(split layers)

    → 텐서 병렬(tensor parallel)과 파이프라인 병렬(pipeline parallel)을 통해 계산 부하를 나누어 효율성을 높임

  • cost: 1 all-reduce for attention and MLP

  • cost: Bubbles in pipeline(1F1B interleaved, ZeroBubbles)

  • MLP < ML6 impt

Training Infra for long text(lossless 128k)

스크린샷 2025-01-23 오후 12.06.52.png

  • beyond an AI guy imagination 5 years ago
  • 사진(강의자 논문): 서로 다른 BERT를 연결해서 검색, 연습, working memory of human을 모방
    • 긴 맥락을 이해하기 위한 것
    • 길이가 100,000 이상인 경우, full attention
    • 매우 단순화됨
  • context parallel: 시퀀스를 여러개로 나누고, ring attention이나 ulysses가 attention을 마무리하도록 함
    • TransformerEngine이라는 라이브러리에 있음
    • 모든 사람이 동일한 계산을 할 수 있도록 부하 균형 처리
    • 현재는 transformer, full attention으로 가능..

SFT

  • Supervised fine tuning is an ordinary finetuning for LLM on high quality datasets
  • 보통 high quality data는 인간 주석(notation)으로부터 나옴
    • 그냥 인간이 아니라, need ‘experts’ from different domains
  • 잘문-답변 쌍 추출
    • open ai 에서 사용하는 방식 아님
    • Weak-toStrong generalization
    • 정말 중요한 것은 pre-train loss

RLHF

  • reinforcement learning from human feedback
  • PPO는 구현/훈련하기가 어려움
  • 대부분의 언어모델은 DPO method 사용
  • 몇 가지 선호도 쌍 + 공식만 있으면 됨. reward model 필요 없음

What are the LLM pretrainers doing?

  • MLP가 아니라 ML6가 중요
  • 가장 중요한 것은 데이터
  • 데이터 cleaning, filtering, sythesizing이 중요
  • 강연자 의견: data, alrgorithm, architecter can transform each other
    • data: most general form, not enough compute
      • 데이터를 건드리는 게 가장 간단
      • 추가하기만 하면 다른 작업에 영향을 주지 않고도 task 마칠 수 있음
    • algorithm: hard to implement
    • hard to perform what you want

What are we working on?: Visual language model and techniques

BLIP - 2

  • pionior to efficiently brdige CLIP and LLM
  • Q-former 이미지 인코더에서 일부 중요한 기능을 추출하고, 이러한 기능을 LLM에 삽입하기 위해 Q-former라는 transformer 사용
  • text-image pair, aligned space of image featrues & text features가 필요

LLaVA

  • Finetuned from Llama, most popular one
  • 비전 언어 모델의 가장 인기 있는 architecture

CogVLM: 저자 작업

  • Vision expert, keep all language behavior Strong
  • vision expert를 이용하여 parameter 새로 추가, image feature에만 관여
  • github https://github.com/THUDM/CogVLM

CogAgent

  • GUI와 OCR 작업에 최적화된 웹 에이전트 훈련
  • 낮은 해상도를 처리하기 위해 cross attention 사용
  • 모델을 웹 에이전트로 훈련 - input as screen shot - perform different operation on the screen shot
    • ex) last year best paper in CVPR - grab info - use to reserve tickets

Vary

  • ensemble vision features as input

Current Architecture GLM-4V

  • mixed training with text: will also release in CogVLM2
  • 계산을 언어모델로 유지하기 위하여 LLaVA의 투영 비율을 stride CNN으로 변환
  • good performance
  • ex) chatglm.cn website
    • 알아보기 어려운 손글씨를 텍스트로 정확하게 분석

Image generation & transformer

Autoregressive modeling for text-to-image (using GPT)

  • find method to clean image …
  • train sequence is very long, cannot train high resolution image
  • 이미지를 텍스트처럼 토큰화하고 GPT를 활용해 이미지 생성
  • transfer image tokenizer → 이미지를 여러개의 토큰으로 분리, 텍스트 입력 먼저 →GPT를 사용하여 segment 작업
  • inference: 텍스트 삽입 → 이미지 토큰 하나하나 예측 → 일부 이미지 생성
  • CogView, DALL-E, Parti

Universal Modeling for VLM

  • 시각 언어 작업에 대한 보편적인 모델링을 할 수 있을까?
  • 이미지를 텍스트처럼 토큰화하면, 이미지 데이터로부터 이미지 생성, 텍스트 생성이 가능함
  • 텍스트와 이미지 시퀀스의 위치를 다양하게 변경할 수 있으므로 매우 간단
  • 텍스트를 쓰고, 이미지를 쓰고, 텍스트를 쓰므로…
  • 마스크된 auto encoder…
  • universal modelling을 diffusion이나, 언어모델과 비교해 볼 때, worse and slow
  • image understand - VLM model보다 성능 떨어짐

Diffusion Wins the Game(for now)

  • different from supervised method
  • auto regressive
  • DDPM = original paper for diffusi
  • give noise image
  • during sampling, can use utility in GPU
  • power of GPU
  • batch size diffusion model의 경우 GPU를 활용할 수 있고 훨씬 빠르게 샘플링 가능

Relay Diffusion

  • 마지막 이미지가 실제로 동일한 노이즈를 가진 이미지
  • A가 더 blur 하게 보이는 것은 - 독립적인 노이즈를 추가하는 것
  • 원래 신호는 공간 전체에서 독립적이지 않음
  • 낮은 해상도에서 높은 해상도로 노이즈가 많은 일정을 변환하려면 find equivalents
  • 주파수 그래프의 SNR을 동일하게 유지 할 수 있음
  • 노이즈가 많은 schedule을 사용하면 확산에 실제로 사용하는 네트워크와 분리

CogView3

  • scale up relay diffusion to text-to-image
  • after distillation, we can generate 1024*1024 images in 1.47s(pure Pytorch)

Diffusion transformer

  • most diffusion models use Unet
  • DiT from Meta
    • ADA layer norm
  • 1 int 이걸 변환하려면

Stable diffusion 3 Transformer

  • SD3 use CogVLM to recaption images
  • train a latent diffusion with MMDiT

Video Generation

  • How to train Sora?
  • High quality → scaling
  • context parallel techniques
  • high resolution and 30 fps
    • important thing is using infra in language model, make easy to scale much larger than other company
  • data coverage

Which direction should we head from here?

  • Prediction1: In 1-2 years, we can easily recognize, grounding, segment all the common things, attributes and human expressions. High-level vision will be 80% solved.
    • Like face recognition.
  • Prediction2: Video understanding will be a new, important field for multi-modality research.
    • Useful enough; Difficult enough
    • compute will increase to a point we can really deal with videos.
  • Prediction3: Embodied Al will be more and more important in research, although cannot make real-life impact in a few years.
    • cf) Embodied AI: 물리적 환경과 상호작용하는 AI
    • Planning with LLM; Recognize with VLM.

If you’re a senior researcher, follow your heart! else:

  • If you want to quickly earn papers / citations / impact,

    • Consider to work on video understanding models / datasets / benchmarks.
  • If you are considering to build an Al startup,

    • Maybe speech Al + LLM is a good direction.
    • speech Al is underestimated. No enough GPU / researcher, but users need.
  • If you want to do some really useful and impactful Al research.

    • Make some system PhD friends at once.

    • There should be room for new architectures, SSL and optimizers. (NVL72, sparse, inference-friendly etc.)

      • cf) Sparse Optimization(희소 최적화)은 모델 학습 및 추론 시, 모든 데이터와 모든 파라미터를 사용하는 대신 일부 중요한 정보만 선택적으로 활용하는 방식

        ex) MoE, Sparse attention

      • cf) Inference-Friendly는 학습이 끝난 모델이 실제 서비스 환경에서 추론(inference)을 효율적으로 수행할 수 있도록 설계된 최적화 방식

        • 저비용, 고속 추론: GPU/CPU 메모리 사용 최소화
        • 실시간 응답성: 대규모 데이터를 다룰 때도 낮은 지연시간(latency) 유지
        • 예시 기술
          • 모델 경량화(Quantization): 파라미터를 줄여 모델 크기 축소
          • Knowledge Distillation(지식 증류): 더 작은 모델로 성능을 압축
          • ZeRO Optimizer: 메모리 소모를 줄이는 기술
    • New ways to transform compute to high-quality data.