智谱AI/LongAlign-7B-64k
模型介绍文件和版本Pull Requests讨论分析

LongAlign-7B-64k

🤗 [LongAlign 数据集] • 💻 [GitHub 仓库] • 📃 [LongAlign 论文]

LongAlign 是首个针对长上下文大语言模型(LLM)对齐的完整方案。我们构建了包含 10,000 条长度在 8k-64k 之间的长指令数据的 LongAlign-10k 数据集。我们研究了两种训练策略,即打包(带损失权重)和排序批处理,这些策略均已在代码中实现。为了进行真实场景下的长上下文评估,我们引入了 LongBench-Chat,用于评估模型在处理长度为 10k-100k 查询时的指令跟随能力。

所有模型

我们开源了以下模型列表:

模型Huggingface 仓库描述
LongAlign-6B-64k-base🤗 Huggingface 仓库上下文窗口扩展至 64k 的 ChatGLM3-6B
LongAlign-6B-64k🤗 Huggingface 仓库基于 LongAlign-6B-64k-base 通过 LongAlign 训练得到的对话模型
LongAlign-7B-64k-base🤗 Huggingface 仓库上下文窗口扩展至 64k 的 Llama-2-7B
LongAlign-7B-64k🤗 Huggingface 仓库基于 LongAlign-7B-64k-base 通过 LongAlign 训练得到的对话模型
LongAlign-13B-64k-base🤗 Huggingface 仓库上下文窗口扩展至 64k 的 Llama-2-13B
LongAlign-13B-64k🤗 Huggingface 仓库基于 LongAlign-13B-64k-base 通过 LongAlign 训练得到的对话模型
ChatGLM3-6B-128k🤗 Huggingface 仓库上下文窗口为 128k 的 ChatGLM3-6B

模型使用方法

LongAlign-6B-64k 的对话提示词模板:

[Round 1]

问:Hi!

答:Hello! What can I assist you today?

[Round 2]

问:What should I do if I can't sleep at night?

答:

LongAlign-7B-64k 和 LongAlign-13B-64k 的对话提示词模板:

[INST]Hi![/INST]Hello! What can I assist you today?

[INST]What should I do if I can't sleep at night?[/INST]

ChatGLM3-6B-128k 使用与 ChatGLM3-6B 相同的提示词模板。

以下是模型部署的简单演示:

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("THUDM/LongAlign-6B-64k", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("THUDM/LongAlign-6B-64k", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
model = model.eval()
query = open("assets/paper.txt").read() + "\n\nPlease summarize the paper."
response, history = model.chat(tokenizer, query, history=[], max_new_tokens=512, temperature=1)
print(response)

引用

如果您发现我们的研究工作对您有所帮助,请考虑引用 LongAlign:

下载使用量0