Typhoon2 Qwen2vl 7b Vision Instruct
T
Typhoon2 Qwen2vl 7b Vision Instruct
由scb10x開發
Typhoon2-Vision 是一款支持泰語的視覺語言模型,能夠處理圖像和視頻輸入,特別針對基於圖像的應用進行了優化。
下載量 793
發布時間 : 12/10/2024
模型概述
基於 Qwen2-VL-7B-Instruct 構建的泰語視覺語言模型,支持圖像和文本的多模態交互,適用於泰語和英語環境下的視覺任務。
模型特點
泰語優化
特別針對泰語環境進行了優化,支持泰語和英語的多模態交互。
多模態處理
能夠同時處理圖像和文本輸入,支持複雜的視覺語言任務。
高性能
在多個基準測試中表現優異,尤其在泰語視覺任務上顯著優於同類模型。
模型能力
圖像分析
文本生成
多模態交互
泰語視覺任務處理
英語視覺任務處理
使用案例
圖像理解
圖像地點識別
識別圖像中的地點名稱和國家
能夠準確識別圖像中的地標和地理位置
圖像相似性分析
比較多張圖像的相似之處
能夠識別圖像間的共同特徵和差異
教育
泰語視覺問答
回答關於圖像內容的泰語問題
在泰語視覺問答任務中表現優異
🚀 Typhoon2-Vision
Typhoon2-qwen2vl-7b-vision-instruct 是一款泰國 🇹🇭 視覺語言模型,支持圖像和視頻輸入。雖然 Qwen2-VL 旨在處理圖像和視頻處理任務,但 Typhoon2-VL 專門針對基於圖像的應用進行了優化。
如需查看技術報告,請訪問我們的 arxiv。
🚀 快速開始
以下是一個代碼片段,展示如何使用 transformers
庫來使用該模型。
在運行代碼片段之前,你需要安裝以下依賴項:
pip install torch transformers accelerate pillow
如何開始使用模型
使用以下代碼開始使用該模型。
問題:ระบุชื่อสถานที่และประเทศของภาพนี้เป็นภาษาไทย
答案:พระบรมมหาราชวัง, กรุงเทพฯ, ประเทศไทย
from PIL import Image
import requests
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
model_name = "scb10x/typhoon2-qwen2vl-7b-vision-instruct"
model = Qwen2VLForConditionalGeneration.from_pretrained(
model_name, torch_dtype="auto", device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_name)
# Image
url = "https://cdn.pixabay.com/photo/2023/05/16/09/15/bangkok-7997046_1280.jpg"
image = Image.open(requests.get(url, stream=True).raw)
conversation = [
{
"role": "user",
"content": [
{
"type": "image",
},
{"type": "text", "text": "ระบุชื่อสถานที่และประเทศของภาพนี้เป็นภาษาไทย"},
],
}
]
# Preprocess the inputs
text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
inputs = processor(
text=[text_prompt], images=[image], padding=True, return_tensors="pt"
)
inputs = inputs.to("cuda")
output_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids = [
output_ids[len(input_ids) :]
for input_ids, output_ids in zip(inputs.input_ids, output_ids)
]
output_text = processor.batch_decode(
generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
)
print(output_text)
# ['พระบรมมหาราชวัง, กรุงเทพฯ, ประเทศไทย']
處理多張圖像
from PIL import Image
import requests
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
model_name = "scb10x/typhoon2-qwen2vl-7b-vision-instruct"
model = Qwen2VLForConditionalGeneration.from_pretrained(
model_name, torch_dtype="auto", device_map="auto"
)
processor = AutoProcessor.from_pretrained(model_name)
# Messages containing multiple images and a text query
conversation = [
{
"role": "user",
"content": [
{
"type": "image",
},
{
"type": "image",
},
{"type": "text", "text": "ระบุ 3 สิ่งที่คล้ายกันในสองภาพนี้"},
],
}
]
urls = [
"https://cdn.pixabay.com/photo/2023/05/16/09/15/bangkok-7997046_1280.jpg",
"https://cdn.pixabay.com/photo/2020/08/10/10/09/bangkok-5477405_1280.jpg",
]
images = [Image.open(requests.get(url, stream=True).raw) for url in urls]
# Preprocess the inputs
text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
inputs = processor(text=[text_prompt], images=images, padding=True, return_tensors="pt")
inputs = inputs.to("cuda")
# Inference
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
# ['1. ทั้งสองภาพแสดงสถาปัตยกรรมที่มีลักษณะคล้ายกัน\n2. ทั้งสองภาพมีสีสันที่สวยงาม\n3. ทั้งสองภาพมีทิวทัศน์ที่สวยงาม']
提示
為了平衡模型性能和計算成本,你可以通過向處理器傳遞參數來設置最小和最大像素數。
min_pixels = 128 * 28 * 28
max_pixels = 2560 * 28 * 28
processor = AutoProcessor.from_pretrained(
model_name, min_pixels=min_pixels, max_pixels=max_pixels
)
評估(圖像)
基準測試 | Llama-3.2-11B-Vision-Instruct | Qwen2-VL-7B-Instruct | Pathumma-llm-vision-1.0.0 | Typhoon2-qwen2vl-7b-vision-instruct |
---|---|---|---|---|
OCRBench Liu et al., 2024c | 72.84 / 51.10 | 72.31 / 57.90 | 32.74 / 25.87 | 64.38 / 49.60 |
MMBench (Dev) Liu et al., 2024b | 76.54 / - | 84.10 / - | 19.51 / - | 83.66 / - |
ChartQA Masry et al., 2022 | 13.41 / x | 47.45 / 45.00 | 64.20 / 57.83 | 75.71 / 72.56 |
TextVQA Singh et al., 2019 | 32.82 / x | 91.40 / 88.70 | 32.54 / 28.84 | 91.45 / 88.97 |
OCR (TH) OpenThaiGPT, 2024 | 64.41 / 35.58 | 56.47 / 55.34 | 6.38 / 2.88 | 64.24 / 63.11 |
M3Exam Images (TH) Zhang et al., 2023c | 25.46 / - | 32.17 / - | 29.01 / - | 33.67 / - |
GQA (TH) Hudson et al., 2019 | 31.33 / - | 34.55 / - | 10.20 / - | 50.25 / - |
MTVQ (TH) Tang et al., 2024b | 11.21 / 4.31 | 23.39 / 13.79 | 7.63 / 1.72 | 30.59 / 21.55 |
平均 | 37.67 / x | 54.26 / 53.85 | 25.61 / 23.67 | 62.77 / 59.02 |
注意:每個單元格中的第一個值代表 Rouge-L,第二個值(/
之後)代表 準確率,並進行了歸一化處理,使得 Rouge-L = 100%。
✨ 主要特性
- Typhoon2-qwen2vl-7b-vision-instruct 基於 Qwen2-VL-7B-Instruct 構建。
- 模型類型:基於 Qwen2 架構的 7B 指令僅解碼器模型,帶有視覺編碼器。
- 要求:
transformers
4.38.0 或更高版本。 - 主要語言:泰語 🇹🇭 和英語 🇬🇧
- 演示:https://vision.opentyphoon.ai/
- 許可證:Apache-2.0
📚 詳細文檔
預期用途與限制
該模型是一個指令模型,但仍在開發中。它包含了一定程度的防護機制,但在響應用戶提示時仍可能產生不準確、有偏差或其他令人反感的答案。我們建議開發者在其用例的背景下評估這些風險。
關注我們
https://twitter.com/opentyphoon
支持
https://discord.gg/us5gAYmrxw
引用
如果您發現 Typhoon2 對您的工作有用,請使用以下方式引用:
@misc{typhoon2,
title={Typhoon 2: A Family of Open Text and Multimodal Thai Large Language Models},
author={Kunat Pipatanakul and Potsawee Manakul and Natapong Nitarach and Warit Sirichotedumrong and Surapon Nonesung and Teetouch Jaknamon and Parinthapat Pengpun and Pittawat Taveekitworachai and Adisai Na-Thalang and Sittipong Sripaisarnmongkol and Krisanapong Jirayoot and Kasima Tharnpipitchai},
year={2024},
eprint={2412.13702},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2412.13702},
}
Clip Vit Large Patch14 336
基於Vision Transformer架構的大規模視覺語言預訓練模型,支持圖像與文本的跨模態理解
文本生成圖像
Transformers

