AI바라기의 인공지능

VLM : 논문리뷰 : LLaVA-UHD v2: an MLLM Integrating High-Resolution Feature Pyramid via Hierarchical Window Transformer 본문

논문리뷰

VLM : 논문리뷰 : LLaVA-UHD v2: an MLLM Integrating High-Resolution Feature Pyramid via Hierarchical Window Transformer

AI바라기 2024. 12. 27. 17:54

 

 

 

Abstract

 

multimodal large language models (MLLMs)에서, vision transformers (ViTs)는 visual encoding을 위해 널리 사용되고 있습니다. 그러나, 보편적인 MLLM tasks를 해결하는 데 있어서 그 성능은 만족스럽지 않습니다. 우리는 이것이 language generation에 필요한 다양한 semantic granularity와의 alignment를 방해하는 다양한 visual levels로부터의 정보 부족 때문이라고 생각합니다. 이 문제를 해결하기 위해, 우리는 high-resolution feature pyramid를 구축하고 통합함으로써 다양한 visual granularity를 포착할 수 있게 하는 Hierarchical window transformer를 중심으로 한 고급 MLLM인 LLaVA-UHD v2를 제시합니다. vision-language projector로서, Hiwin transformer는 두 가지 주요 modules로 구성됩니다: (i) image pyramid에서 high-frequency details을 활용하는 ViT-derived feature up-sampling process에 의해 구축된 inverse feature pyramid, 그리고 (ii) multi-level feature maps를 압축하기 위해 cross-scale windows 내의 key sampling features 집합에 초점을 맞추는 hierarchical window attention. 광범위한 실험을 통해 LLaVA-UHD v2가 널리 사용되는 benchmarks에서 기존의 MLLMs보다 우수한 성능을 달성한다는 것을 보여줍니다. 특히, 우리의 설계는 baseline method와 비교하여 14개의 benchmarks에서 평균 3.7%의 향상을 가져왔으며, 예를 들어 DocVQA에서는 9.3%의 향상을 보였습니다. 우리는 향후 연구를 촉진하기 위해 모든 data, model checkpoint, 그리고 code를 공개적으로 제공합니다.

 

 

 

핵심 내용

  • 문제점: 기존 multimodal large language models (MLLMs)에서 vision transformers (ViTs)를 visual encoding에 사용하지만, 보편적인 MLLM tasks 해결 성능이 만족스럽지 않음. 그 이유는 language generation에 필요한 다양한 semantic granularity와의 alignment를 방해하는, 다양한 visual levels에서의 정보가 부족하기 때문임.
  • 해결책: LLaVA-UHD v2 제시
    • LLaVA-UHD v2란? Hierarchical window transformer를 중심으로 한 고급 MLLM.
    • Hierarchical window transformer의 역할: high-resolution feature pyramid를 구축하고 통합하여 다양한 visual granularity를 포착.
  • Hiwin transformer 구성 (vision-language projector 역할)
    • (i) inverse feature pyramid:
      • ViT-derived feature up-sampling process를 통해 구축.
      • image pyramid에서 high-frequency details 활용.
    • (ii) hierarchical window attention:
      • multi-level feature maps를 압축하기 위해 cross-scale windows 내의 key sampling features 집합에 집중.
  • 실험 결과:
    • LLaVA-UHD v2가 널리 사용되는 benchmarks에서 기존 MLLMs보다 우수한 성능을 보임.
    • baseline method 대비 14개 benchmarks에서 평균 3.7% 성능 향상.
    • DocVQA에서 9.3% 성능 향상.
  • 기여: data, model checkpoint, code를 공개하여 후속 연구를 지원.

요약

기존 MLLMs의 ViT 기반 visual encoding은 다양한 visual levels 정보 부족으로 성능이 제한적이었음. 이를 해결하기 위해, LLaVA-UHD v2는 Hierarchical window transformer를 사용하여 high-resolution feature pyramid를 구축하고, inverse feature pyramid와 hierarchical window attention을 통해 다양한 visual granularity를 포착하여 성능을 향상시킴. 실험 결과는 LLaVA-UHD v2의 우수성을 입증하며, data, model, code 공개로 MLLM 연구 발전에 기여함.

 

 

 

1 Introduction

 

visual information을 large language models (LLMs)에 접목하는 것은 visual question answering, document analysis, 그리고 visual interaction과 같은 복잡한 visual multimodal tasks를 처리하는 능력을 크게 향상시켰습니다.

transformers의 부상과 함께, vision transformer (ViT)는 현대 multimodal large language models (MLLMs)에서 visual encoding을 위한 표준 방식으로 떠올랐습니다.

그러나, MLLM의 ViT는 그림 1(a)에서 볼 수 있듯이, single-scale features에 의해 포착된 불충분한 visual granularity로 인해 모든 유형의 visual multimodal tasks를 효과적으로 처리하는 데 어려움을 겪고 있습니다. 예를 들어, visual grounding과 optical character recognition은 fine-grained visual details을 요구하는 반면, image caption은 high-level semantics와 relations를 포착하는 데 중점을 둡니다.

