🚀 VARCO-VISION-14B-HF
VARCO-VISION-14B-HF 是一款強大的英韓語視覺語言模型(VLM)。它能接受單張圖像和文本作為輸入,並生成文本輸出,支持定位、指稱以及OCR(光學字符識別)等功能。
🚀 快速開始
要使用此模型,需確保安裝了 transformers >= 4.45.0
。
import torch
import requests
from PIL import Image
from transformers import LlavaOnevisionForConditionalGeneration, AutoProcessor
model_name = "NCSOFT/VARCO-VISION-14B-HF"
model = LlavaOnevisionForConditionalGeneration.from_pretrained(
model_name,
torch_dtype="float16",
device_map="auto",
attn_implementation="flash_attention_2"
)
processor = AutoProcessor.from_pretrained(model_name)
device = model.device
conversation = [
{
"role": "user",
"content": [
{"type": "text", "text": "Describe this image."},
{"type": "image"},
],
},
]
prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
EOS_TOKEN = "<|im_end|>"
image_file = "http://images.cocodataset.org/val2017/000000039769.jpg"
raw_image = Image.open(requests.get(image_file, stream=True).raw)
inputs = processor(images=raw_image, text=prompt, return_tensors='pt').to(device, torch.float16)
output = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
output = processor.decode(output[0][inputs.input_ids.shape[1]:])
if output.endswith(EOS_TOKEN):
output = output[: -len(EOS_TOKEN)]
output = output.strip()
print(output)
✨ 主要特性
- 強大性能:在多模態和純文本基準測試中,VARCO-VISION-14B不僅在性能上超越了其他類似規模的模型,還取得了與專有模型相當的分數。
- 多階段訓練:VARCO-VISION的訓練管道包括四個階段:特徵對齊預訓練、基礎監督微調、高級監督微調以及偏好優化。
- 支持多任務:支持定位、指稱以及OCR(光學字符識別)等功能。
📚 詳細文檔
模型信息
特殊功能
如果問題基於邊界框或需要以邊界框作為輸出,請在輸入文本中包含特殊標記。以下特殊標記用於為模型定義特定任務、輸入和輸出:
<gro>
:表示模型的響應應包含邊界框信息。
<ocr>
:指定用於識別圖像中文字的OCR任務。
<char>
和 </char>
:用於標記文本短語。
<obj>
和 </obj>
:用於表示對象。
<bbox>
和 </bbox>
:用於表示邊界框。
<delim>
:表示單個對象或文本的多個位置點。
定位(Grounding)
定位是指模型需要在圖像中識別特定位置以提供合適答案的任務。要執行定位任務,請在問題前加上特殊標記 <gro>
。
conversation = [
{
"role": "user",
"content": [
{"type": "text", "text": "<gro>\nDescribe the image in detail."},
{"type": "image"},
],
},
]
預期輸出示例:
The image shows <obj>two cats</obj><bbox>0.014, 0.106, 0.51, 0.996<delim>0.51, 0.054, 0.996, 0.787</bbox> lying on <obj>a pink blanket</obj><bbox>0.003, 0.231, 0.999, 0.999</bbox>. The cat on the left is lying on its side with its head resting on the blanket, while the cat on the right is lying on its stomach with its head also resting on the blanket. Both cats appear to be relaxed and comfortable. There are <obj>two remote controls</obj><bbox>0.037, 0.141, 0.283, 0.253<delim>0.506, 0.171, 0.581, 0.295</bbox> placed near the cats, one on the left side and one on the right side of the image.

指稱(Referring)
VARCO-VISION-14B可以使用邊界框處理特定位置的問題。要執行指稱任務,請在對話中使用 <obj>
和 </obj>
標籤包含感興趣的對象,並使用 <bbox>
和 </bbox>
標籤指定其位置。這使模型能夠理解上下文並專注於指定位置的對象。邊界框以 (x1, y1, x2, y2) 的形式表示。前兩個值表示邊界框的左上角位置,後兩個值是右下角位置。
conversation = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "<obj>이 물건</obj><bbox>0.039, 0.138, 0.283, 0.257</bbox>은 어떻게 쓰는거야?",
},
{"type": "image"},
],
},
]
預期輸出示例:
**이 물건**은 리모컨으로, 주로 텔레비전이나 다른 전자 기기를 원격으로 조작하는 데 사용됩니다. 리모컨에는 다양한 버튼이 있으며, 각 버튼은 채널 변경, 볼륨 조절, 전원 켜기/끄기 등의 기능을 수행합니다. 사용자는 리모컨을 손에 들고 버튼을 누르면, 해당 기기에 신호를 보내 원하는 조작을 할 수 있습니다. 리모컨은 일반적으로 가정이나 사무실에서 편리하게 전자 기기를 조작할 수 있도록 사용됩니다.
OCR
要執行光學字符識別(OCR),請使用 <ocr>
標記。
image_file = "./assets/ocr_1.png"
raw_image = Image.open(image_file)
conversation = [
{
"role": "user",
"content": [
{"type": "text", "text": "<ocr>"},
{"type": "image"},
],
},
]
預期輸出示例:
<char>백범로</char><bbox>0.172, 0.266, 0.328, 0.341</bbox>
<char>124번길</char><bbox>0.347, 0.266, 0.512, 0.341</bbox>
<char>Baekbeom-ro</char><bbox>0.171, 0.337, 0.433, 0.392</bbox>
<char>124</char><bbox>0.444, 0.341, 0.508, 0.392</bbox>
<char>만수주공아파트</char><bbox>0.109, 0.531, 0.335, 0.601</bbox>
<char>시흥</char><bbox>0.443, 0.518, 0.522, 0.581</bbox>
<char>시청</char><bbox>0.711, 0.521, 0.811, 0.594</bbox>
<char>Mansu</char><bbox>0.102, 0.601, 0.181, 0.648</bbox>
<char>Jugong</char><bbox>0.186, 0.601, 0.273, 0.658</bbox>
<char>Apt</char><bbox>0.28, 0.601, 0.327, 0.651</bbox>
<char>42</char><bbox>0.377, 0.601, 0.416, 0.648</bbox>
<char>Shieung</char><bbox>0.445, 0.578, 0.53, 0.625</bbox>
<char>인천대공원</char><bbox>0.43, 0.621, 0.609, 0.684</bbox>
<char>모래내시장역</char><bbox>0.651, 0.59, 0.873, 0.665</bbox>
<char>IncheonGrand</char><bbox>0.432, 0.681, 0.561, 0.723</bbox>
<char>Park</char><bbox>0.564, 0.681, 0.611, 0.723</bbox>

📄 許可證
本模型採用CC BY-NC 4.0許可證,僅用於研究目的,禁止商業使用。
🔧 技術細節
VARCO-VISION的訓練管道包括四個階段:特徵對齊預訓練、基礎監督微調、高級監督微調以及偏好優化。
📚 引用模型
如果您在研究中使用了VARCO-VISION-14B,請引用以下內容:
@misc{ju2024varcovisionexpandingfrontierskorean,
title={VARCO-VISION: Expanding Frontiers in Korean Vision-Language Models},
author={Jeongho Ju and Daeyoung Kim and SunYoung Park and Youngjune Kim},
year={2024},
eprint={2411.19103},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2411.19103},