[Paper Review] LLaVA: Visual Instruction Tuning - ๋ฉํฐ๋ชจ๋ฌ AI์ ์๋ก์ด ํจ๋ฌ๋ค์

๋ ผ๋ฌธ ์ ๋ณด
- ์ ๋ชฉ: Visual Instruction Tuning
- ์ ์: Haotian Liu, Chunyuan Li, Qingyang Wu, Yong Jae Lee
- ์์: University of WisconsinโMadison, Microsoft Research, Columbia University
- ๋ฐํ: NeurIPS 2023
- ๋ ผ๋ฌธ ๋งํฌ: https://arxiv.org/abs/2304.08485
- GitHub: https://github.com/haotian-liu/LLaVA
-
Introduction: Visual Instruction Tuning์ ํ์
์ฐ๊ตฌ ๋ฐฐ๊ฒฝ
๋ํ ์ธ์ด ๋ชจ๋ธ(LLM)์ instruction tuning์ ํตํด zero-shot ์ฑ๋ฅ์ ํฌ๊ฒ ํฅ์์์ผฐ์ต๋๋ค. ChatGPT์ GPT-4์ ์ฑ๊ณต์ ์ธ์ด ์์ญ์์ instruction-following์ ๊ฐ๋ ฅํจ์ ์ ์ฆํ์ต๋๋ค. ํ์ง๋ง ๋ฉํฐ๋ชจ๋ฌ ์์ญ์์์ instruction tuning์ ๊ฑฐ์ ํ๊ตฌ๋์ง ์์์ต๋๋ค.
๊ธฐ์กด ์ปดํจํฐ ๋น์ ์ฐ๊ตฌ๋ค์:
- ๊ฐ ํ์คํฌ๋ฅผ ๋ ๋ฆฝ์ ์ผ๋ก ํด๊ฒฐ (classification, detection, segmentation ๋ฑ)
- ๊ณ ์ ๋ ์ธํฐํ์ด์ค์ ์ ํ์ ์ธ ์ํธ์์ฉ์ฑ
- ์ธ์ด๋ฅผ ์ด๋ฏธ์ง ์ค๋ช ์๋ง ํ์ฉ

LLaVA์ ํต์ฌ ์์ด๋์ด
LLaVA(Large Language and Vision Assistant)๋ vision๊ณผ language๋ฅผ ํตํฉํ end-to-end ํ์ต ๋ฉํฐ๋ชจ๋ฌ ๋ชจ๋ธ์ ๋๋ค.

์ฃผ์ ๊ธฐ์ฌ์ :
-
Multimodal Instruction-Following Data
- ์ธ์ด ์ ์ฉ GPT-4๋ฅผ ํ์ฉํ์ฌ vision-language instruction ๋ฐ์ดํฐ ์์ฑ
- Image-text ์์ instruction-following ํ์์ผ๋ก ๋ณํ
- ์ด 158K๊ฐ์ ๊ณ ํ์ง ๋ฐ์ดํฐ์ ๊ตฌ์ถ
-
Large Multimodal Model (LMM)
- CLIP ๋น์ ์ธ์ฝ๋์ Vicuna ์ธ์ด ๋ชจ๋ธ ์ฐ๊ฒฐ
- End-to-end ํ์ต์ผ๋ก ๋ฉํฐ๋ชจ๋ฌ instruction-following ๋ฅ๋ ฅ ํ๋
- GPT-4์์ ์์๋ธ๋ก Science QA์์ 92.53% ์ ํ๋ ๋ฌ์ฑ (์๋ก์ด SOTA)
-
ํ๊ฐ ๋ฒค์น๋งํฌ
- LLaVA-Bench (COCO): ์ผ๊ด์ฑ ์๋ ํ๊ฐ
- LLaVA-Bench (In-the-Wild): ๋ค์ํ๊ณ ๋์ ์ ์ธ ์ค์ธ๊ณ ํ์คํฌ
์ฑ๊ณผ
- GPT-4 ๋๋น 85.1% ์๋ ์ ์ ๋ฌ์ฑ (synthetic multimodal instruction-following ๋ฐ์ดํฐ์ )
- Unseen ์ด๋ฏธ์ง/๋ช ๋ น์์ GPT-4์ ์ ์ฌํ ๋ฉํฐ๋ชจ๋ฌ ํ๋ ์ ์
- ๋ชจ๋ ๋ฐ์ดํฐ, ์ฝ๋, ๋ชจ๋ธ์ ์คํ์์ค๋ก ๊ณต๊ฐ
-
Related Work: ๊ธฐ์กด ์ฐ๊ตฌ์์ ์ฐจ๋ณ์
Multimodal Instruction-Following Agents
์ฌ๋์๊ฒ โ์ด ์ฌ์ง์์ ๊ณ ์์ด๋ฅผ ์ฐพ์์ ๋นจ๊ฐ์์ผ๋ก ์น ํด์คโ๋ผ๊ณ ๋งํ๋ฉด ๋๋ถ๋ถ ์ฝ๊ฒ ํด๋ผ ์ ์์ต๋๋ค. ํ์ง๋ง AI์๊ฒ๋ ์ด๋ฏธ์ง ์ดํด, ์์ฐ์ด ํด์, ํ๋ ์คํ์ด๋ผ๋ ์ธ ๊ฐ์ง ๋ฅ๋ ฅ์ด ๋์์ ํ์ํ ์ด๋ ค์ด ๋ฌธ์ ์ ๋๋ค. ์ฐ๊ตฌ์๋ค์ ์ด ๋ฌธ์ ๋ฅผ ํฌ๊ฒ ๋ ๋ฐฉํฅ์ผ๋ก ์ ๊ทผํด์์ต๋๋ค.
์ฒซ ๋ฒ์งธ๋ End-to-End ํ์ต ๋ชจ๋ธ์ ๋๋ค.
์ ๋ ฅ๋ถํฐ ์ถ๋ ฅ๊น์ง ํ๋์ ์ ๊ฒฝ๋ง์ด ๋ชจ๋ ๊ฒ์ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ผ๋ก, Vision-Language Navigation(VLN), Habitat 2.0, InstructPix2Pix ๋ฑ์ด ๋ํ์ ์ ๋๋ค.
- VLN์ โ๊ฑฐ์ค๋ก ๊ฐ์ ๋นจ๊ฐ ์ํ ์์ ์โ์ ๊ฐ์ ์ง์๋ฅผ ๋ฐ์ ๋ก๋ด์ด ์ค์ ๋ก ์ด๋ํ๋ ํ์คํฌ๋ฅผ ๋ค๋ฃจ๊ณ , InstructPix2Pix๋ โ์ด ์ฌ์ง์ ํ๋ฐฑ์ผ๋ก ๋ฐ๊ฟ์คโ ๊ฐ์ ํธ์ง ์ง์๋ฅผ ๋ฐ์ ์ด๋ฏธ์ง๋ฅผ ์ง์ ์์ ํฉ๋๋ค.
- ์ด๋ฐ ๋ชจ๋ธ๋ค์ ์ถ๋ก ์๋๊ฐ ๋น ๋ฅด๊ณ ํ์ต๋ ํ์คํฌ์์ ๋์ ์ฑ๋ฅ์ ๋ณด์ด์ง๋ง, ๊ฐ ๋ชจ๋ธ์ด ํน์ ํ์คํฌ์๋ง ํนํ๋์ด ์๋ค๋ ํ๊ณ๊ฐ ์์ต๋๋ค. ์๋ก์ด ํ์คํฌ๊ฐ ํ์ํ๋ฉด ์ฒ์๋ถํฐ ๋ณ๋์ ๋ชจ๋ธ์ ํ์ต์์ผ์ผ ํฉ๋๋ค.
๋ ๋ฒ์งธ๋ ์์คํ ๊ธฐ๋ฐ ์ ๊ทผ์ ๋๋ค.
LLM์ ์งํ์(Orchestrator)๋ก ํ์ฉํ์ฌ ์ฌ๋ฌ ์ ๋ฌธ ๋ชจ๋ธ์ ์์ฐจ์ ์ผ๋ก ํธ์ถํ๋ ๋ฐฉ์์ ๋๋ค. Visual ChatGPT, MM-REACT, VisProg, ViperGPT ๋ฑ์ด ์ฌ๊ธฐ์ ํด๋นํฉ๋๋ค.
- ์๋ฅผ ๋ค์ด Visual ChatGPT๋ ์ฌ์ฉ์๊ฐ โ๋ฐฐ๊ฒฝ์ ์ ๊ฑฐํ๊ณ ์ ํ ์คํ์ผ๋ก ๋ฐ๊ฟ์คโ๋ผ๊ณ ์์ฒญํ๋ฉด, ChatGPT๊ฐ ์ด ์ง์๋ฅผ ๋ถ์ํ์ฌ Segment Anything์ผ๋ก ๋ฐฐ๊ฒฝ์ ์ ๊ฑฐํ๊ณ , Stable Diffusion์ผ๋ก ์คํ์ผ์ ๋ณํํ๋ ์์ผ๋ก ์๋ํฉ๋๋ค. ๋ค์ํ ํ์คํฌ๋ฅผ ์ฒ๋ฆฌํ ์ ์๋ค๋ ์ฅ์ ์ด ์์ง๋ง, ์ฌ๋ฌ ๋ชจ๋ธ์ ์์ฐจ ํธ์ถํ๋ฏ๋ก ์๋๊ฐ ๋๋ฆฌ๊ณ , ์์ ๋ชจ๋ธ์ ์ค๋ฅ๊ฐ ๋ค๋ฐ๋ฅด๋ ๋ชจ๋ธ๋ก ์ ํ๋๋ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
LLaVA๋ ์ด ๋ ์ ๊ทผ๋ฒ ์ฌ์ด์์ ๊ท ํ์ ์ ์ฐพ์ต๋๋ค. End-to-End ๋ชจ๋ธ์ ํจ์จ์ฑ(๋จ์ผ ๋ชจ๋ธ, ๋น ๋ฅธ ์ถ๋ก )์ ์ ์งํ๋ฉด์๋, ์์คํ ๊ธฐ๋ฐ ์ ๊ทผ์ ๋ฒ์ฉ์ฑ(๋ค์ํ ํ์คํฌ ์ฒ๋ฆฌ)์ ๊ฐ์ถ๋ ๊ฒ์ด ๋ชฉํ์ ๋๋ค.
Instruction Tuning in NLP
Instruction Tuning์ ์ฌ์ ํ์ต๋ LLM์ ์์ฐ์ด ์ง์๋ฌธ ํํ์ ๋ฐ์ดํฐ๋ก ์ถ๊ฐ ํ์ต์์ผ, ๋ค์ํ ํ์คํฌ๋ฅผ zero-shot์ผ๋ก ์ํํ ์ ์๊ฒ ๋ง๋๋ ๊ธฐ๋ฒ์ ๋๋ค.
- GPT-3๋ InstructGPT๋ก, T5๋ FLAN-T5๋ก, PaLM์ FLAN-PaLM์ผ๋ก ๋ฐ์ ํ์ต๋๋ค. ๊ธฐ๋ณธ GPT-3์๊ฒ โTranslate โhelloโ to Koreanโ์ด๋ผ๊ณ ์ ๋ ฅํ๋ฉด ๋ฌธ์ฅ์ ๊ทธ๋ฅ ์ด์ด์ ์์ฑํ์ง๋ง, InstructGPT๋ ์ง์๋ฅผ ์ดํดํ๊ณ โ์๋ ํ์ธ์โ๋ผ๊ณ ์ ํํ ์๋ตํฉ๋๋ค.