computer vision의 발전을 바탕으로, fine-grained details와 high-level semantics의 포괄적인 coverage는 feature pyramid에 의해 효과적으로 통합될 수 있습니다. 그러나 이 방법은 MLLMs에 적용될 때 두 가지 주요 과제를 제시합니다. (1) Representation Inheritance. 확장성을 갖춘 ViT는 large-scale image-text pre-training(예: CLIP 또는 SigLIP)을 통해 획득한 일반적인 vision-language representations을 자랑하며, 이는 MLLMs에서 continual learning에 필수적입니다. multi-scale representations을 위해 ViT를 Swin과 같은 hierarchical architecture로 수정하면 기존 pre-trained models의 vision-language representations이 상속 불가능해집니다. (2) Compression Effectiveness. visual tokens 수에 대한 LLMs의 2차 계산 비용은 feature pyramid의 효과적인 압축을 필요로 합니다. 현재 기술은 종종 features를 고정된 resolution으로 resize하는데, 이는 그림 1(b)에서 볼 수 있듯이 spatial shape와 intrinsic semantics를 모두 왜곡합니다. 게다가, high-resolution features를 down-sampling하는 것은 중요한 fine-grained details을 잃을 위험이 있습니다.

이러한 과제를 해결하기 위해, 우리는 그림 1(c)에서 볼 수 있듯이, high-resolution feature pyramid를 구축하고 통합하여 다양한 visual granularities를 포착할 수 있는 새로운 Hierarchical window transformer를 중심으로 한 고급 MLLM인 LLaVA-UHD v2를 제시합니다. Hiwin transformer는 feature maps의 spatial resolution에 대해 확장-후-압축 절차를 수행하며, 이는 두 단계로 구성됩니다. (i) inverse feature pyramid 구축. 우리는 pre-trained ViT(예: CLIP-ViT) 위에 FeatUp에서 제안된 Joint Bilateral Upsampling (JBU) module인 parameterized feature up-sampler를 training하여 image의 high-frequency information을 feature map에 encoding합니다. 이 전략은 ViT 기반의 multi-resolution feature pyramid를 구축하는 동시에 강력한 feature representations을 상속하면서 모든 ViT에 적용될 수 있습니다. (ii) hierarchical window attention으로 features 통합. multi-level feature maps를 효과적으로 압축하기 위해, 우리는 서로 다른 pyramid levels에 걸쳐 local regions에서 semantics를 포착하기 위해 hierarchical windows 집합을 활용할 것을 제안합니다. learnable queries 집합은 각 windows 내의 key sampled features에만 attend하도록 제한됩니다. 이 attention mechanism은 각 pyramid level의 native resolution에서 local dense features에 대한 효과적인 압축을 수행하여, visual tokens가 fine-grained details와 high-level semantics를 모두 효과적으로 포착할 수 있도록 합니다.

광범위한 실험을 통해 LLaVA-UHD v2가 document-centric visual question answering (예: DocVQA에서 +9.3%), visual grounding (예: RefCOCOs에서 평균 +5.7%), high-resolution image perception (예: HR-Bench에서 +3.4%)을 포함한 14개의 널리 사용되는 benchmarks에서 baseline method (LLaVA-UHD)를 크게 능가한다는 것을 보여줍니다. 또한, 우리는 실험적으로 feature pyramids가 특정 구축 방법(예: bilinear interpolation)에 관계없이 MLLMs의 visual perception 능력을 더욱 향상시킬 수 있음을 밝혀, 향후 연구를 위한 새로운 insights를 제공합니다. 우리의 기여는 다음과 같이 요약할 수 있습니다.

  • 우리는 up-sampling module을 pre-training하여 visual pyramid encoding 방법을 제안하고, language decoding을 위해 풍부한 semantic granularity를 제공합니다.
  • 우리는 high-resolution feature pyramid를 압축된 visual tokens 집합으로 통합하고 압축할 수 있는 hierarchical window attention을 제안하여, language decoding에 필요한 중요한 details을 보존하면서 계산 효율성을 보장합니다.
  • academic-scale data에서 효율적으로 trained된 LLaVA-UHD v2는 14개의 benchmarks에서 baseline method에 비해 상당한 개선을 달성합니다.

 

그림 1: LLaVA-UHD v2와 다른 MLLMs의 비교. (a) MLLMs는 일반적으로 MLPs 또는 perceiver re-samplers를 사용하여 ViT features를 language space에 align하지만, visual granularity가 부족합니다. (b) 여러 visual encoders를 결합하는 것은 보편적이지 않고 계산 집약적입니다. (c) LLaVA-UHD v2는 Hiwin transformer를 사용하여 inverse feature pyramid를 구축하고 이를 visual tokens로 압축하여, language generation을 위한 다양한 semantic granularity를 제공합니다.

 

 

1. Introduction 정리

MLLMs (Multimodal Large Language Models) 개요

  • 정의: visual information을 large language models (LLMs)에 결합하여, visual question answering, document analysis, visual interaction 등 복잡한 visual multimodal tasks 처리 능력을 향상시킨 모델.
  • 핵심 기술: vision transformer (ViT)가 visual encoding의 표준으로 부상.

기존 MLLMs의 문제점: ViT의 한계

  • 문제점: MLLMs 내 ViT는 single-scale features에서 포착하는 visual granularity가 불충분하여 모든 유형의 visual multimodal tasks를 효과적으로 처리하기 어려움 (그림 1(a) 참조).
    • 예시:
      • visual grounding, optical character recognition: fine-grained visual details 필요.
      • image caption: high-level semantics 및 relations 파악이 중요.
  • 해결책: computer vision 분야의 feature pyramid 활용.
    • feature pyramid: fine-grained details와 high-level semantics를 포괄적으로 통합 가능.

