浦语·灵笔
InternLM-XComposer ? ? | InternLM-XComposer-VL ? ? | Technical Report ?
[?Github 仓库](https://github.com/InternLM/InternLM-XComposer)
浦语·灵笔是基于书生·浦语大语言模型研发的视觉-语言大模型,提供出色的图文理解和创作能力,具有多项优势:
图文交错创作: 浦语·灵笔可以为用户打造图文并貌的专属文章。生成的文章文采斐然,图文相得益彰,提供沉浸式的阅读体验。这一能力由以下步骤实现:
- 理解用户指令,创作符合要求的长文章。
- 智能分析文章,自动规划插图的理想位置,确定图像内容需求。
- 多层次智能筛选,从图库中锁定最完美的图片。
基于丰富多模态知识的图文理解: 浦语·灵笔设计了高效的训练策略,为模型注入海量的多模态概念和知识数据,赋予其强大的图文理解和对话能力。
杰出性能: 浦语·灵笔在多项视觉语言大模型的主流评测上均取得了最佳性能,包括MME Benchmark (英文评测), MMBench (英文评测), Seed-Bench (英文评测), CCBench(中文评测), MMBench-CN (中文评测).
我们开源的浦语·灵笔包括两个版本:
- InternLM-XComposer-VL-7B ? ? : 基于书生·浦语大语言模型的多模态预训练和多任务训练模型,在多种评测上表现出杰出性能, 例如:MME Benchmark, MMBench Seed-Bench, CCBench, MMBench-CN.
- InternLM-XComposer-7B ? ? : 面向 图文交错文章创作 和 智能对话 的微调模型。
更多方法细节请参考技术报告.
Clone本仓库:
git clone https://www.modelscope.cn/Shanghai_AI_Laboratory/internlm-xcomposer-7b.git
示例代码
import torch
from modelscope import snapshot_download, AutoModel, AutoTokenizer
import os
torch.set_grad_enabled(False)
# init model and tokenizer
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm-xcomposer-7b', revision = 'v1.0.2')
model = AutoModel.from_pretrained(model_dir, trust_remote_code=True).cuda().eval()
tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
model.tokenizer = tokenizer
# example image
image = os.path.join(model_dir,'aiyinsitan.jpg')
# Single-Turn Pure-Text Dialogue
text = 'Please introduce Einstein.'
response = model.generate(text)
print(response)
# Multi-Turn Text-Image Dialogue
# 1st turn
text = '图片里面的是谁?'
response, history = model.chat(text=text, image=image, history=None)
print(response)
# 阿尔伯特·爱因斯坦。
# 2nd turn
text = '他有哪些成就?'
response, history = model.chat(text=text, image=None, history=history)
print(response)
# 阿尔伯特·爱因斯坦是20世纪最伟大的物理学家之一,他提出了狭义相对论和广义相对论,对现代物理学的发展产生了深远影响。
# 此外,他还提出了著名的质能方程E=mc²,为核能的开发提供了理论基础。
# 3rd turn
text = '他是最伟大的物理学家吗?'
response, history = model.chat(text=text, image=None, history=history)
print(response)
# 是的,阿尔伯特·爱因斯坦是20世纪最伟大的物理学家之一。
评论