https://medium.com/@lmpo/an-overview-instruction-tuning-for-llms-440228e7edab
LLaVA๋ ์ด Instruction Tuning ์์ด๋์ด๋ฅผ ๋น์ ๋ถ์ผ์ ์ ์ฉํฉ๋๋ค. ํต์ฌ์ ํ์ต ๋ฐ์ดํฐ๋ฅผ ์ด๋ป๊ฒ ํ๋ณดํ๋๋์ธ๋ฐ, LLaVA๋ GPT-4๋ฅผ ๋ฐ์ดํฐ ์์ฑ๊ธฐ๋ก ํ์ฉํฉ๋๋ค. GPT-4๋ ์ด๋ฏธ์ง๋ฅผ ์ง์ ๋ณผ ์ ์์ง๋ง, ์ด๋ฏธ์ง์ ์บก์ ์ด๋ ๋ฐ์ด๋ฉ ๋ฐ์ค ์ ๋ณด๋ฅผ ํ ์คํธ๋ก ์ ๊ณต๋ฐ์ผ๋ฉด ํด๋น ์ด๋ฏธ์ง์ ๋ํ ๊ณ ํ์ง Q&A ๋ฐ์ดํฐ๋ฅผ ์์ฑํ ์ ์์ต๋๋ค. ์ด๋ NLP์์ ๊ฒ์ฆ๋ Self-Instruct ๋ฐฉ์์ ๋ณํ์ผ๋ก, LLaVA๋ ์ด๋ ๊ฒ ์์ฑ๋ visual instruction-following ๋ฐ์ดํฐ๋ก vision-language ๋ชจ๋ธ์ ํ๋ํฉ๋๋ค.
๊ธฐ์กด Large Multimodal Models (LMMs)
LLaVA๊ฐ ๋ฑ์ฅํ๊ธฐ ์ ์๋ ์ด๋ฏธ์ง์ ํ ์คํธ๋ฅผ ํจ๊ป ์ฒ๋ฆฌํ๋ Large Multimodal Model๋ค์ด ์กด์ฌํ์ต๋๋ค. ์ด ํ๋ฆ์ ์์์ ์ผ๋ก ๋ง์ด ์ธ๊ธ๋๋ ๊ฒ์ด ๋ฐ๋ก Flamingo์ ๋๋ค.