Feature Pyramid를 MLLMs에 적용 시 발생하는 두 가지 과제

  1. Representation Inheritance (표현 상속):
    • ViT는 large-scale image-text pre-training (예: CLIP, SigLIP)을 통해 얻은 일반적인 vision-language representations을 보유하며, 이는 MLLMs의 continual learning에 필수적임.
    • multi-scale representations을 위해 ViT를 Swin과 같은 hierarchical architecture로 변경하면 기존 pre-trained models의 vision-language representations을 상속할 수 없음.
  2. Compression Effectiveness (압축 효율성):
    • visual tokens 수에 따른 LLMs의 2차 계산 비용으로 인해 feature pyramid의 효과적인 압축이 필요함.
    • 기존 기술은 features를 고정된 resolution으로 resize하여 spatial shape와 intrinsic semantics를 왜곡함 (그림 1(b) 참조).
    • high-resolution features를 down-sampling하면 중요한 fine-grained details 손실 위험.

LLaVA-UHD v2 소개: 문제 해결을 위한 새로운 접근법

  • LLaVA-UHD v2: Hierarchical window transformer를 중심으로 하는 고급 MLLM (그림 1(c) 참조).
  • 핵심 아이디어: high-resolution feature pyramid를 구축 및 통합하여 다양한 visual granularities를 포착.
  • Hiwin transformer의 작동 방식 (확장 후 압축):
    1. inverse feature pyramid 구축:
      • pre-trained ViT (예: CLIP-ViT) 상에서 FeatUp에서 제안된 Joint Bilateral Upsampling (JBU) module인 parameterized feature up-sampler를 training.
      • image의 high-frequency information을 feature map에 encoding.
      • ViT의 강력한 feature representations을 상속하면서 ViT 기반 multi-resolution feature pyramid 구축.
    2. hierarchical window attention을 사용한 features 통합:
      • multi-level feature maps를 효과적으로 압축.
      • hierarchical windows 집합을 사용하여 서로 다른 pyramid levels의 local regions에서 semantics를 포착.
      • learnable queries 집합은 각 windows 내의 key sampled features에만 attend.
      • 각 pyramid level의 native resolution에서 local dense features에 대한 효과적인 압축 수행.
      • visual tokens가 fine-grained details와 high-level semantics를 모두 효과적으로 포착하도록 지원.

실험 결과 및 기여

  • 실험 결과: LLaVA-UHD v2가 14개의 널리 사용되는 benchmarks에서 baseline method (LLaVA-UHD)를 크게 능가.
    • document-centric visual question answering (DocVQA: +9.3%)
    • visual grounding (RefCOCOs: 평균 +5.7%)
    • high-resolution image perception (HR-Bench: +3.4%)
  • feature pyramids의 추가적 의의: 특정 구축 방법(예: bilinear interpolation)과 관계없이 MLLMs의 visual perception 능력을 향상시킬 수 있음을 실험적으로 증명하여 향후 연구에 새로운 insights 제공.

기여 요약

  • up-sampling module pre-training을 통한 visual pyramid encoding 방법 제안: language decoding을 위한 풍부한 semantic granularity 제공.
  • hierarchical window attention 제안: high-resolution feature pyramid를 압축된 visual tokens 집합으로 통합 및 압축하여 계산 효율성을 보장하고 language decoding에 필요한 중요한 details 보존.
  • academic-scale data에서 효율적으로 trained된 LLaVA-UHD v2는 14개 benchmarks에서 baseline method 대비 상당한 개선 달성.

 

 

그림 2: 제안된 LLaVA-UHD v2의 전체 architecture로, ViT, 우리의 hierarchical window transformer (Hiwin transformer) 및 LLM으로 구성됩니다. Hiwin transformers는 sliced patches와 overview image를 처리하여 내부 multi-level representations을 포착하고 이를 spatially consistent tokens로 압축하여 더 나은 vision-language alignment를 제공합니다.

 

 

 

 

 

2 Related Works

2.1 Feature Pyramid Representation

image pyramid 기술은 수동 feature 설계 시대부터 multi-resolution 분석을 용이하게 하는 image processing의 기초이며, SIFT의 scale-space keypoints에서 볼 수 있습니다. deep learning에서 ResNet 및 VGG와 같은 CNN은 본질적으로 계층적 features를 추출합니다. FPN 및 U-Net과 같은 혁신은 detection 및 segmentation과 같은 tasks를 위해 semantic 계층을 향상시킵니다. 최근, 일부 transformer-based models은 feature pyramid 구성을 더욱 발전시켜 visual representations을 위한 보다 포괄적인 visual semantic granularity를 포착합니다. 그러나 CLIP-based ViTs를 자주 사용하는 multimodal language models은 계층적 features를 충분히 활용하지 못하여, 이러한 models에 고급 feature pyramids를 통합하기 위한 연구 격차를 시사합니다.

2.2 Visual Encoding in MLLMs

대조적인 pre-training을 통해 visual features를 linguistic semantics와 효과적으로 align하는 것으로 선호되는 CLIP-ViT는 MLLMs에서 널리 채택됩니다. 새로운 연구는 주로 세 가지 범주에서 대안적인 visual representations을 탐구합니다. (1) CLIP-based CNNs 및 ViTs의 features 융합. LLaVA-HR은 단계별 CNN features를 ViT의 layers에 통합하여 fine-grained 인식을 향상시킵니다. CogAgent는 language decoding 중에 detailed information을 위해 ViT features를 사용하여 high-resolution CNN features를 query합니다. Mini-Gemini는 CNN 및 ViT features 간의 cross-attention-based 사후 융합을 사용합니다. (2) 서로 다른 vision pre-training tasks로 trained된 visual experts의 features 융합. 후보 experts에는 visual contrastive pre-training에 의한 DINO-v2, prompt segmentation pre-training에 의한 SAM, document parsing pre-training에 의한 Pix2Struct 등이 포함됩니다. Deepseek-VL, SPHINX-X 및 Eagle은 output feature maps를 down-sample하고 channel 축을 따라 concatenate합니다. Cambrian-1은 visual experts의 local patches를 query하기 위해 embeddings을 초기화합니다. (3) visual encoding을 위한 language models: Fuyu, Otter-HD 및 SOLO는 전용 visual encoders를 우회하여 LLMs로 직접 images를 encoding합니다. 그러나 이러한 접근 방식은 효과적이지만 계산 요구를 증가시키고 통합된 image-to-language 설계를 방해합니다.

