munish0838 commited on
Commit
b2fec6f
·
verified ·
1 Parent(s): 6fc6e4b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +165 -0
README.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-generation
3
+ license: other
4
+ base_model: internlm/internlm2-chat-7b
5
+ ---
6
+ # InternLM -Chat-7B-GGUF
7
+ This is quantized version of [internlm/internlm2-chat-7b]() created using llama.cpp
8
+
9
+ # Model Description
10
+ <div align="center">
11
+
12
+ <img src="https://github.com/InternLM/InternLM/assets/22529082/b9788105-8892-4398-8b47-b513a292378e" width="200"/>
13
+ <div>&nbsp;</div>
14
+ <div align="center">
15
+ <b><font size="5">InternLM</font></b>
16
+ <sup>
17
+ <a href="https://internlm.intern-ai.org.cn/">
18
+ <i><font size="4">HOT</font></i>
19
+ </a>
20
+ </sup>
21
+ <div>&nbsp;</div>
22
+ </div>
23
+ </div>
24
+
25
+ ## Introduction
26
+
27
+ InternLM2 has open-sourced a 7 billion parameter base model and a chat model tailored for practical scenarios. The model has the following characteristics:
28
+
29
+ - **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](https://github.com/InternLM/lmdeploy) for 200K-context inference.
30
+
31
+ - **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).
32
+
33
+ - **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.
34
+
35
+ - **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](https://github.com/InternLM/lagent).
36
+
37
+ ## InternLM2-Chat-7B
38
+
39
+ ### Performance Evaluation
40
+
41
+ We conducted a comprehensive evaluation of InternLM using the open-source evaluation tool [OpenCompass](https://github.com/internLM/OpenCompass/). The evaluation covered five dimensions of capabilities: disciplinary competence, language competence, knowledge competence, inference competence, and comprehension competence. Here are some of the evaluation results, and you can visit the [OpenCompass leaderboard](https://opencompass.org.cn/rank) for more evaluation results.
42
+
43
+ | Dataset\Models | InternLM2-7B | InternLM2-Chat-7B | InternLM2-20B | InternLM2-Chat-20B | ChatGPT | GPT-4 |
44
+ | --- | --- | --- | --- | --- | --- | --- |
45
+ | MMLU | 65.8 | 63.7 | 67.7 | 66.5 | 69.1 | 83.0 |
46
+ | AGIEval | 49.9 | 47.2 | 53.0 | 50.3 | 39.9 | 55.1 |
47
+ | BBH | 65.0 | 61.2 | 72.1 | 68.3 | 70.1 | 86.7 |
48
+ | GSM8K | 70.8 | 70.7 | 76.1 | 79.6 | 78.2 | 91.4 |
49
+ | MATH | 20.2 | 23.0 | 25.5 | 31.9 | 28.0 | 45.8 |
50
+ | HumanEval | 43.3 | 59.8 | 48.8 | 67.1 | 73.2 | 74.4 |
51
+ | MBPP(Sanitized) | 51.8 | 51.4 | 63.0 | 65.8 | 78.9 | 79.0 |
52
+
53
+ - The evaluation results were obtained from [OpenCompass](https://github.com/internLM/OpenCompass/) (some data marked with *, which means come from the original papers), and evaluation configuration can be found in the configuration files provided by [OpenCompass](https://github.com/internLM/OpenCompass/).
54
+ - The evaluation data may have numerical differences due to the version iteration of [OpenCompass](https://github.com/internLM/OpenCompass/), so please refer to the latest evaluation results of [OpenCompass](https://github.com/internLM/OpenCompass/).
55
+
56
+
57
+ **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.
58
+
59
+ ### Import from Transformers
60
+
61
+ To load the InternLM2 7B Chat model using Transformers, use the following code:
62
+
63
+ ```python
64
+ import torch
65
+ from transformers import AutoTokenizer, AutoModelForCausalLM
66
+ tokenizer = AutoTokenizer.from_pretrained("internlm/internlm2-chat-7b", trust_remote_code=True)
67
+ # Set `torch_dtype=torch.float16` to load model in float16, otherwise it will be loaded as float32 and cause OOM Error.
68
+ model = AutoModelForCausalLM.from_pretrained("internlm/internlm2-chat-7b", torch_dtype=torch.float16, trust_remote_code=True).cuda()
69
+ model = model.eval()
70
+ response, history = model.chat(tokenizer, "hello", history=[])
71
+ print(response)
72
+ # Hello! How can I help you today?
73
+ response, history = model.chat(tokenizer, "please provide three suggestions about time management", history=history)
74
+ print(response)
75
+ ```
76
+
77
+ The responses can be streamed using `stream_chat`:
78
+
79
+ ```python
80
+ import torch
81
+ from transformers import AutoModelForCausalLM, AutoTokenizer
82
+
83
+ model_path = "internlm/internlm2-chat-7b"
84
+ model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16, trust_remote_code=True).cuda()
85
+ tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
86
+
87
+ model = model.eval()
88
+ length = 0
89
+ for response, history in model.stream_chat(tokenizer, "Hello", history=[]):
90
+ print(response[length:], flush=True, end="")
91
+ length = len(response)
92
+ ```
93
+
94
+ ## Deployment
95
+
96
+ ### LMDeploy
97
+
98
+ LMDeploy is a toolkit for compressing, deploying, and serving LLM, developed by the MMRazor and MMDeploy teams.
99
+
100
+ ```bash
101
+ pip install lmdeploy
102
+ ```
103
+
104
+ You can run batch inference locally with the following python code:
105
+
106
+ ```python
107
+ import lmdeploy
108
+ pipe = lmdeploy.pipeline("internlm/internlm2-chat-7b")
109
+ response = pipe(["Hi, pls intro yourself", "Shanghai is"])
110
+ print(response)
111
+ ```
112
+
113
+ Or you can launch an OpenAI compatible server with the following command:
114
+
115
+ ```bash
116
+ lmdeploy serve api_server internlm/internlm2-chat-7b --model-name internlm2-chat-7b --server-port 23333
117
+ ```
118
+
119
+ Then you can send a chat request to the server:
120
+
121
+ ```bash
122
+ curl http://localhost:23333/v1/chat/completions \
123
+ -H "Content-Type: application/json" \
124
+ -d '{
125
+ "model": "internlm2-chat-7b",
126
+ "messages": [
127
+ {"role": "system", "content": "You are a helpful assistant."},
128
+ {"role": "user", "content": "Introduce deep learning to me."}
129
+ ]
130
+ }'
131
+ ```
132
+
133
+ Find more details in the [LMDeploy documentation](https://lmdeploy.readthedocs.io/en/latest/)
134
+
135
+ ### vLLM
136
+
137
+ Launch OpenAI compatible server with `vLLM>=0.3.2`:
138
+
139
+ ```bash
140
+ pip install vllm
141
+ ```
142
+
143
+ ```bash
144
+ python -m vllm.entrypoints.openai.api_server --model internlm/internlm2-chat-7b --served-model-name internlm2-chat-7b --trust-remote-code
145
+ ```
146
+
147
+ Then you can send a chat request to the server:
148
+
149
+ ```bash
150
+ curl http://localhost:8000/v1/chat/completions \
151
+ -H "Content-Type: application/json" \
152
+ -d '{
153
+ "model": "internlm2-chat-7b",
154
+ "messages": [
155
+ {"role": "system", "content": "You are a helpful assistant."},
156
+ {"role": "user", "content": "Introduce deep learning to me."}
157
+ ]
158
+ }'
159
+ ```
160
+
161
+ Find more details in the [vLLM documentation](https://docs.vllm.ai/en/latest/index.html)
162
+
163
+ ## Open Source License
164
+
165
+ 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)](https://wj.qq.com/s2/12727483/5dba/)/[申请表(中文)](https://wj.qq.com/s2/12725412/f7c1/). For other questions or collaborations, please contact <internlm@pjlab.org.cn>.