C
openai
5.9M
241
Fashion Clip
MIT
FashionCLIP是基於CLIP開發的視覺語言模型,專門針對時尚領域進行微調,能夠生成通用產品表徵。
文本生成圖像
Transformers 英語

F
patrickjohncyh
3.8M
222
Gemma 3 1b It
Gemma 3是Google推出的輕量級先進開放模型系列,基於與Gemini模型相同的研究和技術構建。該模型是多模態模型,能夠處理文本和圖像輸入並生成文本輸出。
文本生成圖像
Transformers

G
google
2.1M
347
Blip Vqa Base
Bsd-3-clause
BLIP是一個統一的視覺語言預訓練框架,擅長視覺問答任務,通過語言-圖像聯合訓練實現多模態理解與生成能力
文本生成圖像
Transformers

B
Salesforce
1.9M
154
CLIP ViT H 14 Laion2b S32b B79k
MIT
基於OpenCLIP框架在LAION-2B英文數據集上訓練的視覺-語言模型,支持零樣本圖像分類和跨模態檢索任務
文本生成圖像
Safetensors
C
laion
1.8M
368
CLIP ViT B 32 Laion2b S34b B79k
MIT
基於OpenCLIP框架在LAION-2B英語子集上訓練的視覺-語言模型,支持零樣本圖像分類和跨模態檢索
文本生成圖像
Safetensors
C
laion
1.1M
112
Pickscore V1
PickScore v1 是一個針對文本生成圖像的評分函數,可用於預測人類偏好、評估模型性能和圖像排序等任務。
文本生成圖像
Transformers

P
yuvalkirstain
1.1M
44
Owlv2 Base Patch16 Ensemble
Apache-2.0
OWLv2是一種零樣本文本條件目標檢測模型,可通過文本查詢在圖像中定位對象。
文本生成圖像
Transformers

O
google
932.80k
99
Llama 3.2 11B Vision Instruct
Llama 3.2 是 Meta 發佈的多語言多模態大型語言模型,支持圖像文本到文本的轉換任務,具備強大的跨模態理解能力。
文本生成圖像
Transformers 支持多種語言

L
meta-llama
784.19k
1,424
Owlvit Base Patch32
Apache-2.0
OWL-ViT是一個零樣本文本條件目標檢測模型,可以通過文本查詢搜索圖像中的對象,無需特定類別的訓練數據。
文本生成圖像
Transformers

O
google
764.95k
129
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98