2.3 Token Projection and Compression

MLPs, perceiver resamplers 및 Q-Formers는 최신 MLLMs에서 널리 사용되는 기본 projectors입니다. 최근 다양한 새로운 설계가 등장했습니다. (1) Spatial-preserving 압축. Qwen2-VL 및 MiniGPT-v2는 간단한 linear를 사용하여 tokens를 국소적으로 (예: 2x2) 병합합니다. Honey-bee는 C-abstractor (즉, CNN-based block)를 도입하는 반면, Oryx는 동적으로 features를 pooling하고 이를 사용하여 원래 features를 query합니다. (2) Cross-layer feature 압축. Token-Packer는 cross-attention을 사용하여 ViT의 layers에 걸쳐 features를 압축합니다. MMFuser는 final-layer features를 queries로 사용하여 early-layer features에 attend합니다. (3) Semantic-merged 압축. Chat-UniVi 및 LLaVA-PruMerge는 token merging 전략을 확장하여 유사한 semantics를 가진 features를 단일 representation으로 병합합니다. 그러나 이러한 접근 방식은 feature padding, resizing 및 reshaping에 크게 의존하여 임의의 resolutions로 features를 압축하는 능력을 저해합니다.

 

 

 

2.1 Feature Pyramid Representation

  • Image Pyramid의 중요성:
    • image processing의 기본 기술.
    • SIFT의 scale-space keypoints처럼 수동 feature 설계 시대부터 multi-resolution 분석을 가능하게 함.
  • Deep Learning에서의 활용:
    • CNNs (ResNet, VGG): 계층적 features 추출.
    • FPN, U-Net: detection, segmentation 등의 tasks를 위한 semantic 계층 구조 강화.
  • Transformer-based models:
    • feature pyramid 구성을 더욱 발전시켜 visual representations을 위한 포괄적인 visual semantic granularity를 포착.
  • MLLMs (Multimodal Large Language Models)의 한계:
    • CLIP-based ViTs를 주로 사용하지만, 계층적 features 활용이 부족함.
    • 연구 과제: MLLMs에 advanced feature pyramids 통합 필요.

2.2 Visual Encoding in MLLMs

  • CLIP-ViT의 우세:
    • visual features와 linguistic semantics를 효과적으로 align하여 MLLMs에서 널리 사용됨.
  • 대안적 visual representations 탐구 (3가지 범주):
    1. CLIP-based CNNs와 ViTs의 features 융합:
      • LLaVA-HR: 단계별 CNN features를 ViT layers에 통합하여 fine-grained 인식 향상.
      • CogAgent: language decoding 중 detailed information을 얻기 위해 ViT features로 high-resolution CNN features를 query.
      • Mini-Gemini: CNN과 ViT features 간 cross-attention 기반 사후 융합.
    2. 다양한 vision pre-training tasks로 trained된 visual experts의 features 융합:
      • Experts 예시: DINO-v2 (visual contrastive pre-training), SAM (prompt segmentation pre-training), Pix2Struct (document parsing pre-training) 등.
      • Deepseek-VL, SPHINX-X, Eagle: output feature maps를 down-sample하고 channel 축을 따라 concatenate.
      • Cambrian-1: visual experts로부터 local patches를 query하기 위해 embeddings 초기화.
    3. Visual encoding을 위한 language models:
      • Fuyu, Otter-HD, SOLO: 별도의 visual encoders 없이 LLMs로 직접 images를 encoding.
      • 한계: 계산량 증가, image-to-language 통합 설계 방해.

2.3 Token Projection and Compression

  • 기본 projectors: MLPs, perceiver resamplers, Q-Formers가 MLLMs에서 널리 사용됨.
  • 최근의 새로운 설계들 (3가지 범주):
    1. Spatial-preserving 압축:
      • Qwen2-VL, MiniGPT-v2: 간단한 linear를 사용하여 tokens를 국소적(예: 2x2)으로 병합.
      • Honey-bee: C-abstractor (CNN-based block) 도입.
      • Oryx: features를 동적으로 pooling하고 이를 사용하여 원래 features를 query.
    2. Cross-layer feature 압축:
      • Token-Packer: cross-attention을 사용하여 ViT layers에 걸쳐 features 압축.
      • MMFuser: final-layer features를 queries로 사용하여 early-layer features에 attend.
    3. Semantic-merged 압축:
      • Chat-UniVi, LLaVA-PruMerge: token merging 전략을 확장하여, 유사한 semantics를 가진 features를 단일 representation으로 병합.
  • 한계: feature padding, resizing, reshaping에 크게 의존하여 임의의 resolutions을 가진 features 압축 능력 저해.

