pipeline_tag: 文本生成
license: 其他
书生·浦语
简介
第二代书生·浦语模型InternLM2包含7B和20B两种参数规模。为方便用户使用与研究,我们针对每个参数规模开源了四个版本的模型,分别是:
- internlm2-base:高质量且具备极强可塑性的模型基座,是进行深度领域适配的优秀起点;
- internlm2(推荐):在internlm2-base基础上,经过领域特定语料继续预训练,在评测中表现优异,同时保持出色的通用语言能力,是大部分应用场景的推荐选择;
- internlm2-chat-sft:基于Base模型进行有监督的人类对齐训练;
- internlm2-chat(推荐):在internlm2-chat-sft基础上通过RLHF优化对话交互能力,在指令遵循、共情对话和工具调用等方面表现卓越。
InternLM2基础模型具备以下技术特性:
- 完美支持20万字超长上下文:模型在20万字长文本中实现"大海捞针"级精准检索,在LongBench和L-Eval等长文本任务中的表现位居开源模型前列;
- 综合性能全面提升:相比前代模型,在推理、数学和编程等能力维度均有显著提升。
InternLM2-20B
性能评测
我们使用开源评测工具OpenCompass对InternLM2进行了多维度评测。部分评测结果如下表所示,更多结果请访问OpenCompass榜单。
评测集\模型 |
InternLM2-7B |
InternLM2-Chat-7B |
InternLM2-20B |
InternLM2-Chat-20B |
ChatGPT |
GPT-4 |
MMLU |
65.8 |
63.7 |
67.7 |
66.5 |
69.1 |
83.0 |
AGIEval |
49.9 |
47.2 |
53.0 |
50.3 |
39.9 |
55.1 |
BBH |
65.0 |
61.2 |
72.1 |
68.3 |
70.1 |
86.7 |
GSM8K |
70.8 |
70.7 |
76.1 |
79.6 |
78.2 |
91.4 |
MATH |
20.2 |
23.0 |
25.5 |
31.9 |
28.0 |
45.8 |
HumanEval |
43.3 |
59.8 |
48.8 |
67.1 |
73.2 |
74.4 |
MBPP(净化版) |
51.8 |
51.4 |
63.0 |
65.8 |
78.9 |
79.0 |
局限性声明: 尽管我们在训练过程中高度重视模型安全性,致力于使模型输出符合伦理法律要求,但受模型规模及概率生成机制限制,仍可能产生包含偏见、歧视等有害内容的不当输出。请勿传播此类内容,因传播不良信息导致的后果本项目概不负责。
通过Transformers加载
使用以下代码加载InternLM2-20B模型进行文本生成:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("internlm/internlm2-20b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("internlm/internlm2-20b", torch_dtype=torch.float16, trust_remote_code=True).cuda()
model = model.eval()
inputs = tokenizer(["一株美丽的鲜花"], return_tensors="pt")
for k,v in inputs.items():
inputs[k] = v.cuda()
gen_kwargs = {"max_length": 128, "top_p": 0.8, "temperature": 0.8, "do_sample": True, "repetition_penalty": 1.0}
output = model.generate(**inputs, **gen_kwargs)
output = tokenizer.decode(output[0].tolist(), skip_special_tokens=True)
print(output)
开源许可
代码遵循Apache-2.0协议开源,模型权重对学术研究完全开放,同时允许免费商业使用(需填写英文申请表/中文申请表)。其他问题或合作请联系internlm@pjlab.org.cn。
引用文献
@misc{cai2024internlm2,
title={InternLM2技术报告},
author={蔡峥 and 曹茂松 and 陈豪炯 and 陈恺 and 陈科宇 and 陈鑫 and 陈洵 and 陈泽晖 and 陈志 and 褚培 and 董晓艺 and 段昊东 and 范琪 and 费昭烨 and 高洋 and 葛佳烨 and 顾辰亚 and 顾雨泽 and 桂韬 and 郭爱佳 and 郭启鹏 and 何从辉 and 胡英芳 and 黄婷 and 姜涛 and 焦鹏龙 and 金振疆 and 雷志凯 and 李佳幸 and 李静雯 and 李林阳 and 李帅彬 and 李玮 and 李奕宁 and 刘宏伟 and 刘江宁 and 洪佳伟 and 刘凯文 and 刘奎坤 and 刘笑然 and 吕承琪 and 吕海军 and 吕凯 and 马丽 and 马润远 and 马泽润 and 宁文昌 and 欧阳林可 and 邱建涛 and 曲元 and 尚福凯 and 邵云帆 and 宋德民 and 宋子凡 and 隋志浩 and 孙鹏 and 孙宇 and 唐焕泽 and 王斌 and 王国腾 and 王佳琪 and 王佳瑜 and 王睿 and 王宇栋 and 王子怡 and 魏星剑 and 翁启真 and 吴凡 and 熊颖瞳 and 徐超 and 徐瑞亮 and 严航 and 严一荣 and 杨晓桂 and 叶浩宸 and 应怀原 and 俞佳 and 俞静 and 臧宇航 and 张楚瑜 and 张丽 and 张潘 and 张鹏 and 张瑞杰 and 张硕 and 张松阳 and 张文健 and 张文蔚 and 张星城 and 张新月 and 赵辉 and 赵倩 and 赵晓萌 and 周凤哲 and 周载道 and 卓靖明 and 邹奕成 and 邱锡鹏 and 乔宇 and 林达华},
year={2024},
eprint={2403.17297},
archivePrefix={arXiv},
primaryClass={cs.CL}
}