商业应用| ?拥抱脸| ?更新新闻| ?报告问题|技术报告
聊天网 | ?API | ?建模者
英语 | 简体中文
通过 Discord 和微信加入我们
InternLM2.5系列发布,具有以下特点:
出色的推理能力:数学推理性能领先,超越Llama3、Gemma2-9B等模型。
1M 上下文窗口:在 1M 长上下文中大海捞针方面近乎完美,在 LongBench 等长上下文任务上表现领先。尝试使用 LMDeploy 进行 1M 上下文推理。更多详细信息和文件聊天演示可在此处找到。
工具性更强:InternLM2.5支持从100多个网页收集信息,相应的实现很快就会在Lagent中发布。 InternLM2.5在指令跟随、工具选择和反思方面具有更好的工具利用相关能力。请参阅示例。
[2024.08.01] 我们发布了 InternLM2.5-1.8B、InternLM2.5-1.8B-Chat、InternLM2.5-20B 和 InternLM2.5-20B-Chat。请参阅下面的模型动物园下载或模型卡了解更多详细信息。
[2024.07.19] 我们发布了InternLM2-Reward系列奖励模型,有1.8B、7B和20B尺寸。请参阅下面的模型动物园下载或模型卡了解更多详细信息。
[2024.07.03] 我们发布了 InternLM2.5-7B、InternLM2.5-7B-Chat 和 InternLM2.5-7B-Chat-1M。请参阅下面的模型动物园下载或模型卡了解更多详细信息。
[2024.03.26] 我们发布InternLM2技术报告。详情请参阅 arXiv。
[2024.01.31] 我们发布了 InternLM2-1.8B 以及相关的聊天模型。它们提供更便宜的部署选项,同时保持领先的性能。
[2024.01.23] 我们发布了带有预训练和 SFT 检查点的 InternLM2-Math-7B 和 InternLM2-Math-20B。它们以小尺寸超越了 ChatGPT。有关详细信息和下载,请参阅 InternLM-Math。
[2024.01.17] 我们发布了InternLM2-7B和InternLM2-20B及其相应的聊天模型,在各个维度上都有更强的能力。请参阅下面的模型动物园下载或模型卡了解更多详细信息。
[2023.12.13] InternLM-7B-Chat 和 InternLM-20B-Chat 检查点已更新。通过改进的微调策略,新的聊天模型可以生成具有更大风格多样性的更高质量的响应。
[2023.09.20] InternLM-20B 发布基础版和聊天版。
模型 | 变压器(高频) | 型号范围(HF) | OpenXLab(HF) | OpenXLab(起源) | 发布日期 |
---|---|---|---|---|---|
实习生LM2.5-1.8B | ?internlm2_5-1_8b | 实习生LM2_5-1_8b | 2024-08-05 | ||
实习生LM2.5-1.8B-聊天 | ?internlm2_5-1_8b-聊天 | internlm2_5-1_8b-聊天 | 2024-08-05 | ||
实习生LM2.5-7B | ?internlm2_5-7b | 实习生LM2_5-7b | 2024-07-03 | ||
实习生LM2.5-7B-聊天 | ?internlm2_5-7b-聊天 | internlm2_5-7b-聊天 | 2024-07-03 | ||
实习生LM2.5-7B-聊天-1M | ?internlm2_5-7b-聊天-1m | internlm2_5-7b-聊天-1m | 2024-07-03 | ||
实习生LM2.5-20B | ?internlm2_5-20b | 实习生LM2_5-20b | 2024-08-05 | ||
实习生LM2.5-20B-聊天 | ?internlm2_5-20b-聊天 | internlm2_5-20b-聊天 | 2024-08-05 |
笔记:
InternLM2.5系列的发布包含1.8B、7B、20B版本。 7B模型研究和应用效率较高,20B模型功能更强大,可以支持更复杂的场景。这些模型的关系如下所示。
局限性:尽管我们努力确保模型在训练过程中的安全性,并鼓励模型生成符合道德和法律要求的文本,但由于其规模和概率生成范式,模型仍然可能会产生意外的输出。例如,生成的响应可能包含偏见、歧视或其他有害内容。请不要传播此类内容。我们对因传播有害信息而造成的任何后果不承担任何责任。
补充: HF
是指Transformers中HuggingFace使用的格式,而Origin
表示InternEvo中InternLM团队采用的格式。
InternLM2-Reward 是一系列奖励模型,经过 240 万个偏好样本的训练,提供 1.8B、7B 和 20B 尺寸。这些模型被应用于我们聊天模型的 PPO 训练过程。有关详细信息,请参阅型号卡。
模型 | 奖励基准分数 | 变压器(高频) | 型号范围(HF) | OpenXLab(HF) | 发布日期 |
---|---|---|---|---|---|
实习生LM2-1.8B-奖励 | 80.6 | ?internlm2-1_8b-奖励 | internlm2-1_8b-奖励 | 2024-07-19 | |
实习生LM2-7B-奖励 | 86.6 | ?internlm2-7b-奖励 | internlm2-7b-奖励 | 2024-07-19 | |
实习生LM2-20B-奖励 | 89.5 | ?internlm2-20b-奖励 | internlm2-20b-奖励 | 2024-07-19 |
我们的上一代模型在长上下文处理、推理和编码方面具有先进的功能。有关详细信息,请参阅型号卡。
模型 | 变压器(高频) | 型号范围(HF) | OpenXLab(HF) | OpenXLab(起源) | 发布日期 |
---|---|---|---|---|---|
实习生LM2-1.8B | ?internlm2-1.8b | 实习生LM2-1.8b | 2024-01-31 | ||
实习生LM2-Chat-1.8B-SFT | ?internlm2-chat-1.8b-sft | internlm2-聊天-1.8b-sft | 2024-01-31 | ||
实习生LM2-聊天-1.8B | ?internlm2-chat-1.8b | internlm2-聊天-1.8b | 2024-02-19 | ||
实习生LM2-Base-7B | ?internlm2-base-7b | interlm2-base-7b | 2024-01-17 | ||
实习生LM2-7B | ?internlm2-7b | 实习生LM2-7B | 2024-01-17 | ||
实习生LM2-Chat-7B-SFT | ?internlm2-chat-7b-sft | internlm2-聊天-7b-sft | 2024-01-17 | ||
实习生LM2-Chat-7B | ?internlm2-chat-7b | interlm2-聊天-7b | 2024-01-17 | ||
实习生LM2-Base-20B | ?internlm2-base-20b | interlm2-base-20b | 2024-01-17 | ||
实习生LM2-20B | ?internlm2-20b | 实习生LM2-20B | 2024-01-17 | ||
实习生LM2-Chat-20B-SFT | ?internlm2-chat-20b-sft | internlm2-聊天-20b-sft | 2024-01-17 | ||
实习生LM2-Chat-20B | ?internlm2-chat-20b | internlm2-聊天-20b | 2024-01-17 |
我们使用开源评估工具 OpenCompass 在几个重要基准上评估了 InternLM2.5。部分评价结果如下表所示。欢迎您访问OpenCompass排行榜了解更多评测结果。
基准 | 实习生LM2.5-7B | 骆驼3-8B | 毅1.5-9B |
---|---|---|---|
MMLU(5 次) | 71.6 | 66.4 | 71.6 |
CMMLU(5 次) | 79.1 | 51.0 | 74.1 |
BBH(3发) | 70.1 | 59.7 | 71.1 |
数学(4 次) | 34.0 | 16.4 | 31.9 |
GSM8K(4拍) | 74.8 | 54.3 | 74.5 |
GPQA(0 次) | 31.3 | 31.3 | 27.8 |
基准 | 实习生LM2.5-7B-聊天 | Llama3-8B-指导 | Gemma2-9B-IT | Yi-1.5-9B-聊天 | GLM-4-9B-聊天 | Qwen2-7B-指令 |
---|---|---|---|---|---|---|
MMLU(5 次) | 72.8 | 68.4 | 70.9 | 71.0 | 71.4 | 70.8 |
CMMLU(5 次) | 78.0 | 53.3 | 60.3 | 74.5 | 74.5 | 80.9 |
BBH(3 次 CoT) | 71.6 | 54.4 | 68.2* | 69.6 | 69.6 | 65.0 |
数学(0 次 CoT) | 60.1 | 27.9 | 46.9 | 51.1 | 51.1 | 48.6 |
GSM8K(0 次 CoT) | 86.0 | 72.9 | 88.9 | 80.1 | 85.3 | 82.9 |
GPQA(0 次) | 38.4 | 26.1 | 33.8 | 37.9 | 36.9 | 38.4 |
ppl
对基本模型进行 MCQ 评估。InternLM支持多种知名上下游项目,如LLaMA-Factory、vLLM、llama.cpp等。这种支持使广大用户能够更高效、更方便地使用 InternLM 系列模型。为了您的方便,此处提供了选定生态系统项目的教程。
在接下来的章节中,我们将重点介绍 Transformers、ModelScope 和 Web 演示的用法。聊天模型采用chatml格式来支持聊天和代理应用程序。为了保证更好的使用效果,在使用 Transformers 或 ModelScope 进行推理之前,请确保安装的 Transformers 库版本满足以下要求:
transformers >= 4.38
要使用 Transformer 加载 InternLM2.5-7B-Chat 模型,请使用以下代码:
import torch
from transformers import AutoTokenizer , AutoModelForCausalLM
tokenizer = AutoTokenizer . from_pretrained ( "internlm/internlm2_5-7b-chat" , trust_remote_code = True )
# Set `torch_dtype=torch.float16` to load model in float16, otherwise it will be loaded as float32 and might cause OOM Error.
model = AutoModelForCausalLM . from_pretrained ( "internlm/internlm2_5-7b-chat" , device_map = "auto" , trust_remote_code = True , torch_dtype = torch . float16 )
# (Optional) If on low resource devices, you can load model in 4-bit or 8-bit to further save GPU memory via bitsandbytes.
# InternLM 7B in 4bit will cost nearly 8GB GPU memory.
# pip install -U bitsandbytes
# 8-bit: model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto", trust_remote_code=True, load_in_8bit=True)
# 4-bit: model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto", trust_remote_code=True, load_in_4bit=True)
model = model . eval ()
response , history = model . chat ( tokenizer , "hello" , history = [])
print ( response )
# Output: Hello? How can I help you today?
response , history = model . chat ( tokenizer , "please provide three suggestions about time management" , history = history )
print ( response )
要使用 ModelScope 加载 InternLM2.5-7B-Chat 模型,请使用以下代码:
import torch
from modelscope import snapshot_download , AutoTokenizer , AutoModelForCausalLM
model_dir = snapshot_download ( 'Shanghai_AI_Laboratory/internlm2_5-7b-chat' )
tokenizer = AutoTokenizer . from_pretrained ( model_dir , device_map = "auto" , trust_remote_code = True )
# Set `torch_dtype=torch.float16` to load model in float16, otherwise it will be loaded as float32 and might cause OOM Error.
model = AutoModelForCausalLM . from_pretrained ( model_dir , device_map = "auto" , trust_remote_code = True , torch_dtype = torch . float16 )
# (Optional) If on low resource devices, you can load model in 4-bit or 8-bit to further save GPU memory via bitsandbytes.
# InternLM 7B in 4bit will cost nearly 8GB GPU memory.
# pip install -U bitsandbytes
# 8-bit: model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto", trust_remote_code=True, load_in_8bit=True)
# 4-bit: model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto", trust_remote_code=True, load_in_4bit=True)
model = model . eval ()
response , history = model . chat ( tokenizer , "hello" , history = [])
print ( response )
response , history = model . chat ( tokenizer , "please provide three suggestions about time management" , history = history )
print ( response )
您可以通过运行以下代码通过前端界面与 InternLM Chat 7B 模型进行交互:
pip install streamlit
pip install transformers > =4.38
streamlit run ./chat/web_demo.py
我们使用 LMDeploy 来快速部署 InternLM。
只需 4 行代码,即可在pip install lmdeploy
后进行 internlm2_5-7b-chat 推理。
from lmdeploy import pipeline
pipe = pipeline ( "internlm/internlm2_5-7b-chat" )
response = pipe ([ "Hi, pls intro yourself" , "Shanghai is" ])
print ( response )
为了减少内存占用,我们提供了4位量化模型internlm2_5-7b-chat-4bit,使用该模型可以进行如下推理:
from lmdeploy import pipeline
pipe = pipeline ( "internlm/internlm2_5-7b-chat-4bit" )
response = pipe ([ "Hi, pls intro yourself" , "Shanghai is" ])
print ( response )
此外,您可以独立激活8bit/4bit KV缓存功能:
from lmdeploy import pipeline , TurbomindEngineConfig
pipe = pipeline ( "internlm/internlm2_5-7b-chat-4bit" ,
backend_config = TurbomindEngineConfig ( quant_policy = 8 ))
response = pipe ([ "Hi, pls intro yourself" , "Shanghai is" ])
print ( response )
更多模型部署的使用方法请参考指南。如需其他部署教程,请随意探索此处。
通过启用LMDeploy的Dynamic NTK功能,您可以获得长上下文推理能力。
注意:1M 上下文长度需要 4xA100-80G。
from lmdeploy import pipeline , GenerationConfig , TurbomindEngineConfig
backend_config = TurbomindEngineConfig (
rope_scaling_factor = 2.5 ,
session_len = 1048576 , # 1M context length
max_batch_size = 1 ,
cache_max_entry_count = 0.7 ,
tp = 4 ) # 4xA100-80G.
pipe = pipeline ( 'internlm/internlm2_5-7b-chat-1m' , backend_config = backend_config )
prompt = 'Use a long prompt to replace this sentence'
response = pipe ( prompt )
print ( response )
InternLM2.5-Chat模型具有出色的工具利用能力,可以以零样本的方式处理函数调用。它还支持从100多个网页中收集信息进行分析。请参阅代理部分的更多示例。
请参阅 Finetune 文档以使用 InternLM 进行微调。
注意:我们已将此项目中的整个训练功能迁移到 InternEvo,以获得更轻松的用户体验,这为训练 InternLM 提供了高效的预训练和微调基础设施。
我们利用 OpenCompass 进行模型评估。在InternLM2.5中,我们主要关注标准客观评估、长上下文评估(大海捞针)、数据污染评估、代理评估和主观评估。
要评估 InternLM 模型,请遵循 OpenCompass 教程中的指南。通常,我们使用ppl
来处理Base模型上的多项选择题,使用gen
来处理Chat模型上的所有问题。
对于Needle in a Haystack
评估,请参阅文档中提供的教程。请随意尝试一下。
要了解有关数据污染评估的更多信息,请查看污染评估。
我们感谢所有贡献者为改进和增强 InternLM 所做的努力。强烈鼓励社区用户参与该项目。请参阅贡献指南,了解如何为该项目做出贡献的说明。
该代码在 Apache-2.0 下获得许可,而模型权重完全开放用于学术研究,也允许免费商业使用。如需申请商业许可,请填写申请表(英文)/申请表(中文)。如有其他问题或合作,请联系[email protected]。
@misc{cai2024internlm2,
title={InternLM2 Technical Report},
author={Zheng Cai and Maosong Cao and Haojiong Chen and Kai Chen and Keyu Chen and Xin Chen and Xun Chen and Zehui Chen and Zhi Chen and Pei Chu and Xiaoyi Dong and Haodong Duan and Qi Fan and Zhaoye Fei and Yang Gao and Jiaye Ge and Chenya Gu and Yuzhe Gu and Tao Gui and Aijia Guo and Qipeng Guo and Conghui He and Yingfan Hu and Ting Huang and Tao Jiang and Penglong Jiao and Zhenjiang Jin and Zhikai Lei and Jiaxing Li and Jingwen Li and Linyang Li and Shuaibin Li and Wei Li and Yining Li and Hongwei Liu and Jiangning Liu and Jiawei Hong and Kaiwen Liu and Kuikun Liu and Xiaoran Liu and Chengqi Lv and Haijun Lv and Kai Lv and Li Ma and Runyuan Ma and Zerun Ma and Wenchang Ning and Linke Ouyang and Jiantao Qiu and Yuan Qu and Fukai Shang and Yunfan Shao and Demin Song and Zifan Song and Zhihao Sui and Peng Sun and Yu Sun and Huanze Tang and Bin Wang and Guoteng Wang and Jiaqi Wang and Jiayu Wang and Rui Wang and Yudong Wang and Ziyi Wang and Xingjian Wei and Qizhen Weng and Fan Wu and Yingtong Xiong and Chao Xu and Ruiliang Xu and Hang Yan and Yirong Yan and Xiaogui Yang and Haochen Ye and Huaiyuan Ying and Jia Yu and Jing Yu and Yuhang Zang and Chuyu Zhang and Li Zhang and Pan Zhang and Peng Zhang and Ruijie Zhang and Shuo Zhang and Songyang Zhang and Wenjian Zhang and Wenwei Zhang and Xingcheng Zhang and Xinyue Zhang and Hui Zhao and Qian Zhao and Xiaomeng Zhao and Fengzhe Zhou and Zaida Zhou and Jingming Zhuo and Yicheng Zou and Xipeng Qiu and Yu Qiao and Dahua Lin},
year={2024},
eprint={2403.17297},
archivePrefix={arXiv},
primaryClass={cs.CL}
}