결론 (LLaVA-UHD v2와의 연관성)

  • 기존 MLLMs는 feature pyramid를 효과적으로 활용하지 못하고, visual encoding 방식과 압축 기법에 한계가 있음.
  • LLaVA-UHD v2는 이러한 한계를 극복하기 위해 새로운 feature pyramid 구축 방식 (inverse feature pyramid)압축 기법 (hierarchical window attention) 을 제안.
  • 이를 통해 더 나은 visual representations과 효율적인 계산을 가능하게 함.
  • 즉, Related Works 부분은 LLaVA-UHD v2의 필요성과 독창성을 뒷받침하는 근거를 제시하고 있다고 볼 수 있음.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3 Method

3.1 Overview

제안된 LLaVA-UHD v2의 architecture는 그림 2에 나와 있습니다. 이는 세 가지 주요 modules로 구성됩니다: visual encoder (ViT), vision-language projector (Hiwin transformer), 그리고 LLM. 우리는 먼저 에서 제안된 slicing strategy를 활용하여 각 input image를 적절한 크기와 가로 세로 비율로 여러 slices로 나누고 자릅니다. image slices는 overview image와 함께 임의의 크기와 모양의 images를 처리할 수 있는 interpolated positional embeddings을 갖춘 CLIP-ViT에 의해 처리됩니다. 결과 features는 이후 vision-language projection을 위해 Hiwin transformer로 전달되며, 이는 두 단계로 수행됩니다: (i) inverse feature pyramid 구축 (3.2절에서 자세히 설명) 및 (ii) hierarchical window attention에 의한 feature pyramid 통합 (3.3절에서 자세히 설명). Hiwin transformer의 핵심은 각 ViT-encoded feature를 high-resolution feature pyramid encoding으로 향상시켜 각 image slice에 대해 풍부한 semantic granularity를 달성하는 데 있습니다. 이 향상 후, 서로 다른 slices의 visual tokens는 원래 image에 상대적으로 spatially consistent feature map으로 재구성되어 공간 관계의 명확성을 보장합니다. overview tokens와 concatenate된 후, 모든 visual tokens는 language decoding을 위한 visual context를 제공합니다.

3.2 Inverse Feature Pyramid

기본 사항. 수작업으로 제작된 visual representations 시대에는 gaussian convolution filter가 image pyramids {Il ∈ R^(H/2^l × W/2^l × 3), l = 0, 1...L − 1}를 구성하는 데 널리 사용되었습니다. 여기서 l은 pyramid level, (H, W)는 image 높이와 너비, L은 총 levels 수를 나타냅니다. 이 개념을 바탕으로 ResNet 및 VGG와 같은 심층 convolutional neural networks (CNNs)는 자연스럽게 bottom-up 방식의 계층적 feature pyramid {Fl ∈ R^(H/(p·2^l) × W/(p·2^l) × C)}를 생성합니다. 여기서 C는 feature 차원을 나타내고 p는 down-sampling 비율을 나타냅니다(예: ResNet-50에서는 p = 8). 이러한 pyramids에서 lower-level feature maps는 일반적으로 더 높은 resolution을 가지며 더 많은 visual detail을 포착하는 반면, higher-level feature maps는 더 낮은 resolution을 갖지만 더 추상적인 semantic information을 포함합니다. 그러나 이미지를 coarse patches로 분할하는 ViTs는 그림 1(a)에서 볼 수 있듯이 single-scale feature maps(예: F0 ∈ R^(H/p × W/p × C), 예를 들어 p = 14)만 생성합니다. CNNs에 존재하는 것과 같은 이러한 feature pyramid가 없으면 fine-grained visual details와 high-level semantic information이 모두 필요한 MLLM tasks에서 ViTs의 성능이 저하됩니다. 결과적으로 다양한 semantic granularity를 가진 ViT-based feature pyramid를 구축하는 방법은 여전히 미해결 과제로 남아 있습니다.

Guided feature up-sampling. high-resolution features가 부족하기 때문에 ViT features를 up-sampling하는 것이 feature pyramid를 역으로 구성하는 데 필요한 전략이 됩니다. 두 가지 직접적인 접근 방식을 사용할 수 있습니다: (1) 단순 bilinear interpolation 및 (2) deconvolution network. 결과 feature maps의 resolution을 두 배와 네 배로 늘리면 ViT-based feature pyramid {Fl ∈ R^(H·2^l/p × W·2^l/p × C), l = 0, 1, 2}가 구성됩니다. 효과적이기는 하지만 deep features를 직접 up-sampling하는 것은 fine-grained visual information이 필요한 tasks에 필수적인 정밀한 visual details을 거의 제공하지 못합니다. 이 한계를 해결하기 위해 우리는 parameterized JBU module을 활용하여 image priors로 feature up-sampling을 guide하여 high-frequency visual details을 도입하는 데 도움을 줍니다. 일반적으로 JBU module의 목적은 image pyramid {Il ∈ R^(H·2^l/p × W·2^l/p × 3)}에서 (l - 1)개의 convolutional layers를 학습하여 feature up-sampling을 안내하기 위해 local texture의 high-frequency patterns를 포착하는 것입니다(그림 3). 구체적으로, 각 input image에 대해 (l + 1)번째 level ViT features는 다음과 같이 정의됩니다.

F^(l+1) = Conv(Up(F^l); Θl+1(I^(l+1)))

여기서 Up(·)은 up-sampling interpolation을 나타내고 Conv(·)는 해당 image I^(l+1)에서 학습된 customized kernel weights Θl+1을 사용하여 feature maps에 적용된 convolutional operation을 나타냅니다.

