YoojLee / paper_review

paper review archive
6 stars 2 forks source link

CogVLM: Visual Expert for Pretrained Language Models (2024) #75

Open YoojLee opened 7 months ago

YoojLee commented 7 months ago
image

Summary

NLP 성능을 LLM 수준으로 유지시키면서 VLM을 scratch로 학습시키는 건 굉장히 어려움. 따라서, frozen pretrained language model로부터 어떤 식으로 VLM을 학습시키는지를 investigate하는 방향으로 연구가 진행되어 옴.

기존 연구 방향

  1. Shallow alignment (such as InstructBLIP, MiniGPT-4) vision encoder와 language model을 둘 다 freeze시킨 후에 학습 가능한 Q-Former 혹은 linear layer를 두 encoder 사이에 넣어서 연결하여 image feature를 language model의 embedding space에 매핑하는 형태로 VLM 설계 그러나, shallow alignment 방법론 같은 경우에는 각 모달리티 간 deep fusion이 이루어지지 않기 때문에 performance가 suboptimal하다는 한계가 있음.

  2. LLM unfreeze catastrophic forgetting 문제 -> 기존 학습된 데이터 / 태스크를 잊어버리는 문제. 따라서, 아래의 그림과 같이 기존 얻었던 Natural language understanding 능력이 급격히 저하되는 걸 볼 수 있음.

image

CogVLM

image

CogVLM은 두 가지 모달리티에서 모두 좋은 성능을 보여줄 수 있는 방안으로 visual-textual feature 간의 deep fusion이 필요하다고 주장. 이에 따라 visual expert module을 제안함. side adapter 방식으로 language model 내부 side에 visual feature를 위한 별도의 trainable alignment module (attention, FFN)을 추가함으로써 llm freeze를 시킴에 따라 nlp capa는 그대로 유지하고 visual feature를 language model에 맞게 더 잘 align시킬 수 있다고 주장.

cf.) side adapter
![image](https://github.com/YoojLee/paper_review/assets/52986798/d279714d-2780-43c9-be46-ae432c74b43f)

CogVLM-17B는 아래와 같이 17개의 cross-modal benchmarks (including multiple datasets & benchmarks from image captioning, vqa, LVLM, visual grounding)에서 SOTA 성능을 보여줌.

image

Method Highlights

Architecture

총 4개의 component.

  1. ViT Encoder EVA2-CLIP-E (4.4B) / final layer is removed (마지막 레이어는 abstract 정보를 뽑아내므로)
  2. MLP Adapter word embedding과 동일한 space로 mapping하기 위한 adpater. two-layer mlp로 구현.
  3. Pre-trained large language model GPT-style의 PLM과는 다 호화됨. CogVLM-17B 같은 경우에는 Vicuna1.5-7B를 사용함. causal mask attention 사용 (image feature에까지 다)
  4. Visual expert module 모든 레이어에 deep feature alignment를 위해 QKV matrix (attention)와 MLP를 side에 붙여서 image feature만 processing하도록 함. language model의 각 attention head는 semantic information의 특정 aspect를 각자 뽑아내기 위한 목적이었다면, visual expert module은 image feature를 각 다른 head와 align시키기 위한 방향으로 작용함.
image image image

positional embedding은 visual feature가 llm에 feed될 때는 position id 공유하는 형태로.

Pre-training (image captioning & grounding)과 alignment (sft) 두 가지 단계를 거침.

Pre-raining

pre-training 데이터는 아래와 같이 collect

pre-training 중 첫번째 스테이지는 image-captioning으로 학습.

두번째 스테이지는 image captioning과 Referring Expression Comprehension (Referring expression이 주어지면, bbox 좌표 리턴하는 형태)의 mixture로 학습

# total trainable parameters: 6.5B

Instruction alignment

trained two generalist models - CogVLM-Chat and CogVLM-Grounding

VQA 데이터셋 같은 경우에는 짧은 답변을 요구하는 경우가 많아서 input prompt format을 다음과 같이 구성.

image

trained for 6,000 iterations with lr of 1e-5 and a batch size of 1024. 이때, visual encoder의 parameter unfreeze시키고 이 부분의 lr은 1e-6으로 조정.

Experiment Highlights

Image Captioning

image

NoCaps와 Flickr는 zero-shot, COCO & TextCaps는 fine-tuning한 결과. 성능이 매우 잘 나오고, OCR 데이터 없이도 textcaps에서 SOTA와 비견되는 성능을 보여줌.

VQA and LVLM benchmarks

image

VQA 잘함. LVLM 벤치마크에서도 잘함 (더 큰 llm 쓴 모델보다도 잘함). 다양한 LVLM에서 잘하는 걸로 보았을 때, 다양한 태스크에서 robust하고 generalize된 reasoning 능력을 보여준다.

ShalIow alignment (InstructBLIP과 MiniGPT-4)을 사용한 모델은 성능이 좋지 못함 -> deep fusion의 중요성이 부각 (?)

Referring Expression Comprehension and GroundedVQA

image

generalist 중 가장 잘할 뿐 아니라, 해당 태스크에 맞춰서 학습된 specialist 모델들보다도 잘함 (5 out of 9 splits)

Ablations

image

추가로, computational efficiency는 아래와 같음.

image

Strengths

Weaknesses

YoojLee commented 7 months ago

https://openreview.net/forum?id=c72vop46KY