InternLM has open-sourced a 7 billion parameter base model, a chat model tailored for practical scenarios and the training system.
Go to file
Wenwei Zhang 468982bc76
[Doc]: Resolve comments in documentation (#587)
* fix typos and try pass lint

* fix wrong path in CI

* fix wrong path in readme

* update lint doc

* update doc

* update doc
2024-01-17 10:47:06 +08:00
.github [Doc]: Resolve comments in documentation (#587) 2024-01-17 10:47:06 +08:00
agent Update main branch and docs (#585) 2024-01-17 09:46:11 +08:00
assets Update main branch and docs (#585) 2024-01-17 09:46:11 +08:00
chat [Doc]: Resolve comments in documentation (#587) 2024-01-17 10:47:06 +08:00
finetune Update main branch and docs (#585) 2024-01-17 09:46:11 +08:00
model_cards Update main branch and docs (#585) 2024-01-17 09:46:11 +08:00
.gitignore Merge develop to main (#233) 2023-08-24 22:03:04 +08:00
.owners.yml feat(bot): Create .owners.yml for Auto Assign (#176) 2023-08-10 12:11:30 +08:00
.pre-commit-config.yaml doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
.pylintrc doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
.readthedocs.yml [Dev2Main] 20130901 (#261) 2023-09-01 11:00:11 +08:00
LICENSE docs(LICENSE): add license (#125) 2023-07-24 11:59:56 +08:00
README.md [Doc]: Resolve comments in documentation (#587) 2024-01-17 10:47:06 +08:00
README_zh-CN.md [Doc]: Resolve comments in documentation (#587) 2024-01-17 10:47:06 +08:00
requirements.txt Update main branch and docs (#585) 2024-01-17 09:46:11 +08:00
sonar-project.properties initial commit 2023-07-06 12:55:23 +08:00

README.md

InternLM

👋 join us on Discord and WeChat

Introduction

InternLM2 series are released with the following features:

  • 200K Context window: Nearly perfect at finding needles in the haystack with 200K-long context, with leading performance on long-context tasks like LongBench and L-Eval. Try it with LMDeploy for 200K-context inference.

  • Outstanding comprehensive performance: Significantly better than the last generation in all dimensions, especially in reasoning, math, code, chat experience, instruction following, and creative writing, with leading performance among open-source models in similar sizes. In some evaluations, InternLM2-Chat-20B may match or even surpass ChatGPT (GPT-3.5).

  • Code interpreter & Data analysis: With code interpreter, InternLM2-Chat-20B obtains compatible performance with GPT-4 on GSM8K and MATH. InternLM2-Chat also provides data analysis capability.

  • Stronger tool use: Based on better tool utilization-related capabilities in instruction following, tool selection and reflection, InternLM2 can support more kinds of agents and multi-step tool calling for complex tasks. See examples.

News

[2024.01.17] We release InternLM2-7B and InternLM2-20B and their corresponding chat models with stronger capabilities in all dimensions. See model zoo below for download or model cards for more details.

[2023.12.13] InternLM-7B-Chat and InternLM-20B-Chat checkpoints are updated. With an improved finetuning strategy, the new chat models can generate higher quality responses with greater stylistic diversity.

[2023.09.20] InternLM-20B is released with base and chat versions.

Model Zoo

Model Transformers(HF) ModelScope(HF) OpenXLab(HF) Release Date
InternLM2 Chat 20B 🤗internlm/internlm2-chat-20b internlm2-chat-20b Open in OpenXLab 2024-01-17
InternLM2 20B 🤗internlm/internlm2-20b internlm2-20b Open in OpenXLab 2024-01-17
InternLM2 Chat 20B SFT 🤗internlm/internlm2-chat-20b-sft internlm2-chat-20b-sft Open in OpenXLab 2024-01-17
InternLM2 Base 20B 🤗internlm/internlm2-base-20b internlm2-base-20b Open in OpenXLab 2024-01-17
InternLM2 Chat 7B 🤗internlm/internlm2-chat-7b internlm2-chat-7b Open in OpenXLab 2024-01-17
InternLM2 7B 🤗internlm/internlm2-7b internlm2-7b Open in OpenXLab 2024-01-17
InternLM2 Chat 7B SFT 🤗internlm/internlm2-chat-7b-sft internlm2-chat-7b-sft Open in OpenXLab 2024-01-17
InternLM2 Base 7B 🤗internlm/internlm2-base-7b internlm2-base-7b Open in OpenXLab 2024-01-17

Note of Models:

The release of InternLM2 series contains two model sizes: 7B and 20B. 7B models are efficient for research and application and 20B models are more powerful and can support more complex scenarios. For each model size, there are three types of models for different user requirements

  1. InternLM2-Base: Foundation models with high quality and high adaptation flexibility, which serves as a good starting point for downstream deep adaptations.
  2. InternLM2: Optimized in multiple dimensions based on InternLM2-Base, obtaining state-of-the-art performance in evaluation with good language capability. InternLM2 models are recommended for consideration in most applications.
  3. InternLM2-Chat: InternLM2-Chat have gone through SFT and online RLHF based on InternLM2-Base model, for better instruction following, chat experience and function calling, which is recommended for downstream applications. We also released their corresponding SFT version, termed InternLM2 Chat 7/20B SFT, to ease the research for alignment.

Limitations: Although we have made efforts to ensure the safety of the model during the training process and to encourage the model to generate text that complies with ethical and legal requirements, the model may still produce unexpected outputs due to its size and probabilistic generation paradigm. For example, the generated responses may contain biases, discrimination, or other harmful content. Please do not propagate such content. We are not responsible for any consequences resulting from the dissemination of harmful information.

Usages

We briefly show the usages with Transformers, ModelScope, and Web demos. The chat models adopt chatml format to support both chat and agent applications.

Import from Transformers

To load the InternLM2 7B Chat model using Transformers, use the following code:

>>> from transformers import AutoTokenizer, AutoModelForCausalLM
>>> tokenizer = AutoTokenizer.from_pretrained("internlm/internlm2-chat-7b", trust_remote_code=True)
>>> model = AutoModelForCausalLM.from_pretrained("internlm/internlm2-chat-7b", trust_remote_code=True).cuda()
>>> model = model.eval()
>>> response, history = model.chat(tokenizer, "hello", history=[])
>>> print(response)
Hello! How can I help you today?
>>> response, history = model.chat(tokenizer, "please provide three suggestions about time management", history=history)
>>> print(response)

Import from ModelScope

To load the InternLM model using ModelScope, use the following code:

from modelscope import snapshot_download, AutoTokenizer, AutoModelForCausalLM
import torch
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm2-chat-7b')
tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
model = AutoModelForCausalLM.from_pretrained(model_dir,device_map="auto",  trust_remote_code=True,torch_dtype=torch.float16)
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)

Dialogue

You can interact with the InternLM Chat 7B model through a frontend interface by running the following code:

pip install streamlit==1.24.0
pip install transformers==4.30.2
streamlit run ./chat/web_demo.py

The effect is similar to below:

demo

Deployment

We use LMDeploy for fast deployment of InternLM.

With only 4 lines of codes, you can perform internlm2-chat-7b inference after pip install lmdeploy.

from lmdeploy import pipeline
pipe = pipeline("internlm/internlm2-chat-7b")
response = pipe(["Hi, pls intro yourself", "Shanghai is"])
print(response)

Please refer to the guidance for more usages about model deployment. For additional deployment tutorials, feel free to explore here.

Agent

InternLM2-Chat models have excellent tool utilization capabilities and can work with function calls in a zero-shot manner. See more examples in agent session.

Fine-tuning

Please refer to finetune docs for fine-tuning with InternLM.

Note: We have migrated the whole training functionality in this project to InternEvo for easier user experience, which provides efficient pre-training and fine-tuning infra for training InternLM.

Contribution

We appreciate all the contributors for their efforts to improve and enhance InternLM. Community users are highly encouraged to participate in the project. Please refer to the contribution guidelines for instructions on how to contribute to the project.

License

The code is licensed under Apache-2.0, while model weights are fully open for academic research and also allow free commercial usage. To apply for a commercial license, please fill in the application form (English)/申请表(中文). For other questions or collaborations, please contact internlm@pjlab.org.cn.

Citation

@misc{2023internlm,
    title={InternLM: A Multilingual Language Model with Progressively Enhanced Capabilities},
    author={InternLM Team},
    howpublished = {\url{https://github.com/InternLM/InternLM}},
    year={2023}
}