浦语·灵笔2-视觉问答-7B-4bit

我要开发同款
匿名用户2024年07月31日
67阅读

技术信息

官网地址
https://www.shlab.org.cn/
开源地址
https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm-xcomposer2-vl-7b-4bit
授权协议
other

作品详情

IterLM-XComposer2

[?Github Repo](https://github.com/IterLM/IterLM-XComposer) [Paper](https://arxiv.org/abs/2401.16420)

IterLM-XComposer2 is a visio-laguage large model (VLLM) based o IterLM2 for advaced text-image comprehesio ad compositio.

We release IterLM-XComposer2 series i two versios:

  • IterLM-XComposer2-VL: The pretraied VLLM model with IterLM2 as the iitializatio of the LLM, achievig strog performace o various multimodal bechmarks.
  • IterLM-XComposer2: The fietued VLLM for Free-from Iterleaved Text-Image Compositio.

This is the 4-bit versio of IterLM-XComposer2-VL, istall the latest versio of auto_gptq before usig.

Quickstart

We provide a simple example to show how to use IterLM-XComposer with ? Trasformers.

import torch, auto_gptq
from trasformers import AutoModel, AutoTokeizer 
from auto_gptq.modelig import BaseGPTQForCausalLM

auto_gptq.modelig._base.SUPPORTED_MODELS = ["iterlm"]
torch.set_grad_eabled(False)

class IterLMXComposer2QForCausalLM(BaseGPTQForCausalLM):
    layers_block_ame = "model.layers"
    outside_layer_modules = [
        'vit', 'visio_proj', 'model.tok_embeddigs', 'model.orm', 'output', 
    ]
    iside_layer_modules = [
        ["attetio.wqkv.liear"],
        ["attetio.wo.liear"],
        ["feed_forward.w1.liear", "feed_forward.w3.liear"],
        ["feed_forward.w2.liear"],
    ]

# iit model ad tokeizer
model = IterLMXComposer2QForCausalLM.from_quatized(
  'iterlm/iterlm-xcomposer2-vl-7b-4bit', trust_remote_code=True, device="cuda:0").eval()
tokeizer = AutoTokeizer.from_pretraied(
  'iterlm/iterlm-xcomposer2-vl-7b-4bit', trust_remote_code=True)

text = '<ImageHere>Please describe this image i detail.'
image = 'examples/image1.webp'
with torch.cuda.amp.autocast(): 
  respose, _ = model.chat(tokeizer, query=query, image=image, history=[], do_sample=False) 
prit(respose)
#The image features a quote by Oscar Wilde, "Live life with o excuses, travel with o regrets." 
#The quote is displayed i white text agaist a dark backgroud. I the foregroud, there are two silhouettes of people stadig o a hill at suset. 
#They appear to be hikig or climbig, as oe of them is holdig a walkig stick. 
#The sky behid them is paited with hues of orage ad purple, creatig a beautiful cotrast with the dark figures.

Ope Source Licese

The code is licesed uder Apache-2.0, while model weights are fully ope for academic research ad also allow free commercial usage. To apply for a commercial licese, please fill i the applicatio form (Eglish)/申请表(中文). For other questios or collaboratios, please cotact iterlm@pjlab.org.c.

功能介绍

InternLM-XComposer2 [?Github Repo](https://github.com/InternLM/InternLM-XComposer) [Paper](http

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论