language:
- ja
tags:
- heron
- 视觉
- 图像描述生成
- 视觉问答
pipeline_tag: 图像转文本
license:
- cc-by-nc-4.0
inference: false
Heron BLIP 日语 StableLM 基础版 7B v1
模型详情
Heron BLIP 日语 StableLM 基础版 7B 是一个能够就输入图像进行对话的视觉语言模型。
该模型使用 the heron 库 训练。详情请参考相关代码。
使用方法
按照 安装指南 进行操作。
import torch
from heron.models.video_blip import VideoBlipForConditionalGeneration, VideoBlipProcessor
from transformers import LlamaTokenizer
device_id = 0
device = f"cuda:{device_id}"
MODEL_NAME = "turing-motors/heron-chat-blip-ja-stablelm-base-7b-v1"
model = VideoBlipForConditionalGeneration.from_pretrained(
MODEL_NAME, torch_dtype=torch.float16, ignore_mismatched_sizes=True
)
model = model.half()
model.eval()
model.to(device)
processor = VideoBlipProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
tokenizer = LlamaTokenizer.from_pretrained("novelai/nerdstash-tokenizer-v1", additional_special_tokens=['▁▁'])
processor.tokenizer = tokenizer
import requests
from PIL import Image
url = "https://www.barnorama.com/wp-content/uploads/2016/12/03-Confusing-Pictures.jpg"
image = Image.open(requests.get(url, stream=True).raw)
text = f"##human: 这张图片有趣的地方是什么?\n##gpt: "
inputs = processor(
text=text,
images=image,
return_tensors="pt",
truncation=True,
)
inputs = {k: v.to(device) for k, v in inputs.items()}
inputs["pixel_values"] = inputs["pixel_values"].to(device, torch.float16)
eos_token_id_list = [
processor.tokenizer.pad_token_id,
processor.tokenizer.eos_token_id,
int(tokenizer.convert_tokens_to_ids("##"))
]
with torch.no_grad():
out = model.generate(**inputs, max_length=256, do_sample=False, temperature=0., eos_token_id=eos_token_id_list, no_repeat_ngram_size=2)
print(processor.tokenizer.batch_decode(out))
模型详情
训练
该模型使用 LLaVA-Instruct-150K-JA 进行了全面微调。
训练数据集
使用与限制
预期用途
该模型适用于聊天类应用和研究目的。
限制
模型可能产生不准确或错误信息,其准确性无法保证。目前仍处于研发阶段。
引用方式
@misc{BlipJapaneseStableLM,
url = {[https://huggingface.co/turing-motors/heron-chat-blip-ja-stablelm-base-7b-v0](https://huggingface.co/turing-motors/heron-chat-blip-ja-stablelm-base-7b-v0)},
title = {Heron BLIP 日语 StableLM 基础版 7B},
author = {Kotaro Tanahashi, Yuichi Inoue, and Yu Yamaguchi}
}
参考文献
@misc{JapaneseInstructBLIPAlpha,
url = {[https://huggingface.co/stabilityai/japanese-instructblip-alpha](https://huggingface.co/stabilityai/japanese-instructblip-alpha)},
title = {日语 InstructBLIP Alpha},
author = {Shing, Makoto and Akiba, Takuya}
}
license: cc-by-nc-4.0