비전 언어 모델 설명

Vision Language Models(VLM)은 이미지와 텍스트 입력을 처리하여 텍스트 출력을 생성하는 멀티모달 생성 모델로, 시각적 질문 응답, 이미지 캡션 생성, 문서 이해와 같은 작업을 가능하게 합니다. 이러한 모델은 웹 페이지와 문서를 포함한 다양한 이미지 유형에 대해 제로샷 일반화를 제공하며, 일부 모델은 경계 상자나 세그멘테이션 마스크를 통해 공간적 그라운딩을 제공할 수 있습니다.

비전 언어 모델의 아키텍처

Most prominent VLMs utilize a three-part architecture to unify image and text representations for a text decoder. This structure typically consists of:

  1. Image Encoder: 입력 이미지에서 특징을 추출합니다.
  2. Embedding Projector: 이미지 표현과 텍스트 표현을 정렬하는 밀집 신경망입니다.
  3. Text Decoder: 결합된 임베딩을 기반으로 최종 텍스트 출력을 생성합니다.

Different training strategies are employed depending on the model. For example, LLaVA uses a CLIP image encoder and a Vicuna text decoder; it first trains only the multimodal projector to align features using image-caption pairs, then unfreezes the text decoder for further training. In contrast, KOSMOS-2 is trained end-to-end, which is more computationally expensive. Some models, like Fuyu-8B, omit the image encoder entirely, feeding image patches directly into a projection layer before the auto-regressive decoder.

오픈소스 VLM 현황

Numerous open-source VLMs are available on the Hugging Face Hub. Key models include:

  • LLaVA 1.6 (Hermes 34B): 34B 파라미터, 672x672 해상도.
  • DeepSeek-VL (Base and Chat): 7B 파라미터, 384x384 해상도, 채팅 최적화 버전 포함.
  • CogVLM (Base and Chat): 17B 파라미터, 490x490 해상도; 채팅 버전은 그라운딩을 지원합니다.
  • moondream2: 약 2B 파라미터, 378x378 해상도.
  • Qwen-VL (Base and Chat): 4B 파라미터, 448x448 해상도; 제로샷 객체 탐지를 지원합니다.
  • KOSMOS-2: 약 2B 파라미터, 224x224 해상도; 그라운딩 및 제로샷 객체 탐지를 지원합니다.
  • Yi-VL-34B: 34B 파라미터, 448x448 해상도; 영어와 중국어를 지원하는 이중 언어 모델입니다.
  • Fuyu-8B: 8B 파라미터, 300x300 해상도; 이미지 내 텍스트 탐지에 특화되었습니다.

VLM 성능 평가

Selecting the right VLM requires utilizing specialized leaderboards and benchmarks to measure reasoning and understanding capabilities.

리더보드

  • Vision Arena: 익명 인간 선호 투표를 기반으로 하는 지속적인 리더보드입니다.
  • Open VLM Leaderboard: 다양한 지표를 기반으로 모델을 순위 매기며, 크기와 라이선스로 필터링할 수 있습니다.

벤치마크

  • MMMU: 엔지니어링, 예술 등 다양한 분야의 대학 수준 지식을 요구하는 11.5K 멀티모달 과제를 포함한 포괄적인 벤치마크입니다.
  • MMBench: 20가지 기술(예: OCR, 객체 위치 지정)에서 3,000개의 단일 선택 질문으로 구성됩니다. 답변 선택지를 섞어 모델 일관성을 보장하는 "CircularEval" 전략을 사용합니다.
  • Domain-Specific Benchmarks: 여기에는 수학적 추론을 위한 MathVista, 다이어그램 이해를 위한 AI2D, 과학 질문을 위한 ScienceQA, 문서 이해를 위한 OCRBench가 포함됩니다.

구현 및 파인튜닝

Transformers를 이용한 추론

VLMs can be deployed for inference using the transformers library. For instance, using LlavaNextForConditionalGeneration and LlavaNextProcessor, users can pass an image and a prompt template to generate text descriptions or answers about the image.

TRL을 이용한 파인튜닝

TRL's SFTTrainer now includes experimental support for Vision Language Models. This allows users to perform Supervised Fine-Tuning (SFT) on models like Llava 1.5 using datasets such as llava-instruct-mix-vsft, which contains 260k image-conversation pairs. The process involves:

  1. VLM에 대한 특정 채팅 템플릿을 설정합니다.
  2. 텍스트와 이미지 쌍을 결합하기 위해 커스텀 DataCollator를 사용합니다.
  3. 모델, 데이터셋, PEFT 구성을 사용하여 SFTTrainer를 초기화하고 학습한 후 결과 체크포인트를 Hugging Face Hub에 푸시합니다.

Sources