HuggingFace镜像/glm-4-9b-chat-1m
模型介绍文件和版本分析
下载使用量0

GLM-4-9B-Chat-1M

英文版本

2024年7月24日,我们发布了与长文本相关的最新技术解读,欢迎通过此链接查看我们在训练GLM-4-9B开源模型过程中关于长文本技术的技术报告。

模型介绍

GLM-4-9B是智谱AI推出的最新一代预训练模型GLM-4系列中的开源版本。 在语义、数学、推理、代码和知识等多个数据集的测评中,GLM-4-9B及其经过人类偏好对齐的版本GLM-4-9B-Chat均展现出卓越性能。 除了支持多轮对话外,GLM-4-9B-Chat还具备网页浏览、代码执行、自定义工具调用(Function Call)以及长文本推理(支持最大128K上下文)等高级功能。 本代模型新增了多语言支持,可处理包括日语、韩语、德语在内的26种语言。我们同时推出了支持1M上下文长度(约200万中文字符)的模型。

评测结果

长文本

在1M上下文长度下进行的大海捞针实验结果如下:

needle

在LongBench-Chat上对长文本能力的进一步评测结果如下:

leaderboard

本仓库为GLM-4-9B-Chat-1M的模型仓库,支持1M上下文长度。

运行模型

更多推理代码及依赖信息,请访问我们的GitHub。

请严格按照依赖要求进行安装,否则可能导致无法正常运行。

使用openMind进行推理:

import torch
from openmind import AutoModelForCausalLM, AutoTokenizer

device = "npu"

tokenizer = AutoTokenizer.from_pretrained("AI-Research/glm-4-9b-chat-1m",trust_remote_code=True)

query = "你好"

inputs = tokenizer.apply_chat_template([{"role": "user", "content": query}],
                                       add_generation_prompt=True,
                                       tokenize=True,
                                       return_tensors="pt",
                                       return_dict=True
                                       )

inputs = inputs.to(device)
model = AutoModelForCausalLM.from_pretrained(
    "AI-Research/glm-4-9b-chat-1m",
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    trust_remote_code=True
).to(device).eval()

gen_kwargs = {"max_length": 2500, "do_sample": True, "top_k": 1}
with torch.no_grad():
    outputs = model.generate(**inputs, **gen_kwargs)
    outputs = outputs[:, inputs['input_ids'].shape[1]:]
    print(tokenizer.decode(outputs[0], skip_special_tokens=True))

协议

GLM-4 模型的权重的使用则需要遵循 LICENSE。

引用

如果你觉得我们的工作有帮助的话,请考虑引用下列论文。

@misc{glm2024chatglm,
      title={ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools}, 
      author={Team GLM and Aohan Zeng and Bin Xu and Bowen Wang and Chenhui Zhang and Da Yin and Diego Rojas and Guanyu Feng and Hanlin Zhao and Hanyu Lai and Hao Yu and Hongning Wang and Jiadai Sun and Jiajie Zhang and Jiale Cheng and Jiayi Gui and Jie Tang and Jing Zhang and Juanzi Li and Lei Zhao and Lindong Wu and Lucen Zhong and Mingdao Liu and Minlie Huang and Peng Zhang and Qinkai Zheng and Rui Lu and Shuaiqi Duan and Shudan Zhang and Shulin Cao and Shuxun Yang and Weng Lam Tam and Wenyi Zhao and Xiao Liu and Xiao Xia and Xiaohan Zhang and Xiaotao Gu and Xin Lv and Xinghan Liu and Xinyi Liu and Xinyue Yang and Xixuan Song and Xunkai Zhang and Yifan An and Yifan Xu and Yilin Niu and Yuantao Yang and Yueyan Li and Yushi Bai and Yuxiao Dong and Zehan Qi and Zhaoyu Wang and Zhen Yang and Zhengxiao Du and Zhenyu Hou and Zihan Wang},
      year={2024},
      eprint={2406.12793},
      archivePrefix={arXiv},
      primaryClass={id='cs.CL' full_name='Computation and Language' is_active=True alt_name='cmp-lg' in_archive='cs' is_general=False description='Covers natural language processing. Roughly includes material in ACM Subject Class I.2.7. Note that work on artificial languages (programming languages, logics, formal systems) that does not explicitly address natural-language issues broadly construed (natural-language processing, computational linguistics, speech, text retrieval, etc.) is not appropriate for this area.'}
}