결과적으로 up-sampled feature maps의 각 pixel 값은 다음과 같이 추출됩니다.

F^(l+1)[x, y] = (1/|U|) * Σ((x',y')∈U) [Up(F^l)[x', y'] × Ddist × Dsim(Θl+1(I^(l+1)[x, y]), Θl+1(I^(l+1)[x', y']))]

여기서 [x, y]는 feature maps의 coordinate index를 나타내고, U는 convolution neighborhood 영역을 나타내고, Ddist는 [x, y]와 [x', y'] 사이의 거리를 기반으로 한 decay factor이고, Dsim은 2-layer GeLU MLP Θl+1을 사용한 각 image pixel의 attention을 기반으로 한 similarity weight입니다. 추가 details은 supplement A.1에서 찾을 수 있습니다. Eq. 1을 반복적으로 수행함으로써 feature maps를 점진적으로 up-sample하고 궁극적으로 feature pyramid {Fl, l = 0, 1, 2}를 구성합니다.

Learnable up-sampler 최적화. [26]에 따라, 우리는 highest-level feature maps와 lowest-level feature maps 간의 reconstruction loss를 다음과 같이 최적화합니다.

L = ||F0 - Down(F^2; Ω)||_2^2

여기서 Down(·)은 trainable weights Ω를 가진 down-sampling network입니다(예: stride가 2인 두 개의 convolution layers). 명확성을 위해 Eq. 3의 일부 hyper-parameters를 생략했습니다. 자세한 내용은 supplement A.1을 참조하십시오.

그러나 CLIP-ViT에서 JBU module을 training할 때 high-resolution feature maps의 texture detail 저하가 발생합니다. 구체적으로, CLIP-ViT의 features는 DINO-ViT와 같은 다른 ViTs와 비교하여 더 높은 resolutions에서 향상된 detail representation이 거의 나타나지 않습니다. 우리는 이 문제가 반복적인 up-sampling 중에 language-aligned features에 대한 inter-level feature reconstruction이 부족하여 CLIP-ViT의 이러한 semantic-centric representations의 불안정한 변환을 초래하기 때문이라고 생각합니다. 이를 해결하기 위해 우리는 pyramid의 각 level을 조절하는 직접적인 계층적 supervision 전략을 제안합니다. Eq. 3은 다음과 같이 업데이트됩니다. Eq. 3의 전체 형식에 대한 자세한 내용은 supplement A.1에서 찾을 수 있습니다.

L = (1/2) * Σ(l=1 to 2) ||F0 - Down(F^l; Ωl)||_2^2

 

3.3 Hierarchical Window Attention

feature pyramid의 계층적 특성은 cross-level spatial alignment를 유지하면서 다양한 resolutions에서 features를 압축하기 위한 효과적인 접근 방식을 필요로 합니다.

Hierarchical window 생성. object detection에서 영감을 받아, 우리는 그림 4와 같이 서로 다른 levels의 feature maps에서 spatial locality를 보존하면서 key features를 sampling하기 위해 RoI-align을 사용합니다. 구체적으로, 우리는 먼저 각 level의 feature maps를 N × N windows로 균일하게 나누기 시작합니다. 이 windows의 너비와 높이는 정수가 아닌 부동 소수점 값(W/N, H/N)입니다. 특히, levels에 걸쳐 동일한 "anchor" points를 공유하는 windows는 좌상단 및 우하단 좌표 {Rl_i,j ∈ R^(1×4), i, j ∈ 0, 1, 2...N − 1, l = 0, 1, 2}로 표시되는 hierarchical bounding boxes 집합을 형성합니다. 여기서 l은 feature level을 나타내고 (i, j)는 2D indices를 나타냅니다. RoI-aligned feature maps의 가로 세로 비율과 원래 feature maps의 가로 세로 비율 간의 불일치로 인한 feature maps의 크기 왜곡을 완화하기 위해, 우리는 이 불일치를 평가하기 위한 pooling score를 정의합니다.

S(W, H, rw, rh) = - |log(W/H) - log(rw/rh)|

여기서 (rw, rh)는 pooled features의 너비와 높이를 나타냅니다. score S를 최대화함으로써, 우리는 미리 정의된 proposals 집합 {(3, 3),(2, 3),(3, 2),(2, 4),(4, 2)}에서 최적의 grid size (r*w, r*h)를 선택합니다. 그 후, 생성된 windows로 RoI-align을 수행하여 다음 attention operation을 위한 key feature maps를 sampling합니다.

Cross-window feature querying. 주어진 image slice I의 multi-level feature pyramid {Fl, l = 0, 1, 2}를 압축하기 위해, 우리는 각각 hierarchical windows 집합 {Rl_i,j, l = 0, 1, 2}에 해당하는 queries 집합 {Qi,j ∈ R^(1×C), i, j ∈ 0, 1, 2...N − 1}을 초기화합니다(그림 4). 각 query vector Qi,j가 주어지면, 우리는 l-번째 level의 key vector Kl_i,j ∈ R^((r*x · r*y)×C)를 다음과 같이 준비합니다.

K^l_i,j = RoI(F^l, R^l_i,j) + ϕ^l

여기서 ϕ^l은 level-wise positional embedding입니다. 그런 다음 key vectors Kl_i,j는 length 축을 따라 concatenate되어 각 query Qi,j에 대한 최종 key vector Ki,j ∈ R^((3·r*x · r*y)×C)를 형성합니다. 해당 value vector Vi,j는 동일한 방식으로 얻어지지만 level-wise positional embedding은 없습니다. 따라서 cross-attention은 다음과 같이 수행될 수 있습니다.

