| <!--Copyright 2023 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. | |
| --> | |
| # BLIP-2[[blip-2]] | |
| ## ๊ฐ์[[overview]] | |
| BLIP-2 ๋ชจ๋ธ์ Junnan Li, Dongxu Li, Silvio Savarese, Steven Hoi์ [BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models](https://huggingface.co/papers/2301.12597) ๋ ผ๋ฌธ์์ ์ ์๋์์ต๋๋ค. BLIP-2๋ ๋๊ฒฐ๋ ์ฌ์ ํ์ต ์ด๋ฏธ์ง ์ธ์ฝ๋์ ๋๊ท๋ชจ ์ธ์ด ๋ชจ๋ธ(LLM)์ ์ฐ๊ฒฐํ๋ 12์ธต์ ๊ฒฝ๋ Transformer ์ธ์ฝ๋๋ฅผ ํ์ต์์ผ, ์ฌ๋ฌ ๋น์ -์ธ์ด ์์ ์์ SOTA(ํ์ฌ ์ต๊ณ ์ ์ฑ๋ฅ)์ ๋ฌ์ฑํ์ต๋๋ค. ํนํ, BLIP-2๋ 800์ต ๊ฐ์ ํ๋ผ๋ฏธํฐ๋ฅผ ๊ฐ์ง Flamingo ๋ชจ๋ธ๋ณด๋ค ์ ๋ก์ท VQAv2์์ 8.7% ๋ ๋์ ์ฑ๋ฅ์ ๊ธฐ๋กํ์ผ๋ฉฐ, ํ์ต ๊ฐ๋ฅํ ํ๋ผ๋ฏธํฐ ์๋ Flamingo๋ณด๋ค 54๋ฐฐ ์ ์ต๋๋ค. | |
| ๋ ผ๋ฌธ์ ์ด๋ก์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: | |
| *๋น์ -์ธ์ด ์ฌ์ ํ์ต์ ๋น์ฉ์ ๋๊ท๋ชจ ๋ชจ๋ธ์ ์๋-ํฌ-์๋ ํ์ต์ผ๋ก ์ธํด ์ ์ ๋ ๋ถ๋ด์ค๋ฌ์์ง๊ณ ์์ต๋๋ค. ๋ณธ ๋ ผ๋ฌธ์ ์ฌ์ ํ์ต๋ ์ด๋ฏธ์ง ์ธ์ฝ๋์ ๋๊ท๋ชจ ์ธ์ด ๋ชจ๋ธ์ ํ์ฉํ์ฌ ๋น์ -์ธ์ด ์ฌ์ ํ์ต์ ๋ถํธ์คํธ๋ํํ๋ ์ผ๋ฐ์ ์ด๊ณ ํจ์จ์ ์ธ ์ฌ์ ํ์ต ์ ๋ต์ธ BLIP-2๋ฅผ ์ ์ํฉ๋๋ค. BLIP-2๋ ๊ฒฝ๋ํ๋ Querying Transformer๋ฅผ ํตํด ๋ชจ๋ฌ๋ฆฌํฐ ๊ฐ์ ์ฐจ์ด๋ฅผ ์ฐ๊ฒฐํ๋ฉฐ, ๋ ๋จ๊ณ๋ก ์ฌ์ ํ์ต๋ฉ๋๋ค. ์ฒซ ๋ฒ์งธ ๋จ๊ณ๋ ๋๊ฒฐ๋ ์ด๋ฏธ์ง ์ธ์ฝ๋๋ก๋ถํฐ ๋น์ -์ธ์ด ํํ ํ์ต์ ๋ถํธ์คํธ๋ํํ๊ณ , ๋ ๋ฒ์งธ ๋จ๊ณ๋ ๋๊ฒฐ๋ ์ธ์ด ๋ชจ๋ธ๋ก๋ถํฐ ๋น์ -์ธ์ด ์์ฑ ํ์ต์ ๋ถํธ์คํธ๋ํํฉ๋๋ค. BLIP-2๋ ๊ธฐ์กด ๋ฐฉ๋ฒ๋ค์ ๋นํด ํจ์ฌ ์ ์ ํ์ต ๊ฐ๋ฅํ ํ๋ผ๋ฏธํฐ๋ก ๋ค์ํ ๋น์ -์ธ์ด ์์ ์์ ์ต์ฒจ๋จ ์ฑ๋ฅ์ ๋ฌ์ฑํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ์ฐ๋ฆฌ ๋ชจ๋ธ์ ์ ๋ก์ท VQAv2์์ Flamingo80B๋ณด๋ค 8.7% ๋์ ์ฑ๋ฅ์ ๊ธฐ๋กํ๋ฉฐ, ํ์ต ๊ฐ๋ฅํ ํ๋ผ๋ฏธํฐ ์๋ 54๋ฐฐ ์ ์ต๋๋ค. ์ฐ๋ฆฌ๋ ๋ํ ์์ฐ์ด ๋ช ๋ น์ ๋ฐ๋ฅผ ์ ์๋ ์ ๋ก์ท ์ด๋ฏธ์ง-ํ ์คํธ ์์ฑ์ ์๋ก์ด ๊ธฐ๋ฅ์ ์ ์ฆํ์ต๋๋ค.* | |
| <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/blip2_architecture.jpg" | |
| alt="drawing" width="600"/> | |
| <small> BLIP-2 ๊ตฌ์กฐ. <a href="https://huggingface.co/papers/2301.12597">์๋ณธ ๋ ผ๋ฌธ</a> ์์ ๋ฐ์ท. </small> | |
| ์ด ๋ชจ๋ธ์ [nielsr](https://huggingface.co/nielsr)๊ฐ ๊ธฐ์ฌํ์ต๋๋ค. ์๋ณธ ์ฝ๋๋ [์ฌ๊ธฐ](https://github.com/salesforce/LAVIS/tree/5ee63d688ba4cebff63acee04adaef2dee9af207)์์ ํ์ธํ ์ ์์ต๋๋ค. | |
| ## ์ฌ์ฉ ํ[[usage-tips]] | |
| - BLIP-2๋ ์ด๋ฏธ์ง์ ์กฐ๊ฑด์ ๋ฐ๋ผ ํ ์คํธ ํ๋กฌํํธ๋ฅผ ์ ๋ ฅ๋ฐ์ ์กฐ๊ฑด๋ถ ํ ์คํธ๋ฅผ ์์ฑํฉ๋๋ค. ์ถ๋ก ์ [`generate`] ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค. | |
| - [`Blip2Processor`]๋ฅผ ์ฌ์ฉํ์ฌ ๋ชจ๋ธ์ ์ด๋ฏธ์ง๋ฅผ ์ค๋นํ๊ณ , ์์ธก๋ ํ ํฐ ID๋ฅผ ํ ์คํธ๋ก ๋์ฝ๋ฉํ ์ ์์ต๋๋ค. | |
| ## ์๋ฃ[[resources]] | |
| BLIP-2๋ฅผ ์์ํ๋ ๋ฐ ๋์์ด ๋๋ ๊ณต์ Hugging Face ๋ฐ ์ปค๋ฎค๋ํฐ(๐ ํ์) ์๋ฃ ๋ชฉ๋ก์ ๋๋ค. | |
| - ์ด๋ฏธ์ง ์บก์ ๋, ์๊ฐ ์ง๋ฌธ ์๋ต(VQA), ์ฑํ ๊ณผ ๊ฐ์ ๋ํํ ์์ ์ ์ํ BLIP-2 ๋ฐ๋ชจ ๋ ธํธ๋ถ์ [์ฌ๊ธฐ](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/BLIP-2)์์ ์ฐพ์ ์ ์์ต๋๋ค. | |
| ๋ฆฌ์์ค๋ฅผ ์ ์ถํ์ฌ ์ฌ๊ธฐ์ ํฌํจํ๊ณ ์ถ๋ค๋ฉด ์ธ์ ๋ ์ง ํ ๋ฆฌํ์คํธ๋ฅผ ์ด์ด์ฃผ์ธ์! ๋ฆฌ์์ค๋ ๊ธฐ์กด ๋ฆฌ์์ค๋ฅผ ๋ณต์ ํ์ง ์๊ณ ์๋ก์ด ๋ด์ฉ์ด์ด์ผ ํฉ๋๋ค. | |
| ## Blip2Config[[transformers.Blip2Config]] | |
| [[autodoc]] Blip2Config | |
| - from_vision_qformer_text_configs | |
| ## Blip2VisionConfig[[transformers.Blip2VisionConfig]] | |
| [[autodoc]] Blip2VisionConfig | |
| ## Blip2QFormerConfig[[transformers.Blip2QFormerConfig]] | |
| [[autodoc]] Blip2QFormerConfig | |
| ## Blip2Processor[[transformers.Blip2Processor]] | |
| [[autodoc]] Blip2Processor | |
| ## Blip2VisionModel[[transformers.Blip2VisionModel]] | |
| [[autodoc]] Blip2VisionModel | |
| - forward | |
| ## Blip2QFormerModel[[transformers.Blip2QFormerModel]] | |
| [[autodoc]] Blip2QFormerModel | |
| - forward | |
| ## Blip2Model[[transformers.Blip2Model]] | |
| [[autodoc]] Blip2Model | |
| - forward | |
| - get_text_features | |
| - get_image_features | |
| - get_qformer_features | |
| ## Blip2ForConditionalGeneration[[transformers.Blip2ForConditionalGeneration]] | |
| [[autodoc]] Blip2ForConditionalGeneration | |
| - forward | |
| - generate | |
| ## Blip2ForImageTextRetrieval[[transformers.Blip2ForImageTextRetrieval]] | |
| [[autodoc]] Blip2ForImageTextRetrieval | |
| - forward | |
| ## Blip2TextModelWithProjection[[transformers.Blip2TextModelWithProjection]] | |
| [[autodoc]] Blip2TextModelWithProjection | |
| ## Blip2VisionModelWithProjection[[transformers.Blip2VisionModelWithProjection]] | |
| [[autodoc]] Blip2VisionModelWithProjection | |