社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本

483次阅读
没有评论

社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本

元象多语言通用大模型 XVERSE-13B 自 8 月 7 日开源以来广受关注,为促进大模型在垂直领域和特定任务的应用,方便开发者快速高效地定制化调优,元象宣布推出 XVERSE-13B-Chat 版,继续开源,并可免费商用。


 开源信息 

Hugging Face:

https://huggingface.co/xverse/XVERSE-13B-Chat

Githubhttps://github.com/xverse-ai/XVERSE-13B

联系邮箱:opensource@xverse.cn

XVERSE-13B 是同尺寸中效果最好的多语言大模型系列,性能超越 Llama-2-13B、Baichuan-13B-Chat 等国内外开源代表(图一),凭借高性能、全开源、可商用等优势,是国产替代和中文应用的更佳选择。
社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本

图一:XVERSE-13B 系列使用 five shot 方法测试 

在各项中英文权威测评中持续领先

此次 Chat 版通过底座指令精调(Supervised Fine-tuning,简称 SFT ),使大模型在理解和生成上更加精准流畅,基础性能显著提升,比如 MMLU英文(+9%)、 AGIEval 中英(+17%)、GAOKAO-En 英文(+21%)等数据集效果优异。它还补齐了多个指令场景能力,用途更广包括角色扮演、知识问答、文本生成、编程、数学解答和安全性等。

  多场景示例

角色扮演

社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本

知识问答

社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本

文本生成

社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本

语言理解

社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本

安全性
社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本

  使用教程

环境安装

1. 下载本仓库:

git clone https://github.com/xverse-ai/XVERSE-13B cd XVERSE-13B2. 使用 pip 安装依赖:

pip install -r requirements.txtTransformers 加载方式

可通过以下代码加载 Chat 版对话:

>>>import torch>>> from transformers import AutoTokenizer, AutoModelForCausalLM>>> from transformers.generation.utils import GenerationConfig>>> model_path ="xverse/XVERSE-13B-Chat">>> tokenizer = AutoTokenizer.from_pretrained(model_path)>>> model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto')>>> model.generation_config = GenerationConfig.from_pretrained(model_path)>>> model = model.eval()>>>history=[{"role":"user", "content":"1955年谁是美国总统?他是什么党派?"}]>>> response = model.chat(tokenizer, history)>>> print(response)1955年,美国总统是德怀特·D·艾森豪威尔。他所属的党派是共和党。>>> history.append({"role":"assistant", "content": response})>>> history.append({"role":"user", "content":"他任职了多少年"})>>> response = model.chat(tokenizer, history)>>> print(response)德怀特·D·艾森豪威尔在1953年至1961年间担任美国总统,所以他一共任职了8年。通过以下代码启动一个web server,在浏览器输入访问地址后,可使用 Chat 版对话:

python chat_demo.py --port='port' --model_path='/path/to/model/' --tokenizer_path='/path/to/tokenizer/'

 

  模型量化

支持 INT8  INT4 类型量化,可以大幅降低模型加载所需显存。INT8 量化:

model = AutoModelForCausalLM.from_pretrained("xverse/XVERSE-13B-Chat", torch_dtype=torch.bfloat16, trust_remote_code=True) model = model.quantize(8).cuda()INT4 量化:

model = AutoModelForCausalLM.from_pretrained("xverse/XVERSE-13B-Chat", torch_dtype=torch.bfloat16, trust_remote_code=True)model = model.quantize(4).cuda()Chat 版在不同量化等级下,模型显存占用及 MMLU 准确率:社区供稿 | 元象通用大模型 XVERSE-13B 发布Chat版本


本文转载自
社区供稿内容,不代表官方立场。了解更多,请关注微信公众号”元象XVERSE”:

如果你有好的文章希望通过我们的平台分享给更多人,请通过这个链接与我们联系: 

https://hf.link/tougao

 

Read More 

正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 
评论(没有评论)
Generated by Feedzy