Q\*_i,j = CrossAttn(Qi,j + φi,j, Ki,j + ϕi,j, Vi,j)

여기서 Q*_i,j는 updated query를 나타내고, φ, ϕ는 각각 query 및 key vector의 2D spatial position embedding입니다. 마지막으로, 우리는 모든 updated query Q*_i,j를 feature map P ∈ R^(N×N×C)로 concatenate하여 image I의 visual token을 나타냅니다.

3.4 Spatially-consistent Token Organization

서로 다른 images에 걸쳐 다양한 partitions 때문에, slices의 structure를 효과적으로 구성하고 LLM에 전달하는 것은 image를 보다 정확하게 이해하는 데 중요합니다. 이전 연구는 image slices의 상대적 위치를 나타내기 위해 spatial tokens (예: "\n" 또는 ",")을 사용합니다. 이러한 접근 방식은 각 slice의 global arrangement에 대한 단서를 제공하지만, 개별 visual tokens 간의 본질적인 spatial relationships는 간과합니다. 예를 들어, image에서 가로로 인접한 두 개의 tokens가 서로 다른 slices에 위치한 경우 1D 배열에서 상당히 분리될 수 있습니다. 이를 해결하기 위해, 우리는 원래 image와 2D spatial consistency를 보존하는 Hiwin transformer를 활용하고, 이러한 2D feature maps를 slicing configuration에 따라 큰 2D feature map으로 통합합니다(그림 2). 그런 다음 newline token "\n"이 행 사이에 삽입되고, 그 다음 1D 배열로 flattening됩니다. 또한, image의 서로 다른 views를 구별하기 위해 큰 feature maps와 overview image의 features 사이에 comma ","가 배치됩니다.

 

 

 

3. Method 정리 노트: LLaVA-UHD v2

3.1 Overview:

  • 목표: ViT의 single-scale feature 한계를 극복하고, high-resolution feature pyramid를 생성하여 MLLM의 성능 향상.
  • 핵심 구성 요소:
    • ViT (Visual Encoder): image에서 visual features 추출.
    • Hiwin Transformer (Vision-Language Projector): ViT features를 LLM에 적합한 형태로 변환, 핵심 역할.
    • LLM: visual context를 바탕으로 text 생성.
  • 전체 구조 (그림 2):
    • input image를 여러 slices와 overview image로 분할.
    • ViT를 통해 각 slice와 overview image에서 features 추출.
    • Hiwin Transformer를 통해 inverse feature pyramid 구축 및 hierarchical window attention 적용.
    • spatially consistent visual tokens 생성 후 LLM에 입력.

3.2 Inverse Feature Pyramid:

  • 문제점: ViT는 single-scale feature maps만 생성하여 다양한 visual granularity 정보 부족 (그림 1(a)).
  • 해결책: ViT features를 up-sampling하여 inverse feature pyramid 구축.
  • Feature Pyramid란?
    • 다양한 resolution의 feature maps 집합 ({Fl ∈ R^(H/(p·2^l) × W/(p·2^l) × C)}).
    • lower-level: high-resolution, fine-grained visual details 포착.
    • higher-level: low-resolution, abstract semantic information 포함.
  • 구축 방법:
    • 단순한 방법: bilinear interpolation, deconvolution network 사용.
      • 한계: 정밀한 visual details 도입 어려움.
    • LLaVA-UHD v2의 방법: parameterized JBU (Joint Bilateral Upsampling) module 활용 (그림 3).
      • JBU module: image pyramid를 사용하여 feature up-sampling을 guide.
      • 장점: high-frequency visual details을 up-sampled feature maps에 통합.
      • 동작 원리:
        1. image pyramid {Il}에서 (l - 1)개의 convolutional layers 학습.
        2. local texture의 high-frequency patterns 포착.
        3. Eq. 1을 통해 (l + 1)번째 level ViT features (F^(l+1)) 생성: F^(l+1) = Conv(Up(F^l); Θl+1(I^(l+1)))
          • Up(·): up-sampling interpolation.
          • Conv(·): convolutional operation.
          • Θl+1(I^(l+1)): image I^(l+1)에서 학습된 customized kernel weights.
        4. Eq. 2를 통해 up-sampled feature maps의 각 pixel 값 추출: F^(l+1)[x, y] = (1/|U|) * Σ((x',y')∈U) [Up(F^l)[x', y'] × Ddist × Dsim(Θl+1(I^(l+1)[x, y]), Θl+1(I^(l+1)[x', y']))]
          • Ddist: 거리에 따른 decay factor.
          • Dsim: 2-layer GeLU MLP Θl+1을 사용한 image pixel attention 기반 similarity weight.
        5. Eq. 1을 반복하여 feature pyramid {Fl, l = 0, 1, 2} 생성.
  • Learnable Up-sampler 최적화:
    • 초기 Loss (Eq. 3): L = ||F0 - Down(F^2; Ω)||_2^2
      • highest-level feature maps와 lowest-level feature maps 간의 reconstruction loss 최소화.
      • Down(·): trainable weights Ω를 가진 down-sampling network.
    • 문제점: CLIP-ViT 사용 시 high-resolution feature maps에서 texture detail 저하 발생.
    • 개선된 Loss (Eq. 4): L = (1/2) * Σ(l=1 to 2) ||F0 - Down(F^l; Ωl)||_2^2
      • 해결책: hierarchical supervision strategy 도입.
      • pyramid의 각 level을 조절하여 inter-level feature reconstruction 보장.

