PaliGemma[[paligemma]]
๊ฐ์[[overview]]
PaliGemma ๋ชจ๋ธ์ ๊ตฌ๊ธ์ด ์ ์ํ PaliGemma โ Google์ ์ต์ฒจ๋จ ์คํ ๋น์ ์ธ์ด ๋ชจ๋ธ์์ ์๊ฐ ๋์์ต๋๋ค. PaliGemma๋ SigLIP ๋น์ ์ธ์ฝ๋์ Gemma ์ธ์ด ์ธ์ฝ๋๋ก ๊ตฌ์ฑ๋ 3B ๊ท๋ชจ์ ๋น์ -์ธ์ด ๋ชจ๋ธ๋ก, ๋ ์ธ์ฝ๋๊ฐ ๋ฉํฐ๋ชจ๋ฌ ์ ํ ํ๋ก์ ์ ์ผ๋ก ์ฐ๊ฒฐ๋์ด ์์ต๋๋ค. ์ด ๋ชจ๋ธ์ ์ด๋ฏธ์ง๋ฅผ ๊ณ ์ ๋ ์์ VITํ ํฐ์ผ๋ก ๋ถํ ํ๊ณ ์ด๋ฅผ ์ ํ์ ํ๋กฌํํธ ์์ ์ถ๊ฐ ํ๋ฉฐ, ๋ชจ๋ ์ด๋ฏธ์ง ํ ํฐ๊ณผ ์ ๋ ฅ ํ ์คํธ ํ ํฐ์ ๋ํด ์ ์ฒด ๋ธ๋ก ์ดํ ์ ์ ์ฌ์ฉํ๋ ํน์ง์ ๊ฐ์ง๊ณ ์์ต๋๋ค.
PaliGemma๋ 224x224, 448x448, 896x896์ 3๊ฐ์ง ํด์๋๋ก ์ ๊ณต๋๋ฉฐ, 3๊ฐ์ ๊ธฐ๋ณธ ๋ชจ๋ธ๊ณผ 55๊ฐ์ ๋ค์ํ ์์ ์ ๋ํด ๋ฏธ์ธ ์กฐ์ ๋ ๋ฒ์ , ๊ทธ๋ฆฌ๊ณ 2๊ฐ์ ํผํฉ ๋ชจ๋ธ์ด ์์ต๋๋ค.

