Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐ŸŒ [i18n-KO] Translated model_doc/paligemma.md to Korean #33612

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/ko/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@
title: (๋ฒˆ์—ญ์ค‘) OneFormer
- local: in_translation
title: (๋ฒˆ์—ญ์ค‘) OWL-ViT
- local: model_doc/paligemma
title: PaliGemma
- local: in_translation
title: (๋ฒˆ์—ญ์ค‘) Perceiver
- local: in_translation
Expand Down
80 changes: 80 additions & 0 deletions docs/source/ko/model_doc/paligemma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--Copyright 2024 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

โš ๏ธ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->

# PaliGemma[[paligemma]]

## ์˜ค๋ฒ„๋ทฐ[[overview]]

PaliGemma ๋ชจ๋ธ์€ ๊ตฌ๊ธ€์ด ์ œ์•ˆํ•œ [PaliGemma โ€“ Google์˜ ์ตœ์ฒจ๋‹จ ์˜คํ”ˆ ๋น„์ „ ์–ธ์–ด ๋ชจ๋ธ](https://huggingface.co/blog/paligemma)๋กœ ์†Œ๊ฐœ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. PaliGemma๋Š” [SigLIP](siglip) ๋น„์ „ ์ธ์ฝ”๋”์™€ [Gemma](gemma) ์–ธ์–ด ์ธ์ฝ”๋”๋กœ ๊ตฌ์„ฑ๋œ 3B ๊ทœ๋ชจ์˜ ๋น„์ „-์–ธ์–ด ๋ชจ๋ธ๋กœ, ๋‘ ์ธ์ฝ”๋”๊ฐ€ ๋ฉ€ํ‹ฐ๋ชจ๋‹ฌ ์„ ํ˜• ๋‘์˜์œผ๋กœ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ชจ๋ธ์€ ์ด๋ฏธ์ง€๋ฅผ ๊ณ ์ •๋œ ์ˆ˜์˜ VITํ† ํฐ์œผ๋กœ ๋ถ„ํ• ํ•˜๊ณ  ์ด๋ฅผ ์„ ํƒ์  ํ”„๋กฌํ”„ํŠธ ์•ž์— ์ถ”๊ฐ€ ํ•˜๋ฉฐ, ๋ชจ๋“  ์ด๋ฏธ์ง€ ํ† ํฐ๊ณผ ์ž…๋ ฅ ํ…์ŠคํŠธ ํ† ํฐ์— ๋Œ€ํ•ด ์ „์ฒด ๋ธ”๋ก ์–ดํ…์…˜์„ ์‚ฌ์šฉํ•˜๋Š” ํŠน์ง•์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

PaliGemma๋Š” 224x224, 448x448, 896x896์˜ 3๊ฐ€์ง€ ํ•ด์ƒ๋„๋กœ ์ œ๊ณต๋˜๋ฉฐ, 3๊ฐœ์˜ ๊ธฐ๋ณธ ๋ชจ๋ธ๊ณผ 55๊ฐœ์˜ ๋‹ค์–‘ํ•œ ์ž‘์—…์— ๋Œ€ํ•ด ๋ฏธ์„ธ ์กฐ์ •๋œ ๋ฒ„์ „, ๊ทธ๋ฆฌ๊ณ  2๊ฐœ์˜ ํ˜ผํ•ฉ ๋ชจ๋ธ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/paligemma/paligemma_arch.png"
alt="drawing" width="600"/>

<small> PaliGemma ์•„ํ‚คํ…์ฒ˜ <a href="https://huggingface.co/blog/paligemma">๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ.</a> </small>

์ด ๋ชจ๋ธ์€ [Molbap](https://huggingface.co/Molbap)์— ์˜ํ•ด ๊ธฐ์—ฌ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

## ์‚ฌ์šฉํŒ[[usage-tips]]

PaliGemma์˜ ์ถ”๋ก ์€ ๋‹ค์Œ์ฒ˜๋Ÿผ ์ˆ˜ํ–‰๋ฉ๋‹ˆ๋‹ค:

```python
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`๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

```python
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์˜ ๋ชจ๋“  ๊ธฐ๋Šฅ์„ ์†Œ๊ฐœํ•˜๋Š” ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ๋Š” [์ด๊ณณ](https://huggingface.co/blog/paligemma)์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๐ŸŒŽ
- Trainer API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ VQA(Visual Question Answering)๋ฅผ ์œ„ํ•ด PaliGemma๋ฅผ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ถ”๋ก ์— ๋Œ€ํ•œ ๋ฐ๋ชจ ๋…ธํŠธ๋ถ์€ [์ด๊ณณ](https://github.com/huggingface/notebooks/tree/main/examples/paligemma)์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๐ŸŒŽ
- ์‚ฌ์šฉ์ž ์ •์˜ ๋ฐ์ดํ„ฐ์…‹(์˜์ˆ˜์ฆ ์ด๋ฏธ์ง€ -> JSON)์— ๋Œ€ํ•ด PaliGemma๋ฅผ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ถ”๋ก ์— ๋Œ€ํ•œ ๋ฐ๋ชจ ๋…ธํŠธ๋ถ์€ [์ด๊ณณ](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/PaliGemma)์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๐ŸŒŽ

## PaliGemmaConfig[[transformers.PaliGemmaConfig]]

[[autodoc]] PaliGemmaConfig

## PaliGemmaProcessor[[transformers.PaliGemmaProcessor]]

[[autodoc]] PaliGemmaProcessor

## PaliGemmaForConditionalGeneration[[transformers.PaliGemmaForConditionalGeneration]]

[[autodoc]] PaliGemmaForConditionalGeneration
- forward