3.3 Hierarchical Window Attention:

  • 목표: feature pyramid를 효율적으로 압축하고 LLM에 유용한 visual tokens 생성.
  • 핵심 아이디어: multi-level feature pyramid의 정보를 효과적으로 통합하고 압축.
  • Hierarchical Window 생성 (그림 4):
    • RoI-align을 사용하여 서로 다른 levels의 feature maps에서 spatial locality를 보존하며 key features를 sampling.
    • 각 level의 feature maps를 N × N windows로 균일하게 분할.
    • 동일한 "anchor" points를 공유하는 windows는 hierarchical bounding boxes 집합을 형성: {Rl_i,j ∈ R^(1×4), i, j ∈ 0, 1, 2...N − 1, l = 0, 1, 2}
    • feature maps 크기 왜곡 완화를 위해 pooling score S(W, H, rw, rh) = - |log(W/H) - log(rw/rh)| 정의.
    • score S를 최대화하는 최적의 grid size (r\*w, r\*h) 선택.
  • Cross-Window Feature Querying:
    • query 집합 {Qi,j ∈ R^(1×C)} 초기화 (각 query는 hierarchical windows 집합 {Rl_i,j}에 대응).
    • key vector Kl_i,j = RoI(F^l, R^l_i,j) + ϕ^l 생성 (ϕ^l: level-wise positional embedding).
    • key vectors Kl_i,j를 concatenate하여 최종 key vector Ki,j 생성.
    • value vector Vi,j도 동일한 방식으로 생성 (level-wise positional embedding 제외).
    • Cross-Attention 수행: Q\*_i,j = CrossAttn(Qi,j + φi,j, Ki,j + ϕi,j, Vi,j)
      • φi,j, ϕi,j: query와 key의 2D spatial position embedding.
    • updated query Q\*_i,j를 concatenate하여 feature map P ∈ R^(N×N×C) 생성 (image의 visual token).

3.4 Spatially-consistent Token Organization:

  • 문제점: slices 간 다양한 partitions으로 인해 slices 구조를 LLM에 전달하는 것이 어려움.
  • 해결책: Hiwin transformer의 2D spatial consistency를 활용.
  • 방법:
    1. 2D feature maps를 slicing configuration에 따라 큰 2D feature map으로 통합.
    2. newline token "\n"을 행 사이에 삽입.
    3. 1D 배열로 flattening.
    4. comma ","를 큰 feature maps와 overview image features 사이에 배치.
  • 장점:
    • slices의 global arrangement 정보 제공.
    • 개별 visual tokens 간의 intrinsic spatial relationships 보존.

요약

  • LLaVA-UHD v2는 Hiwin Transformer를 사용하여 ViT의 한계를 극복하고 MLLM 성능 향상.
  • Inverse Feature Pyramid (3.2절): JBU module을 통해 ViT features를 up-sampling하고 high-frequency details를 통합하여 다양한 visual granularity를 포착.
  • Hierarchical Window Attention (3.3절): RoI-align과 cross-attention을 통해 feature pyramid를 효율적으로 압축하고 LLM에 유용한 visual tokens 생성.
  • Spatially-consistent Token Organization (3.4절): Hiwin transformer의 spatial consistency를 활용하여 slices 구조 정보를 LLM에 효과적으로 전달.
  • 이를 통해 LLaVA-UHD v2는 fine-grained visual details와 high-level semantic information을 모두 효과적으로 처리하여 MLLM의 성능을 향상시킴.

 

 

  1. 입력 이미지 전처리: 이미지를 여러 slices와 overview image로 분할.
  2. 특징 추출: ViT를 사용하여 각 부분 이미지(slices와 overview)에서 features 추출.
  3. Hiwin Transformer 적용:
    • Inverse Feature Pyramid 구축: CNN과 유사하게, JBU 모듈로 ViT features를 up-sampling하고 high-frequency details를 추가하여 다양한 해상도의 feature pyramid 생성.
    • Hierarchical Window Attention 적용: Twin Transformer와 유사하게, 계층적으로 window 크기를 조정하며 attention을 적용하여 feature pyramid의 정보를 효율적으로 통합하고 압축.
  4. LLM 입력 생성: Spatially-consistent Token Organization을 통해 spatial 정보를 보존하며 visual tokens를 생성하고, 이를 LLM에 입력.

추가적으로 핵심 포인트를 잘 짚으셨습니다:

  • Inverse Feature Pyramid: CNN의 convolution 연산과 유사하게, JBU 모듈을 통해 ViT features에 계층적이고 풍부한 정보를 추가합니다.
  • Hierarchical Window Attention: Twin Transformer처럼 계층적으로 window를 조정하며 attention을 적용하는 것이 맞습니다. 이를 통해 이미지의 local details와 global context를 모두 고려합니다.
  • Spatially-consistent Token Organization: 말씀하신 대로 positional encoding과 유사한 역할을 합니다. 이미지 slices의 공간적 배열 정보를 LLM에 전달하여 이미지 구조에 대한 이해를 돕습니다.

결론적으로, LLaVA-UHD v2는 복잡해 보이지만, 본질은 "다양한 해상도의 정보를 효율적으로 통합하고 압축하여 LLM에 전달하는 것"입니다.

  • Inverse Feature Pyramid는 다양한 해상도의 정보를 생성하고,
  • Hierarchical Window Attention은 이 정보를 효율적으로 통합하고 압축하며,
  • Spatially-consistent Token Organization은 공간 정보를 보존합니다.