Nanollava 1.5
nanoLLaVA-1.5是一款参数规模在10亿以下的视觉语言模型,专为边缘设备设计,小巧但功能强大。
下载量 442
发布时间 : 6/29/2024
模型简介
nanoLLaVA-1.5是对v1.0版本的升级,是一款高效的视觉语言模型,适用于图像文本到文本的任务。
模型特点
小巧但强大
专为边缘设备设计,参数规模在10亿以下,但功能强大。
多模态支持
支持视觉和语言的多模态任务处理。
高效推理
优化后的模型在边缘设备上也能高效运行。
模型能力
图像描述生成
视觉问答
多模态推理
使用案例
视觉问答
图像内容描述
根据图像生成详细的文字描述。
教育
科学问题解答
基于图像的科学问题解答。
🚀 纳米语言视觉模型 nanoLLaVA-1.5 - 改进的 10 亿参数以下视觉语言模型
纳米语言视觉模型 nanoLLaVA-1.5 是一款专为边缘设备高效运行而设计的“小而强大”的 10 亿参数视觉语言模型。它是 v1.0 版本 qnguyen3/nanoLLaVA 的升级版。
🚀 快速开始
你可以使用 transformers
库,通过以下脚本使用该模型:
pip install -U transformers accelerate flash_attn
import torch
import transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
from PIL import Image
import warnings
# disable some warnings
transformers.logging.set_verbosity_error()
transformers.logging.disable_progress_bar()
warnings.filterwarnings('ignore')
# set device
torch.set_default_device('cuda') # or 'cpu'
model_name = 'qnguyen3/nanoLLaVA-1.5'
# create model
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map='auto',
trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(
model_name,
trust_remote_code=True)
# text prompt
prompt = 'Describe this image in detail'
messages = [
{"role": "user", "content": f'<image>\n{prompt}'}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
print(text)
text_chunks = [tokenizer(chunk).input_ids for chunk in text.split('<image>')]
input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1], dtype=torch.long).unsqueeze(0)
# image, sample images can be found in images folder
image = Image.open('/path/to/image.png')
image_tensor = model.process_images([image], model.config).to(dtype=model.dtype)
# generate
output_ids = model.generate(
input_ids,
images=image_tensor,
max_new_tokens=2048,
use_cache=True)[0]
print(tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip())
✨ 主要特性
- 高效运行:专为边缘设备设计,能够在资源有限的设备上高效运行。
- 模型升级:是 v1.0 版本的升级版,性能可能更优。
📦 安装指南
使用以下命令安装所需的库:
pip install -U transformers accelerate flash_attn
💻 使用示例
基础用法
import torch
import transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
from PIL import Image
import warnings
# disable some warnings
transformers.logging.set_verbosity_error()
transformers.logging.disable_progress_bar()
warnings.filterwarnings('ignore')
# set device
torch.set_default_device('cuda') # or 'cpu'
model_name = 'qnguyen3/nanoLLaVA-1.5'
# create model
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map='auto',
trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(
model_name,
trust_remote_code=True)
# text prompt
prompt = 'Describe this image in detail'
messages = [
{"role": "user", "content": f'<image>\n{prompt}'}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
print(text)
text_chunks = [tokenizer(chunk).input_ids for chunk in text.split('<image>')]
input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1], dtype=torch.long).unsqueeze(0)
# image, sample images can be found in images folder
image = Image.open('/path/to/image.png')
image_tensor = model.process_images([image], model.config).to(dtype=model.dtype)
# generate
output_ids = model.generate(
input_ids,
images=image_tensor,
max_new_tokens=2048,
use_cache=True)[0]
print(tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip())
📚 详细文档
模型信息
属性 | 详情 |
---|---|
基础大语言模型 | Quyen-SE-v0.1 (Qwen1.5 - 0.5B) |
视觉编码器 | google/siglip-so400m-patch14-384 |
模型性能
模型 | VQA v2 | TextVQA | ScienceQA | POPE | MMMU (测试集) | MMMU (评估集) | GQA | MM-VET |
---|---|---|---|---|---|---|---|---|
nanoLLavA-1.0 | 70.84 | 46.71 | 58.97 | 84.1 | 28.6 | 30.4 | 54.79 | 23.9 |
nanoLLavA-1.5 | 待确定 | 待确定 | 待确定 | 待确定 | 待确定 | 待确定 | 待确定 | 待确定 |
提示格式
该模型遵循 ChatML 标准,但 <|im_end|>
末尾没有 \n
:
<|im_start|>system
Answer the question<|im_end|><|im_start|>user
<image>
What is the picture about?<|im_end|><|im_start|>assistant
训练数据
训练数据将在后续发布,因为作者仍在撰写相关论文。最终版本预计会比当前版本更强大。
微调代码
微调代码即将推出!
模型训练
模型使用 Bunny 的修改版本进行训练。
📄 许可证
本项目采用 Apache-2.0 许可证。
Clip Vit Large Patch14
CLIP是由OpenAI开发的视觉-语言模型,通过对比学习将图像和文本映射到共享的嵌入空间,支持零样本图像分类
图像生成文本
C
openai
44.7M
1,710
Clip Vit Base Patch32
CLIP是由OpenAI开发的多模态模型,能够理解图像和文本之间的关系,支持零样本图像分类任务。
图像生成文本
C
openai
14.0M
666
Siglip So400m Patch14 384
Apache-2.0
SigLIP是基于WebLi数据集预训练的视觉语言模型,采用改进的sigmoid损失函数,优化了图像-文本匹配任务。
图像生成文本
Transformers

S
google
6.1M
526
Clip Vit Base Patch16
CLIP是由OpenAI开发的多模态模型,通过对比学习将图像和文本映射到共享的嵌入空间,实现零样本图像分类能力。
图像生成文本
C
openai
4.6M
119
Blip Image Captioning Base
Bsd-3-clause
BLIP是一个先进的视觉-语言预训练模型,擅长图像描述生成任务,支持条件式和非条件式文本生成。
图像生成文本
Transformers

B
Salesforce
2.8M
688
Blip Image Captioning Large
Bsd-3-clause
BLIP是一个统一的视觉-语言预训练框架,擅长图像描述生成任务,支持条件式和无条件式图像描述生成。
图像生成文本
Transformers

B
Salesforce
2.5M
1,312
Openvla 7b
MIT
OpenVLA 7B是一个基于Open X-Embodiment数据集训练的开源视觉-语言-动作模型,能够根据语言指令和摄像头图像生成机器人动作。
图像生成文本
Transformers 英语

O
openvla
1.7M
108
Llava V1.5 7b
LLaVA 是一款开源多模态聊天机器人,基于 LLaMA/Vicuna 微调,支持图文交互。
图像生成文本
Transformers

L
liuhaotian
1.4M
448
Vit Gpt2 Image Captioning
Apache-2.0
这是一个基于ViT和GPT2架构的图像描述生成模型,能够为输入图像生成自然语言描述。
图像生成文本
Transformers

V
nlpconnect
939.88k
887
Blip2 Opt 2.7b
MIT
BLIP-2是一个视觉语言模型,结合了图像编码器和大型语言模型,用于图像到文本的生成任务。
图像生成文本
Transformers 英语

B
Salesforce
867.78k
359
精选推荐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
智启未来,您的人工智能解决方案智库
简体中文