商業應用| ? ?更新新聞| ?技術報告
聊天網 | ?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}
}