Flamingo๋ โ๋ฉํฐ๋ชจ๋ฌ GPT-3 ์๊ฐโ์ด๋ผ ๋ถ๋ฆด ๋งํผ ์์ง์ ์ธ ๋ชจ๋ธ๋ก, ๋๊ท๋ชจ ์ด๋ฏธ์ง-ํ ์คํธ ๋ฐ์ดํฐ๋ก ํ์ตํ์ฌ zero-shot task transfer์ in-context learning ๋ฅ๋ ฅ์ ๋ณด์ฌ์ฃผ์์ต๋๋ค.
(์ฐธ๊ณ ) GPT-3(2020) ์ด์ ์ NLP ๋ชจ๋ธ๋ค์ ์๋ก์ด ํ์คํฌ๋ฅผ ์ํํ๋ ค๋ฉด ํด๋น ํ์คํฌ์ ๋ง๋ ๋ฐ์ดํฐ๋ก fine-tuning์ด ํ์์์ต๋๋ค.
- ๊ทธ๋ฐ๋ฐ GPT-3๋ ๋ณ๋ fine-tuning ์์ด ํ๋กฌํํธ์ ๋ช ๊ฐ์ ์์๋ง ๋ณด์ฌ์ฃผ๋ฉด(few-shot) ์๋ก์ด ํ์คํฌ๋ฅผ ์ํํ ์ ์์์ต๋๋ค. ์ด๊ฒ ๋ฐ๋ก in-context learning์ด๊ณ , โscaling์ด ๊ณง ๋ฅ๋ ฅ์ด๋คโ๋ผ๋ ํจ๋ฌ๋ค์์ ์ด์์ฃ .
๋ง์น GPT-3๊ฐ NLP ๋ถ์ผ์์ few-shot learning์ ๊ฐ๋ฅ์ฑ์ ์ด์๋ฏ์ด, Flamingo๋ ๋น์ -์ธ์ด ๋ถ์ผ์์ ๋น์ทํ ํจ๋ฌ๋ค์ ์ ํ์ ์ด๋์์ต๋๋ค.
Flamingo๋ GPT-3์ฒ๋ผ few-shot in-context learning์ ๋ฉํฐ๋ชจ๋ฌ ์์ญ์์ ์ฒ์์ผ๋ก ๊ฐ๋ฅํ๊ฒ ํ์ต๋๋ค:
- ์ด๋ฏธ์ง-ํ ์คํธ ์์ ๋ช ๊ฐ๋ง ํ๋กฌํํธ์ ๋ฃ์ด์ฃผ๋ฉด
- Fine-tuning ์์ด VQA, ์บก์ ๋, ๋ถ๋ฅ ๋ฑ ๋ค์ํ ํ์คํฌ ์ํ
- ์ฌ์ง์ด ์ผ๋ถ ๋ฒค์น๋งํฌ์์ fine-tuned ๋ชจ๋ธ๋ค์ ๋ฅ๊ฐ
Flamingo ์ดํ๋ก ๋ค์ํ image-text ์ ๊ธฐ๋ฐ ํ์ต ๋ชจ๋ธ๋ค์ด ๋ฑ์ฅํ์ต๋๋ค. BLIP-2๋ frozen image encoder์ LLM์ Q-Former๋ผ๋ ๊ฒฝ๋ ๋ชจ๋๋ก ์ฐ๊ฒฐํ์ฌ ํจ์จ์ ์ธ ํ์ต์ ๊ฐ๋ฅํ๊ฒ ํ๊ณ , FROMAGe๋ ํ ์คํธ ์์ฑ๊ณผ ์ด๋ฏธ์ง ๊ฒ์(retrieval)์ ๋ชจ๋ ์ํํ ์ ์๋ ๋ฅ๋ ฅ์ ๊ฐ์ถ์์ต๋๋ค. KOSMOS-1์ ๋ง์ดํฌ๋ก์ํํธ์์ ๋ฐํํ ๋ชจ๋ธ๋ก ๋ค์ํ ๋ฉํฐ๋ชจ๋ฌ ํ์คํฌ์์ ๊ฐ๋ ฅํ ์ฑ๋ฅ์ ๋ณด์์ผ๋ฉฐ, PaLM-E๋ ๊ตฌ๊ธ์์ ๋ก๋ด ์ ์ด์ ๊ฐ์ embodied AI ํ์คํฌ๋ฅผ ์ํด ์ค๊ณ๋์์ต๋๋ค. ์คํ์์ค ์ง์์์๋ OpenFlamingo์ LLaMA-Adapter ๋ฑ์ด ๊ณต๊ฐ๋๋ฉด์ ์ฐ๊ตฌ ์ปค๋ฎค๋ํฐ์ ์ ๊ทผ์ฑ์ด ๋์์ก์ต๋๋ค.
- BLIP-2, FROMAGe ๋ฑ์ contrastive learning์ด๋ captioning ๊ฐ์ ํน์ ํ์คํฌ๋ก ํ์ต๋์ด ๊ทธ ๋ฒ์ ๋ด์์๋ง ๋์ํ์ต๋๋ค. Flamingo๋ few-shot in-context learning์ผ๋ก ๋ ์ ์ฐํ์ง๋ง, ์ด๊ฒ๋ ์์ ํจํด์ ๋ฐ๋ผํ๋ ๋ฐฉ์์ด์ง ์์ฐ์ด ์ง์๋ฅผ ์ง์ ์ดํดํ๋ ๊ฒ์ ์๋์์ต๋๋ค. ์ฆ, โ์ด ์ด๋ฏธ์ง์์ ์ฌ๋๋ค์ ๊ฐ์ ์ ๋ถ์ํด์คโ ๊ฐ์ ๋ณต์กํ instruction์ ์์ฐ์ค๋ฝ๊ฒ ๋ฐ๋ฅด๋๋ก ๋ช ์์ ์ผ๋ก ํ์ต๋ ๋ชจ๋ธ์ ์์์ต๋๋ค.
NLP ๋ถ์ผ์์ GPT-3๊ฐ InstructGPT๋ก ๋ฐ์ ํ๋ฉฐ ์ฌ์ฉ์ ์ง์๋ฅผ ํจ์ฌ ์ ๋ฐ๋ฅด๊ฒ ๋ ๊ฒ์ฒ๋ผ, ๋ฉํฐ๋ชจ๋ฌ ๋ชจ๋ธ์๋ ์ด๋ฐ instruction tuning์ด ํ์ํ์ง๋ง ์์ง ์ฒด๊ณ์ ์ผ๋ก ์ฐ๊ตฌ๋์ง ์์ ์ํ์์ต๋๋ค.
- ๊ทธ ๊ฒฐ๊ณผ, ์ด ๋ชจ๋ธ๋ค์ ์ธ์ด ์ ์ฉ ํ์คํฌ์์๋ ์ค์ํ ์ฑ๋ฅ์ ๋ณด์ด๋ฉด์๋, ์ด๋ฏธ์ง์ ๋ํ ๋ณต์กํ ์ง๋ฌธ์ ๋ตํ๊ฑฐ๋ ์๊ฐ์ reasoning์ด ํ์ํ ๋ฉํฐ๋ชจ๋ฌ ํ์คํฌ์์๋ ์๋์ ์ผ๋ก ๋ฎ์ ์ฑ๋ฅ์ ๋ณด์์ต๋๋ค.
LLaVA๋ ๋ฐ๋ก ์ด ๊ฒฉ์ฐจ๋ฅผ ๋ฉ์ฐ๊ธฐ ์ํด ๋ฑ์ฅํ์ต๋๋ค. ๊ธฐ์กด ๋ชจ๋ธ๋ค์ด ๋์น๊ณ ์๋ visual instruction tuning์ ์ฒด๊ณ์ ์ผ๋ก ์ฐ๊ตฌํ๊ณ , ์ด๋ฅผ ํตํด ๋ฉํฐ๋ชจ๋ฌ ํ์คํฌ์์์ ์ฑ๋ฅ์ ๋์ด์ฌ๋ฆฌ๋ ๊ฒ์ด LLaVA์ ํต์ฌ ๋ชฉํ์ ๋๋ค.
-
GPT-assisted Visual Instruction Data Generation
๋ฌธ์ ์ : ๋ฉํฐ๋ชจ๋ฌ Instruction ๋ฐ์ดํฐ ๋ถ์กฑ
- Image-text ์ (CC, LAION)์ ํ๋ถ
- ํ์ง๋ง multimodal instruction-following ๋ฐ์ดํฐ๋ ๋งค์ฐ ์ ํ์
- ์ด์ : ์์์ ์์ง์ด ์๊ฐ ์๋ชจ์ ์ด๊ณ ์ ์๊ฐ ๋ชจํธํจ
ํด๊ฒฐ์ฑ : GPT-4 ํ์ฉ ๋ฐ์ดํฐ ์์ฑ