PaliGemma ์ํคํ ์ฒ ๋ธ๋ก๊ทธ ํฌ์คํธ.
์ด ๋ชจ๋ธ์ Molbap์ ์ํด ๊ธฐ์ฌ ๋์์ต๋๋ค.
์ฌ์ฉ ํ[[usage-tips]]
PaliGemma์ ์ถ๋ก ์ ๋ค์์ฒ๋ผ ์ํ๋ฉ๋๋ค:
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
model_id = "google/paligemma-3b-mix-224"
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id)
processor = AutoProcessor.from_pretrained(model_id)
prompt = "What is on the flower?"
image_file = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg?download=true"
raw_image = Image.open(requests.get(image_file, stream=True).raw)
inputs = processor(raw_image, prompt, return_tensors="pt")
output = model.generate(**inputs, max_new_tokens=20)
print(processor.decode(output[0], skip_special_tokens=True)[len(prompt):])
- PaliGemma๋ ๋ํ์ฉ์ผ๋ก ์ค๊ณ๋์ง ์์์ผ๋ฉฐ, ํน์ ์ฌ์ฉ ์ฌ๋ก์ ๋ํด ๋ฏธ์ธ ์กฐ์ ํ ๋ ๊ฐ์ฅ ์ ์๋ํฉ๋๋ค. PaliGemma๋ฅผ ๋ฏธ์ธ ์กฐ์ ํ ์ ์๋ ๋ช ๊ฐ์ง ํ์ ์์ ์๋ ์ด๋ฏธ์ง ์บก์ ๋, ์๊ฐ์ ์ง๋ฌธ ๋ต๋ณ(VQA), ์ค๋ธ์ ํธ ๋ํ ์ , ์ฐธ์กฐ ํํ ๋ถํ ๋ฐ ๋ฌธ์ ์ดํด๊ฐ ํฌํจ๋ฉ๋๋ค.
- ๋ชจ๋ธ์ ํ์ํ ์ด๋ฏธ์ง, ํ
์คํธ ๋ฐ ์ ํ์ ๋ ์ด๋ธ์ ์ค๋นํ๋๋ฐ
PaliGemmaProcessor๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. PaliGemma ๋ชจ๋ธ์ ๋ฏธ์ธ ์กฐ์ ํ ๋๋, ํ๋ก์ธ์์suffix์ธ์๋ฅผ ์ ๋ฌํ์ฌ ๋ค์ ์ฒ๋ผ ๋ชจ๋ธ์labels๋ฅผ ์์ฑํ ์ ์์ต๋๋ค:
prompt = "What is on the flower?"
answer = "a bee"
inputs = processor(images=raw_image, text=prompt, suffix=answer, return_tensors="pt")
์๋ฃ[[resources]]
PaliGemma๋ฅผ ์์ํ๋ ๋ฐ ๋์์ด ๋๋ Hugging Face์ community ์๋ฃ ๋ชฉ๋ก(๐๋ก ํ์๋จ) ์ ๋๋ค.์ฌ๊ธฐ์ ํฌํจ๋ ์๋ฃ๋ฅผ ์ ์ถํ๊ณ ์ถ์ผ์๋ค๋ฉด PR(Pull Request)๋ฅผ ์ด์ด์ฃผ์ธ์. ๋ฆฌ๋ทฐ ํด๋๋ฆฌ๊ฒ ์ต๋๋ค! ์๋ฃ๋ ๊ธฐ์กด ์๋ฃ๋ฅผ ๋ณต์ ํ๋ ๋์ ์๋ก์ด ๋ด์ฉ์ ๋ด๊ณ ์์ด์ผ ํฉ๋๋ค.
- PaliGemma์ ๋ชจ๋ ๊ธฐ๋ฅ์ ์๊ฐํ๋ ๋ธ๋ก๊ทธ ํฌ์คํธ๋ ์ด๊ณณ์์ ์ฐพ์ ์ ์์ต๋๋ค. ๐
- Trainer API๋ฅผ ์ฌ์ฉํ์ฌ VQA(Visual Question Answering)๋ฅผ ์ํด PaliGemma๋ฅผ ๋ฏธ์ธ ์กฐ์ ํ๋ ๋ฐฉ๋ฒ๊ณผ ์ถ๋ก ์ ๋ํ ๋ฐ๋ชจ ๋ ธํธ๋ถ์ ์ด๊ณณ์์ ์ฐพ์ ์ ์์ต๋๋ค. ๐
- ์ฌ์ฉ์ ์ ์ ๋ฐ์ดํฐ์ (์์์ฆ ์ด๋ฏธ์ง -> JSON)์ ๋ํด PaliGemma๋ฅผ ๋ฏธ์ธ ์กฐ์ ํ๋ ๋ฐฉ๋ฒ๊ณผ ์ถ๋ก ์ ๋ํ ๋ฐ๋ชจ ๋ ธํธ๋ถ์ ์ด๊ณณ์์ ์ฐพ์ ์ ์์ต๋๋ค. ๐
PaliGemmaConfig[[transformers.PaliGemmaConfig]]
[[autodoc]] PaliGemmaConfig
PaliGemmaProcessor[[transformers.PaliGemmaProcessor]]
[[autodoc]] PaliGemmaProcessor
PaliGemmaForConditionalGeneration[[transformers.PaliGemmaForConditionalGeneration]]
[[autodoc]] PaliGemmaForConditionalGeneration - forward