首页 > 数据库 > 数据库开发技术 > Index-1.9B: 小巧精炼的B站大模型
今天,B站大模型团队发布了Index-1.9B系列模型,是Index大语言模型系列中的19亿参数规模的模型,如下所示
B站大模型团队在github中发布了Index-1.9B的技术报告,以下是针对技术报告中内容的总结。

模型结构上 Follow Llama 的设定,使用了更深的结构,并增加了norm-head结构,支持更高的学习率进行学习。
| 参数 | 取值 |
|---|---|
| Hidden Size | 2048 |
| FFN Size | 5888 |
| n.Heads | 16 |
| n.Layers | 36 |
| Seq. | 4096 |
| Max LR | 5E-04 |
| Batch Size | 4M |
采用了目前比较常见的两阶段训练策略
在decay阶段提高指令数据的浓度可以显著提升benchmark的成绩,因此B站大模型团队同步开源了Index-1.9B-Pure模型,全程使用自然语言文本。
在Index-1.9B的训练过程中,观察到了一次模型性能的突涨,类似于GLM团队的论文Understanding Emergent Abilities of Language Models from the Loss Perspective中提到的涌现能力。
Index-1.9B 通用理解能力的评测结果
Github链接:https://github.com/bilibili/Index-1.9B【求star!!!】
huggingface链接:https://huggingface.co/IndexTeam
| 模型名称 | 模型链接 |
|---|---|
| Index-1.9B | https://huggingface.co/IndexTeam/Index-1.9B |
| Index-1.9B-Pure | https://huggingface.co/IndexTeam/Index-1.9B-Pure |
| Index-1.9B-Chat | https://huggingface.co/IndexTeam/Index-1.9B-Chat |
| Index-1.9B-Character | https://huggingface.co/IndexTeam/Index-1.9B-Character |
使用Transformers 推理,将参数model_path替换为下载好的Index-1.9B-Chat路径即可体验。
import torch
import argparse
from transformers import AutoTokenizer, AutoModelForCausalLM
parser = argparse.ArgumentParser()
parser.add_argument('--model_path', default="", type=str, help="")
args = parser.parse_args()
tokenizer = AutoTokenizer.from_pretrained(args.model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(args.model_path, torch_dtype=torch.bfloat16, trust_remote_code=True, device_map='auto')
model = model.eval()
print('model loaded', args.model_path, model.device)
system_message = "你是由哔哩哔哩自主研发的大语言模型,名为“Index”。你能够根据用户传入的信息,帮助用户完成指定的任务,并生成恰当的、符合要求的回复。"
query = "续写 天不生我金坷垃"
model_input = []
model_input.append({"role": "system", "content": system_message})
model_input.append({"role": "user", "content": query})
inputs = tokenizer.apply_chat_template(model_input, tokenize=False, add_generation_prompt=False)
input_ids = tokenizer.encode(inputs, return_tensors="pt").to(model.device)
history_outputs = model.generate(input_ids, max_new_tokens=300, top_k=5, top_p=0.8, temperature=0.3, repetition_penalty=1.1, do_sample=True)
# 删除</s>
if history_outputs[0][-1] == 2:
history_outputs = history_outputs[:, :-1]
outputs = history_outputs[0][len(input_ids[0]):]
print('User:', query)
print('\nModel:', tokenizer.decode(outputs))
官方仓库内提供了方便简洁的web_demo,依赖Gradio,安装命令:
pip install gradio==4.29.0
通过以下代码启动一个web server,在浏览器输入访问地址后,可使用 Index-1.9B-Chat 模型进行对话:
python demo/web_demo.py --port='port' --model_path='/path/to/model/'
使用默认的system message
你也可以改变system message,让他扮演一位阴阳怪气的B站老哥
你也可以通过上传符合要求的角色对话语料,使用Index-1.9B-Character实现few shots角色定制
以上是对B站大模型团队发布的Index-1.9B模型的简要介绍,详情可以访问官方github或者huggingface地址了解更多细节,求点赞Star!!!
原文作者:ChallengeHub;如有侵权,请联系管理员删除。