GPT-4๋ ์ด๋ฏธ์ง๋ฅผ ์ง์ ๋ณผ ์ ์์ผ๋๊น, ํ ์คํธ๋ก ์ด๋ฏธ์ง ์ ๋ณด๋ฅผ ์ค๋ช ํด์ค๋๋ค. (์ด๋ฏธ์ง ์๋จ: GPT-4์๊ฒ ์ฃผ๋ ์ ๋ ฅ (Context))
Symbolic Representation
์ด๋ฏธ์ง๋ฅผ ์ธ์ด ์ ์ฉ GPT-4๊ฐ ์ดํดํ ์ ์๋ ํํ๋ก ์ธ์ฝ๋ฉ:
1. Captions (์ด๋ฏธ์ง ์ค๋ช )
- ๋ค์ํ ๊ด์ ์์ ์๊ฐ์ ์ฅ๋ฉด ๋ฌ์ฌ
-
์์:
1 2 3
A group of people standing outside of a black vehicle with various luggage. Luggage surrounds a vehicle in an underground parking area. People try to fit all of their luggage in an SUV.
2. Bounding Boxes (๊ฐ์ฒด ์์น)
- ๊ฐ์ฒด ๊ฐ๋ ๊ณผ ๊ณต๊ฐ ์ ๋ณด ์ธ์ฝ๋ฉ
-
์์:
1 2 3
person: [0.681, 0.242, 0.774, 0.694] backpack: [0.384, 0.696, 0.485, 0.914] suitcase: [0.758, 0.413, 0.845, 0.69]
์ด context๋ฅผ ๋ฐํ์ผ๋ก GPT-4๊ฐ 3๊ฐ์ง ์ ํ์ Q&A ๋ฐ์ดํฐ๋ฅผ ์์ฑํฉ๋๋ค. (์ด๋ฏธ์ง ํ๋จ: GPT-4๊ฐ ์์ฑํ๋ ์ถ๋ ฅ (Response))
์ธ ๊ฐ์ง ๋ฐ์ดํฐ ์ ํ
Response type 1: Conversation (๋จ์ ๋ํ)
- ์ฌ๋๊ณผ ์ด์์คํดํธ ๊ฐ์ ๋ํ
- ๊ฐ์ฒด ์ ํ, ๊ฐ์, ํ๋, ์์น, ์๋์ ์์น ๋ฑ์ ๋ํ ์ง๋ฌธ
- ๋ช ํํ ๋ต๋ณ์ด ์๋ ์ง๋ฌธ๋ง ํฌํจ
1
2
Q: What type of vehicle is featured in the image?
A: The image features a black sport utility vehicle (SUV)...
Response type 2: Detailed Description (์์ธ ์ค๋ช )
- ์ด๋ฏธ์ง์ ๋ํ ํ๋ถํ๊ณ ํฌ๊ด์ ์ธ ์ค๋ช
- GPT-4๊ฐ ์ง๋ฌธ ๋ชฉ๋ก ์์ฑ ํ ์ ๋ณ
1
2
3
4
Q: (์๋ฌต์ ์ผ๋ก "์ด๋ฏธ์ง๋ฅผ ์ค๋ช
ํด์ค")
A: The image is an underground parking area with a black SUV parked.
There are three people in the scene, with one person standing closer
to the left side of the vehicle...
Response type 3: Complex Reasoning (๋ณต์กํ ์ถ๋ก )
- ์๊ฐ ์ฝํ ์ธ ๊ธฐ๋ฐ ์ฌ์ธต ์ถ๋ก ์ง๋ฌธ
- ๋จ๊ณ๋ณ ๋ ผ๋ฆฌ์ ์ถ๋ก ๊ณผ์ ํ์
1
2
3
4
Q: What challenges do these people face?
A: They are facing the challenge of fitting all their luggage into the
black SUV. There are multiple suitcases and backpacks to be packed,
which suggests that the group has a significant amount of belongings...
-
Visual Instruction Tuning
4.1 Architecture: 3-Component ์ค๊ณ
์ ์ฒด ๊ตฌ์กฐ

๊ตฌ์ฑ ์์
1. Vision Encoder: CLIP ViT-L/14
- Pre-trained, frozen ์ํ ์ ์ง
- ์ ๋ ฅ: 336ร336px ์ด๋ฏธ์ง
- ์ถ๋ ฅ: Grid features (Zv)
- 576 patch tokens (24ร24 grid)
- 1 class token
- Dimension: 1024
2. Projection Layer
Hv=Wโ Zv,withZv=g(Xv)H_v = W ยท Z_v, with Z_v = g(X_{v})Hvโ=Wโ Zvโ,withZvโ=g(Xvโ)
- Trainable projection matrix W
- ๋น์ features๋ฅผ ์ธ์ด embedding ๊ณต๊ฐ์ผ๋ก ๋ณํ
- Lightweight ์ค๊ณ๋ก ๋น ๋ฅธ ์คํ ๋ฐ๋ณต ๊ฐ๋ฅ
3. Language Model: Vicuna
- ๊ณต๊ฐ๋ ์ฒดํฌํฌ์ธํธ ์ค ์ต๊ณ ์ instruction-following ๋ฅ๋ ฅ
- ํ๋ผ๋ฏธํฐ ฯ๋ก ํํ

์ค๊ณ ์ฒ ํ
- Simple but Effective:
- Linear projection ์ฌ์ฉ
- ๋ ์ ๊ตํ ๋ฐฉ์๋ ๊ฐ๋ฅ:
- Flamingo์ gated cross-attention
- BLIP-2์ Q-former
- ํฅํ ์ฐ๊ตฌ ๊ณผ์ ๋ก ๋จ๊น
4.2 Training: 2-Stage Procedure
๋ฐ์ดํฐ ํ์
๊ฐ ์ด๋ฏธ์ง Xv\mathbf{X}_vXvโ์ ๋ํด multi-turn conversation ๋ฐ์ดํฐ (Xq1,Xa1,โฏโ,XqT,XaT)(\mathbf{X}_q^1, \mathbf{X}_a^1, \cdots, \mathbf{X}_q^T, \mathbf{X}_a^T)(Xq1โ,Xa1โ,โฏ,XqTโ,XaTโ)๋ฅผ ์์ฑํฉ๋๋ค. ์ฌ๊ธฐ์ TTT๋ ์ด ํด ์์ด๊ณ , Xq\mathbf{X}_qXqโ๋ ์ง๋ฌธ, Xa\mathbf{X}_aXaโ๋ ์๋ต์ ๋๋ค.
ttt๋ฒ์งธ ํด์ instruction Xinstructt\mathbf{X}_{\text{instruct}}^tXinstructtโ๋ ๋ค์๊ณผ ๊ฐ์ด ๊ตฌ์ฑ๋ฉ๋๋ค:
- ์ฒซ ๋ฒ์งธ ํด (t=1): [Xq,Xv][\mathbf{X}_q, \mathbf{X}_v][Xqโ,Xvโ] ๋๋ [Xv,Xq][\mathbf{X}_v, \mathbf{X}_q][Xvโ,Xqโ] ์ค ๋๋ค ์ ํ (์ง๋ฌธ-์ด๋ฏธ์ง ์์๋ฅผ ์์ด์ ๋ชจ๋ธ์ด ๋ ๋ค ์ต์ํด์ง๋๋ก)
- ์ดํ ํด (t>1): Xqt\mathbf{X}_q^tXqtโ๋ง ์ฌ์ฉ (์ด๋ฏธ์ง๋ ์ด๋ฏธ ์ ๊ณต๋จ)

์ ๋ ฅ ์ํ์ค ํ์

ํ์ต ๋ชฉํ
LLM์ ๊ธฐ์กด auto-regressive training objective๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๊ธธ์ด LLL์ธ ์ํ์ค์์ target answer Xa\mathbf{X}_aXaโ์ ํ๋ฅ ์ ์ต๋ํํฉ๋๋ค:
| p(XaโฃXv,Xinstruct)=โi=1Lpฮธ(xiโฃXv,Xinstruct,<i,Xa,<i)p(\mathbf{X}_a | \mathbf{X}_v, \mathbf{X}_{\text{instruct}}) = \prod_{i=1}^{L} p_\theta(x_i | \mathbf{X}_v, \mathbf{X}_{\text{instruct},<i}, \mathbf{X}_{a,<i})p(XaโโฃXvโ,Xinstructโ)=โi=1Lโpฮธโ(xiโโฃXvโ,Xinstruct,<iโ,Xa,<iโ) |
์ค์ํ ์ ์ Assistant์ ์๋ต ํ ํฐ(xix_ixiโ)๋ง loss ๊ณ์ฐ์ ์ฌ์ฉ๋๋ค๋ ๊ฒ์ ๋๋ค. Human์ ์ง๋ฌธ์ด๋ ์ด๋ฏธ์ง ํ ํฐ์๋ loss๋ฅผ ๊ฑธ์ง ์์ต๋๋ค.
Stage 1: Pre-training for Feature Alignment
๋ชฉ์ :
- Visual tokenizer ํ์ต
(์ด๋ฏธ์ง features๋ฅผ LLM word embedding ๊ณต๊ฐ์ ์ ๋ ฌ)
๋ฐ์ดํฐ:
- CC3M ํํฐ๋ง โ 595K image-text ์
- Concept coverage์ ํ์ต ํจ์จ์ฑ ๊ท ํ
ํ์ต ์ค์ :
1
2
3
4
5
6
7
X_system-message <STOP>
Human: X_instruct <STOP> Assistant: X_a <STOP>
- X_instruct = [X_q, X_v] ๋๋ [X_v, X_q] (๋๋ค ์ ํ)
- X_q: ์ด๋ฏธ์ง ์ค๋ช
์์ฒญ ์ง๋ฌธ (๋๋ค ์ํ๋ง)
- X_v: ์ด๋ฏธ์ง features
- X_a: ์๋ณธ ์บก์
(ground-truth)
ํ๋ผ๋ฏธํฐ:
- Frozen: Vision encoder, LLM
- Trainable: W (projection matrix)๋ง
- ํ์ต๋ฅ : 2e-3
- Batch size: 128
- Epochs: 1
- ์๊ฐ: 4์๊ฐ (8รA100)
๊ฒฐ๊ณผ: ์ด๋ฏธ์ง features HvH_vHvโ๊ฐ LLM word embedding๊ณผ ์ ๋ ฌ๋จ
Stage 2: Fine-tuning End-to-End
๋ชฉ์ :
- Instruction-following ๋ฅ๋ ฅ ํ๋
ํ๋ผ๋ฏธํฐ:
- Frozen: Vision encoder
- Trainable: W + ฯ (projection + LLM)
Multi-turn Conversation ํ์:
1
2
3
4
5
6
7
8
9
Xsystem-message <STOP>
Human: Xยน_instruct <STOP> Assistant: Xยน_a <STOP>
Human: Xยฒ_instruct <STOP> Assistant: Xยฒ_a <STOP>
...
- X_instruct = [X_q, X_v] ๋๋ [X_v, X_q] (๋๋ค ์ ํ)
- X_q: ์ด๋ฏธ์ง ์ค๋ช
์์ฒญ ์ง๋ฌธ (๋๋ค ์ํ๋ง)
- X_v: ์ด๋ฏธ์ง features
- X_a: ์๋ณธ ์บก์
(ground-truth)
XinstructtX^{t}_{instruct}Xinstructtโ ๊ตฌ์ฑ:
- t=1 (์ฒซ ํด): [Xq1X^1_qXq1โ, XvX_vXvโ] ๋๋ [XvX_vXvโ, Xq1X^1_qXq1โ] (๋๋ค)
- t>1: XqtX^t_qXqtโ
Loss Computation:
| p(XaโฃXv,Xinstruct)=โi=1Lpฮธ(xiโฃXv,Xinstruct,<i,Xa,<i)p(X_a | X_v, X_{instruct}) = โ_{i=1}^Lpฮธ(x_i | X_v, X_{instruct,<i}, X_{a,<i})p(XaโโฃXvโ,Xinstructโ)=i=1โLโpฮธ(xiโโฃXvโ,Xinstruct,<iโ,Xa,<iโ) |
- ์์ธก ํ ํฐ(xix_ixiโ)๋ง loss ๊ณ์ฐ
- Auto-regressive training objective
๊ฒฐ๊ณผ: LLM์ด visual context๋ฅผ ์ดํดํ๋ฉด์ ๋ค์ํ instruction์ ๋ฐ๋ฅด๋ Multimodal Chatbot ๋ฅ๋ ฅ ํ๋
Use Case 1: Multimodal Chatbot
๋ฐ์ดํฐ: 158K language-image instruction-following samples
- Conversation (multi-turn)
- Detailed description (single-turn)
- Complex reasoning (single-turn)
- Uniform sampling during training
ํ์ต ์ค์ :
- ํ์ต๋ฅ : 2e-5
- Batch size: 32
- Epochs: 3
- ์๊ฐ: 10์๊ฐ (8รA100)
Use Case 2: Science QA
๋ฐ์ดํฐ์ : ScienceQA benchmark
- 21K multimodal multiple choice questions
- 3 subjects, 26 topics, 127 categories, 379 skills
- ์์ฐ์ด ์ค๋ช ๊ณผ ์ด๋ฏธ์ง ์ปจํ ์คํธ ์ ๊ณต
ํ์: Single-turn conversation
- X_instruct: Question & context
- X_a: Reasoning process + answer
ํ์ต ์ค์ :
- Visual features: Before last layer ์ฌ์ฉ
- ์ถ๋ ฅ ์์: Reasons โ Answer
- Epochs: 12
- ์๊ฐ: 4์๊ฐ (8รA100)
-
Experiments: ์ฑ๋ฅ ๊ฒ์ฆ
5.1 Multimodal Chatbot ํ๊ฐ
Qualitative Analysis: GPT-4 ์์ ํ ์คํธ
Example: Extreme Ironing

LLaVA ์๋ต:
1
2
3
4
5
6
The unusual aspect of this image is a man ironing clothes on the back
of a minivan or van. This is not a typical place to perform this activity,
as one would usually iron clothes in a more stationary and safe location,
such as a home, using a regular ironing board. The scene depicted in the
image is peculiar as it involves a makeshift ironing setup on a vehicle,
which can be both unsafe and unconventional...
GPT-4 ์๋ต:
1
2
The unusual thing about this image is that a man is ironing clothes on
an ironing board attached to the roof of a moving taxi.
BLIP-2 ์๋ต:
1
a man is sitting on the back of a yellow cab
OpenFlamingo ์๋ต:
1
The man is drying his clothes on the hood of his car.
๋ถ์:
- โ LLaVA: ์ง์์ฌํญ์ ์ ํํ ๋ฐ๋ฅด๊ณ ์์ธํ ์ค๋ช ์ ๊ณต
- โ GPT-4: ๊ฐ๊ฒฐํ์ง๋ง ์ ํ
- โ BLIP-2, OpenFlamingo: ๋จ์ ์ด๋ฏธ์ง ์ค๋ช , instruction ๋ฌด์
Quantitative Evaluation: GPT-4 ๊ธฐ๋ฐ ํ๊ฐ
ํ๊ฐ ๋ฐฉ๋ฒ:
- Triplet ์์ฑ: (Image, Ground-truth description, Question)
- ๋ชจ๋ธ ์๋ต ์์ฑ
- Text-only GPT-4๋ฅผ judge๋ก ํ์ฉ
- Ground-truth description ๊ธฐ๋ฐ ์ฐธ์กฐ ๋ต๋ณ ์์ฑ
- ๋ ์๋ต ๋น๊ต (helpfulness, relevance, accuracy, detail)
- 1-10์ ์ฒ๋ ํ๊ฐ
LLaVA-Bench (COCO): 90 questions
| Training Data | Conversation | Detail | Complex | All |
|---|---|---|---|---|
| Full data | 83.1 | 75.3 | 96.5 | 85.1 |
| Detail + Complex | 81.5 (-1.6) | 73.3 (-2.0) | 90.8 (-5.7) | 81.9 (-3.2) |
| Conv + 5% Detail + 10% Complex | 81.0 (-2.1) | 68.4 (-7.1) | 91.5 (-5.0) | 80.5 (-4.4) |
| Conversation | 76.5 (-6.6) | 59.8 (-16.2) | 84.9 (-12.4) | 73.8 (-11.3) |
| No Instruction Tuning | 22.0 (-61.1) | 24.0 (-51.3) | 18.5 (-78.0) | 21.5 (-63.6) |
ํต์ฌ ๋ฐ๊ฒฌ:
- Instruction tuning์ผ๋ก 50์ ์ด์ ํฅ์
- Detailed description + complex reasoning ์ถ๊ฐ ์ 7์ ํฅ์
- Reasoning ๋ฅ๋ ฅ์ด conversation ๋ฅ๋ ฅ๋ ๋ณด์
- ์ธ ๊ฐ์ง ๋ฐ์ดํฐ ์ ํ ๋ชจ๋ ์ฌ์ฉ ์ ์ต๊ณ ์ฑ๋ฅ
LLaVA-Bench (In-the-Wild): 60 questions
| Model | Conversation | Detail | Complex | All |
|---|---|---|---|---|
| OpenFlamingo | 19.3 ยฑ 0.5 | 19.0 ยฑ 0.5 | 19.1 ยฑ 0.7 | 19.1 ยฑ 0.4 |
| BLIP-2 | 54.6 ยฑ 1.4 | 29.1 ยฑ 1.2 | 32.9 ยฑ 0.7 | 38.1 ยฑ 1.0 |
| LLaVA | 57.3 ยฑ 1.9 | 52.5 ยฑ 6.3 | 81.7 ยฑ 1.8 | 67.3 ยฑ 2.0 |
์ฑ๊ณผ:
- BLIP-2 ๋๋น +29% ํฅ์
- OpenFlamingo ๋๋น +48% ํฅ์
- Complex reasoning์์ text-only GPT-4 ๋๋น 81.7% ๋ฌ์ฑ
Limitations ๋ถ์
๋์ ์ ์ธ ์์ ๋ค:
- Ramen ์์ : ๋ ์คํ ๋ ์ด๋ฆ ์ธ์
- ๋ค๊ตญ์ด ์ดํด ๋ฐ ๊ด๋ฒ์ํ ์ง์ ํ์
- ๋ฐ์ฐฌ ์ค๋ช ์๋ ๋ฉํฐ๋ชจ๋ฌ ์ ๋ณด ๊ฒ์ ํ์
- Fridge ์์ : ์๊ฑฐํธ ๋ธ๋๋ ์ธ์
- ๊ณ ํด์๋ ์ด๋ฏธ์ง ์ฒ๋ฆฌ ํ์
- ๊ด๋ฒ์ํ ์ง์ coverage ์๊ตฌ
ํฅ๋ฏธ๋ก์ด ์คํจ ์ฌ๋ก:
- โ๋ธ๊ธฐ ๋ง ์๊ฑฐํธ๊ฐ ์๋์?โ โ โYesโ
- ์ค์ ๋ก๋ ์๊ฑฐํธ์ ๋ธ๊ธฐ๊ฐ ๋ฐ๋ก ์กด์ฌ
- LLaVA๊ฐ ์ด๋ฏธ์ง๋ฅผ โbag of patchesโ๋ก ์ธ์
- ๋ณต์กํ semantic ๊ด๊ณ ํ์ ์คํจ
5.2 ScienceQA ๋ฒค์น๋งํฌ
๊ฒฐ๊ณผ (Test Set Accuracy %)
| Model | NAT | SOC | LAN | TXT | IMG | NO | G1-6 | G7-12 | Avg |
|---|---|---|---|---|---|---|---|---|---|
| Human | 90.23 | 84.97 | 87.48 | 89.60 | 87.50 | 88.10 | 91.59 | 82.42 | 88.40 |
| GPT-3.5 CoT | 75.44 | 70.87 | 78.09 | 74.68 | 67.43 | 79.93 | 78.23 | 69.68 | 75.17 |
| LLaMA-Adapter | 84.37 | 88.30 | 84.36 | 83.72 | 80.32 | 86.90 | 85.83 | 84.05 | 85.19 |
| MM-CoT_Large | 95.91 | 82.00 | 90.82 | 95.26 | 88.80 | 92.89 | 92.44 | 90.31 | 91.68 |
| LLaVA | 90.36 | 95.95 | 88.00 | 89.49 | 88.00 | 90.66 | 90.93 | 90.90 | 90.92 |
| LLaVA+GPT-4 (judge) | 91.56 | 96.74 | 91.09 | 90.62 | 88.99 | 93.52 | 92.73 | 92.16 | 92.53 |
ํต์ฌ ์ฑ๊ณผ:
- LLaVA ๋จ๋ ์ผ๋ก 90.92% (SoTA MM-CoT_Large์ ๊ทผ์ )
- GPT-4 judge ์์๋ธ๋ก 92.53% (์๋ก์ด SOTA)
- Text-only GPT-4(82.69%)๊ฐ multimodal ์ฑ๋ฅ ํฅ์์ ๊ธฐ์ฌ
Design Ablations
| Variant | Before Last | Last |
|---|---|---|
| Best | 90.92 | 89.96 (-0.96) |
| Predict answer first | - | 89.77 (-1.15) |
| Train from scratch | 85.81 (-5.11) | - |
| 7B model | 89.84 (-1.08) | - |
๋ฐ๊ฒฌ:
- Visual features: Before last layer๊ฐ 0.96% ๋ ๋์
- Last layer: ๊ธ๋ก๋ฒ/์ถ์ ์์ฑ ์ง์ค
- Before last: ์ง์ญ์ ์ธ๋ถ ์ ๋ณด ๋ณด์กด
-
Chain-of-Thought: Reasoning-first ์ ๋ต
- ์๋ ด ์๋ ํฅ์ (6 epochs vs 12 epochs)
- ์ต์ข ์ฑ๋ฅ์๋ ์์ ์ํฅ
-
Pre-training: 5.11% ํฅ์ ๊ธฐ์ฌ
- Multimodal feature alignment
- Pre-trained knowledge ๋ณด์กด
-
Model size: 13B > 7B (1.08% ์ฐจ์ด)
-
์ฝ๋ ๊ตฌํ ๋ถ์
์๋๋ https://github.com/haotian-liu/LLaVA ์ฝ๋๋ฅผ ๋ถ์ ํ ์ ๋ฆฌํ ๋ด์ฉ์ ๋๋ค.
6.1 ๋ฆฌํฌ์งํ ๋ฆฌ ๊ตฌ์กฐ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
LLaVA/
โโโ llava/ # ํต์ฌ ํจํค์ง
โ โโโ model/ # ๋ชจ๋ธ ์ํคํ
์ฒ
โ โ โโโ llava_arch.py # ํต์ฌ vision-language ๋ชจ๋ธ
โ โ โโโ builder.py # ๋ชจ๋ธ ๋ก๋ฉ ๋ฐ ์ธ์คํด์คํ
โ โ โโโ multimodal_encoder/
โ โ โ โโโ clip_encoder.py # CLIP ๋น์ ์ธ์ฝ๋
โ โ โโโ multimodal_projector/
โ โ โโโ builder.py # Vision-language bridge
โ โโโ train/ # ํ์ต ์คํฌ๋ฆฝํธ
โ โ โโโ train.py # ๋ฉ์ธ ํ์ต ํ์ดํ๋ผ์ธ
โ โ โโโ llava_trainer.py # ์ปค์คํ
ํธ๋ ์ด๋
โ โโโ serve/ # ์ถ๋ก ์๋น
โ โ โโโ cli.py
โ โ โโโ gradio_web_server.py # Web UI
โ โ โโโ model_worker.py
โ โโโ mm_utils.py # ๋ฉํฐ๋ชจ๋ฌ ์ ํธ๋ฆฌํฐ
โ โโโ conversation.py # ๋ํ ๊ด๋ฆฌ
โโโ scripts/ # ํ์ต/ํ๊ฐ ์คํฌ๋ฆฝํธ
โ โโโ pretrain.sh
โ โโโ finetune.sh
โ โโโ finetune_lora.sh
โโโ predict.py # ์ถ๋ก ์ธํฐํ์ด์ค

6.2 ํต์ฌ Architecture ๊ตฌํ
1. Vision Encoder (CLIP)
1
2
3
4
5
6
7
# CLIP Vision Model ๋ก๋ฉ
self.vision_tower = CLIPVisionModel.from_pretrained(vision_tower_name)
self.vision_tower.requires_grad_(False) # โญ ํญ์ Frozen
def forward(self, images):
image_features = self.vision_tower(images, output_hidden_states=True)
return image_features # [batch, num_patches, 1024]
Vision Encoder๋ CLIP ViT-L/14๋ฅผ ์ฌ์ฉํ๋ฉฐ, Stage 1, 2 ๋ชจ๋ frozen ์ํ๋ก ์ ์ง๋ฉ๋๋ค.
2. Multimodal Projector
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def build_vision_projector(config):
projector_type = config.mm_projector_type
if projector_type == 'linear':
# ๋จ์ ์ ํ ๋ณํ: 1024 โ 4096
return nn.Linear(config.mm_hidden_size, config.hidden_size)
if projector_type == 'mlp2x_gelu':
# 2-layer MLP: Linear โ GELU โ Linear
return nn.Sequential(
nn.Linear(config.mm_hidden_size, config.hidden_size),
nn.GELU(),
nn.Linear(config.hidden_size, config.hidden_size)
)
Projector๋ Vision Encoder ์ถ๋ ฅ(1024์ฐจ์)์ LLM embedding ๊ณต๊ฐ(4096์ฐจ์)์ผ๋ก ๋ณํํฉ๋๋ค.
3. ์ด๋ฏธ์ง-ํ ์คํธ ๊ฒฐํฉ (ํต์ฌ ๋ก์ง)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def prepare_inputs_labels_for_multimodal(self, input_ids, images, labels, ...):
# 1) ์ด๋ฏธ์ง ์ธ์ฝ๋ฉ
image_features = self.encode_images(images) # [batch, 256, 4096]
# 2) IMAGE_TOKEN_INDEX ์์น ์ฐพ๊ธฐ
image_token_indices = torch.where(input_ids == IMAGE_TOKEN_INDEX)[0]
# 3) ํ
์คํธ embedding๊ณผ ์ด๋ฏธ์ง features ๊ฒฐํฉ
for i, idx in enumerate(image_token_indices):
# ์ด๋ฏธ์ง ํ ํฐ ์ด์ ํ
์คํธ
cur_new_input_embeds.append(embed_tokens(input_ids[:idx]))
# ์ด๋ฏธ์ง features ์ฝ์
cur_new_input_embeds.append(image_features[i])
# ์ด๋ฏธ์ง ํ ํฐ ์ดํ ํ
์คํธ
cur_new_input_embeds.append(embed_tokens(input_ids[idx+1:]))
# 4) ์ด๋ฏธ์ง ์์น์๋ IGNORE_INDEX๋ก loss ์ ์ธ
image_labels = torch.full((num_patches,), IGNORE_INDEX)
return torch.cat(cur_new_input_embeds, dim=0)
ํต์ฌ ํ๋ฆ:
1
2
3
4
5
6
7
์
๋ ฅ: "Human: <image> ์ด ์ฌ์ง์ ์ค๋ช
ํด์ค"
โ
1. <image> ํ ํฐ ์์น ์ฐพ๊ธฐ
2. ํด๋น ์์น์ image_features (256๊ฐ ํ ํฐ) ์ฝ์
3. ์ด๋ฏธ์ง ํ ํฐ์๋ loss ๊ณ์ฐ ์ ์ธ (IGNORE_INDEX)
โ
์ถ๋ ฅ: [ํ
์คํธ ์๋ฒ ๋ฉ] + [์ด๋ฏธ์ง 256ํ ํฐ] + [ํ
์คํธ ์๋ฒ ๋ฉ]
6.3 Training Pipeline
Stage 1 vs Stage 2 ํต์ฌ ์ค์
1
2
3
4
5
6
7
8
9
10
# Stage 1: Projection๋ง ํ์ต
if model_args.tune_mm_mlp_adapter:
model.requires_grad_(False) # ์ ์ฒด frozen
for p in model.get_model().mm_projector.parameters():
p.requires_grad = True # projector๋ง trainable
# Stage 2: Projection + LLM ํ์ต
if training_args.freeze_mm_mlp_adapter:
for p in model.get_model().mm_projector.parameters():
p.requires_grad = False # projector frozen (์ ํ์ )
ํ์ต ํ๋ฆ ์์ฝ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def train():
# 1) ๋ชจ๋ธ ๋ก๋ฉ
model = LlavaLlamaForCausalLM.from_pretrained(model_name_or_path)
# 2) Vision Tower ์ด๊ธฐํ (CLIP)
model.get_model().initialize_vision_modules(model_args)
vision_tower = model.get_vision_tower()
vision_tower.to(dtype=torch.bfloat16, device=device)
# 3) ๋ฐ์ดํฐ์
๋ก๋ฉ
data_module = make_supervised_data_module(tokenizer, data_args)
# 4) ํ์ต ์คํ
trainer = LLaVATrainer(model=model, tokenizer=tokenizer, **data_module)
trainer.train()
# 5) ๋ชจ๋ธ ์ ์ฅ
trainer.save_state()
6.4 Data Processing
๋ฐ์ดํฐ ํ์ (JSON)
1
2
3
4
5
6
7
{
"image": "image_001.jpg",
"conversations": [
{"from": "human", "value": "<image>\n์ด ์ฌ์ง์ ์ค๋ช
ํด์ค"},
{"from": "gpt", "value": "์ด ์ฌ์ง์๋ ๊ณ ์์ด๊ฐ ์์ต๋๋ค..."}
]
}
์ ์ฒ๋ฆฌ ํต์ฌ ๋ก์ง
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class LazySupervisedDataset(Dataset):
def __getitem__(self, i):
# 1) ์ด๋ฏธ์ง ๋ก๋ฉ ๋ฐ ์ ์ฒ๋ฆฌ
image = Image.open(image_path).convert('RGB')
image = processor.preprocess(image, return_tensors='pt')['pixel_values'][0]
# 2) <image> ํ ํฐ ์์น ์ ๊ทํ
# "์ด ์ฌ์ง <image> ์ค๋ช
ํด์ค" โ "<image>\n์ด ์ฌ์ง ์ค๋ช
ํด์ค"
sentence['value'] = DEFAULT_IMAGE_TOKEN + '\n' + sentence['value']
# 3) Conversation โ input_ids, labels ๋ณํ
data_dict = preprocess(sources, tokenizer, has_image=True)
return {
'input_ids': data_dict['input_ids'],
'labels': data_dict['labels'], # Assistant ์๋ต๋ง loss ๊ณ์ฐ
'image': image
}
Labels ์ฒ๋ฆฌ (Loss ๊ณ์ฐ ๋์)
1
2
3
4
์
๋ ฅ: [Human: <image> ์ค๋ช
ํด์ค] [Assistant: ๊ณ ์์ด์
๋๋ค]
labels: [ IGNORE_INDEX ] [ ์ค์ ํ ํฐ ID ]
โ โ
loss ๊ณ์ฐ ์ ํจ loss ๊ณ์ฐ ๋์
6.5 Inference Pipeline
์ถ๋ก ํ๋ฆ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Predictor:
def setup(self):
# ๋ชจ๋ธ ๋ก๋ฉ
self.tokenizer, self.model, self.image_processor, _ = load_pretrained_model(
model_path="liuhaotian/llava-v1.5-13b"
)
def predict(self, image, prompt, temperature=0.2, max_tokens=1024):
# 1) ์ด๋ฏธ์ง ์ ์ฒ๋ฆฌ
image_tensor = process_images([image], self.image_processor)
image_tensor = image_tensor.to(self.model.device, dtype=torch.float16)
# 2) Conversation ๊ตฌ์ฑ
conv = conv_templates["vicuna_v1"].copy()
inp = DEFAULT_IMAGE_TOKEN + "\n" + prompt # "<image>\n์ฌ์ฉ์ ์ง๋ฌธ"
conv.append_message(conv.roles[0], inp) # Human
conv.append_message(conv.roles[1], None) # Assistant (์์ฑ ๋์)
# 3) Tokenization
input_ids = tokenizer_image_token(
conv.get_prompt(),
self.tokenizer,
IMAGE_TOKEN_INDEX,
return_tensors='pt'
).to(self.model.device)
# 4) ์์ฑ
with torch.inference_mode():
output = self.model.generate(
inputs=input_ids,
images=image_tensor,
temperature=temperature,
max_new_tokens=max_tokens
)
return self.tokenizer.decode(output[0])
์ถ๋ก ์ ์ ๋ ฅ ํํ
1
2
3
4
5
6
7
8
[System Message] <STOP>
Human: <image>
์ด ์ฌ์ง์ ์ค๋ช
ํด์ค <STOP>
Assistant:
โ
[์์คํ
ํ ํฐ๋ค] + [์ด๋ฏธ์ง 256ํ ํฐ] + [์ง๋ฌธ ํ ํฐ๋ค]
โ
LLM์ด ๋ค์ ํ ํฐ ์์ฑ ์์
-
์ฃผ์ ํน์ง ๋ฐ ํ์
7.1 Data-Centric Approach
- GPT-4 ํ์ฉ: Language-only ๋ชจ๋ธ๋ก vision-language ๋ฐ์ดํฐ ์์ฑ
- Symbolic Representation: Captions + Bounding boxes
- ๋ค์์ฑ ํ๋ณด: Conversation, Detailed description, Complex reasoning
- ํ์ฅ ๊ฐ๋ฅ์ฑ: ๋ ๋ง์ image-text ์์ ์ ์ฉ ๊ฐ๋ฅ
7.2 Simple yet Effective Architecture
- Frozen Components: Vision encoder, LLM ๊ณ ์
- Lightweight Connector: Linear projection (2-layer MLP)
- ๋น ๋ฅธ ํ์ต: 4~10์๊ฐ (8รA100)
- ํจ์จ์ฑ: Pre-training ๋จ๊ณ์์ alignment ๋ฌ์ฑ
7.3 Two-Stage Training Strategy
Stage 1 (Feature Alignment):
- 595K caption pairs
- Projection matrix๋ง ํ์ต
- Visual tokenizer ์ญํ
Stage 2 (Instruction Tuning):
- 158K instruction data
- LLM + projection ํ์ต
- Vision encoder frozen
7.4 Emergent Capabilities
Out-of-distribution Generalization:
- Elon Musk ์ธ์ (ํ์ต ๋ฐ์ดํฐ์ ์์์)
- Meme ์ดํด
- OCR ๋ฅ๋ ฅ (ํ์ต ๋ฐ์ดํฐ์ ๊ฑฐ์ ์์์)
Multi-turn Conversation:
- Context ์ ์ง
- Follow-up ์ง๋ฌธ ์ฒ๋ฆฌ
- Detailed explanations
-
Limitations ๋ฐ ํฅํ ๋ฐฉํฅ
ํ์ฌ ํ๊ณ
- Hallucination: ์ฌ์ค๊ณผ ๋ค๋ฅธ ์ถ๋ ฅ ์์ฑ
- ๊ณ ํด์๋ ์ด๋ฏธ์ง: ์ธ๋ฐํ ํ ์คํธ/๋ธ๋๋ ์ธ์ ์ด๋ ค์
- Complex Semantics: โBag of patchesโ ๋ฌธ์
- ์: ๋ธ๊ธฐ + ์๊ฑฐํธ โ ๋ธ๊ธฐ ๋ง ์๊ฑฐํธ (X)
- Multilingual: ๋ค๊ตญ์ด ์ง์ ์ ํ์
ํฅํ ์ฐ๊ตฌ ๋ฐฉํฅ
-
๋ ์ ๊ตํ Connector:
- Gated cross-attention
- Q-former
- Multi-scale features
-
๊ณ ํด์๋ ์ฒ๋ฆฌ:
- Patch-based processing
- Adaptive resolution
-
๋ ํฐ ๋ฐ์ดํฐ์ :
- Diverse domains
- More languages
- Complex reasoning
-
Model Scaling:
- 65B+ LLM variants
- Larger vision encoders
-
์ฌํ์ ์ํฅ (Broader Impact)
Risks
Malicious Input:
- OpenAI Filter API๋ก ์ ํด ํ ์คํธ ์ฐจ๋จ
- NSFW Filter๋ก ๋ถ์ ์ ํ ์ด๋ฏธ์ง ์ฐจ๋จ
Hallucination:
- ์๋ฃ ๋ฑ critical application์์ ์ฃผ์ ํ์
Biases:
- CLIP, LLaMA/Vicuna๋ก๋ถํฐ ํธํฅ ์ ์ด ๊ฐ๋ฅ
Energy Consumption:
- ํ์ฌ๋ ์์ ๋ฐ์ดํฐ์ ์ผ๋ก ํ์ต (595K)
- Scaling ์ ์๋์ง ์๋น ๊ณ ๋ ค ํ์
Benefits
Research Community:
- ๋ชจ๋ ์์ฐ ์คํ์์ค๋ก ๊ณต๊ฐ
- Reproducibility ํ๋ณด
- Community ๊ธฐ์ฌ ๊ฐ๋ฅ
Accessibility:
- ๋ค์ํ vision-language ํ์คํฌ ํตํฉ
- User-friendly interface
-
Conclusion
LLaVA๋ visual instruction tuning์ด๋ผ๋ ์๋ก์ด ํจ๋ฌ๋ค์์ ์ ์ํ์ต๋๋ค:
ํต์ฌ ๊ธฐ์ฌ:
- GPT-4 ๊ธฐ๋ฐ 158K multimodal instruction data ์์ฑ
- Simple yet effective 3-component architecture
- ScienceQA์์ 92.53% ๋ฌ์ฑ (SOTA)
- LLaVA-Bench: ์ต์ด์ multimodal instruction-following ๋ฒค์น๋งํฌ
์์:
- Language-only LLM โ Multimodal LMM ํ์ฅ ๊ฒฝ๋ก ์ ์
- Data-centric approach์ ํจ๊ณผ ์ ์ฆ
- End-to-end ํ์ต์ ๊ฐ๋ฅ์ฑ ์ฆ๋ช
์คํ์์ค:
- ๋ฐ์ดํฐ, ์ฝ๋, ๋ชจ๋ธ ๋ชจ๋ ๊ณต๊ฐ
- Community-driven improvement ๊ฐ๋ฅ
LLaVA๋ ๋ฉํฐ๋ชจ๋ฌ AI์ democratization์ ์ํ ์ค์ํ ๋ฐฉํฅ์ฑ์ ์ ์ํ ์ค์ํ ๋
ผ๋ฌธ์
๋๋ค.
์ฝ์ด์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค :)