x54-729 commited on
Commit
e013aec
1 Parent(s): d7e8e24

fix eos & update README for tech report

Browse files
Files changed (3) hide show
  1. README.md +166 -2
  2. generation_config.json +4 -2
  3. tokenizer_config.json +1 -1
README.md CHANGED
@@ -20,7 +20,7 @@ license: other
20
 
21
  [![evaluation](https://github.com/InternLM/InternLM/assets/22529082/f80a2a58-5ddf-471a-8da4-32ab65c8fd3b)](https://github.com/internLM/OpenCompass/)
22
 
23
- [💻Github Repo](https://github.com/InternLM/InternLM) • [🤔Reporting Issues](https://github.com/InternLM/InternLM/issues/new)
24
 
25
  </div>
26
 
@@ -95,10 +95,92 @@ for response, history in model.stream_chat(tokenizer, "Hello", history=[]):
95
  length = len(response)
96
  ```
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  ## Open Source License
99
 
100
  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>.
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  ## 简介
103
 
104
  InternLM2 ,即书生·浦语大模型第二代,开源了面向实用场景的200亿参数基础模型与对话模型 (InternLM2-Chat-20B)。模型具有以下特点:
@@ -165,6 +247,88 @@ for response, history in model.stream_chat(tokenizer, "你好", history=[]):
165
  length = len(response)
166
  ```
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  ## 开源许可证
169
 
170
- 本仓库的代码依照 Apache-2.0 协议开源。模型权重对学术研究完全开放,也可申请免费的商业使用授权([申请表](https://wj.qq.com/s2/12725412/f7c1/))。其他问题与合作请联系 <internlm@pjlab.org.cn>。
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  [![evaluation](https://github.com/InternLM/InternLM/assets/22529082/f80a2a58-5ddf-471a-8da4-32ab65c8fd3b)](https://github.com/internLM/OpenCompass/)
22
 
23
+ [💻Github Repo](https://github.com/InternLM/InternLM) • [🤔Reporting Issues](https://github.com/InternLM/InternLM/issues/new) • [📜Technical Report](https://arxiv.org/abs/2403.17297)
24
 
25
  </div>
26
 
 
95
  length = len(response)
96
  ```
97
 
98
+ ## Deployment
99
+
100
+ ### LMDeploy
101
+
102
+ LMDeploy is a toolkit for compressing, deploying, and serving LLM, developed by the MMRazor and MMDeploy teams.
103
+
104
+ ```bash
105
+ pip install lmdeploy
106
+ ```
107
+
108
+ You can run batch inference locally with the following python code:
109
+
110
+ ```python
111
+ import lmdeploy
112
+ pipe = lmdeploy.pipeline("internlm/internlm2-chat-20b")
113
+ response = pipe(["Hi, pls intro yourself", "Shanghai is"])
114
+ print(response)
115
+ ```
116
+
117
+ Or you can launch an OpenAI compatible server with the following command:
118
+
119
+ ```bash
120
+ lmdeploy serve api_server internlm/internlm2-chat-20b --model-name internlm2-chat-20b --server-port 23333
121
+ ```
122
+
123
+ Then you can send a chat request to the server:
124
+
125
+ ```bash
126
+ curl http://localhost:23333/v1/chat/completions \
127
+ -H "Content-Type: application/json" \
128
+ -d '{
129
+ "model": "internlm2-chat-20b",
130
+ "messages": [
131
+ {"role": "system", "content": "You are a helpful assistant."},
132
+ {"role": "user", "content": "Introduce deep learning to me."}
133
+ ]
134
+ }'
135
+ ```
136
+
137
+ Find more details in the [LMDeploy documentation](https://lmdeploy.readthedocs.io/en/latest/)
138
+
139
+ ### vLLM
140
+
141
+ Launch OpenAI compatible server with `vLLM>=0.3.2`:
142
+
143
+ ```bash
144
+ pip install vllm
145
+ ```
146
+
147
+ ```bash
148
+ python -m vllm.entrypoints.openai.api_server --model internlm/internlm2-chat-20b --served-model-name internlm2-chat-20b --trust-remote-code
149
+ ```
150
+
151
+ Then you can send a chat request to the server:
152
+
153
+ ```bash
154
+ curl http://localhost:8000/v1/chat/completions \
155
+ -H "Content-Type: application/json" \
156
+ -d '{
157
+ "model": "internlm2-chat-20b",
158
+ "messages": [
159
+ {"role": "system", "content": "You are a helpful assistant."},
160
+ {"role": "user", "content": "Introduce deep learning to me."}
161
+ ]
162
+ }'
163
+ ```
164
+
165
+ Find more details in the [vLLM documentation](https://docs.vllm.ai/en/latest/index.html)
166
+
167
  ## Open Source License
168
 
169
  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>.
170
 
171
+ ## Citation
172
+
173
+ ```
174
+ @misc{cai2024internlm2,
175
+ title={InternLM2 Technical Report},
176
+ 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},
177
+ year={2024},
178
+ eprint={2403.17297},
179
+ archivePrefix={arXiv},
180
+ primaryClass={cs.CL}
181
+ }
182
+ ```
183
+
184
  ## 简介
185
 
186
  InternLM2 ,即书生·浦语大模型第二代,开源了面向实用场景的200亿参数基础模型与对话模型 (InternLM2-Chat-20B)。模型具有以下特点:
 
247
  length = len(response)
248
  ```
249
 
250
+ ## 部署
251
+
252
+ ### LMDeploy
253
+
254
+ LMDeploy 由 MMDeploy 和 MMRazor 团队联合开发,是涵盖了 LLM 任务的全套轻量化、部署和服务解决方案。
255
+
256
+ ```bash
257
+ pip install lmdeploy
258
+ ```
259
+
260
+ 你可以使用以下 python 代码进行本地批量推理:
261
+
262
+ ```python
263
+ import lmdeploy
264
+ pipe = lmdeploy.pipeline("internlm/internlm2-chat-20b")
265
+ response = pipe(["Hi, pls intro yourself", "Shanghai is"])
266
+ print(response)
267
+ ```
268
+
269
+ 或者你可以使用以下命令启动兼容 OpenAI API 的服务:
270
+
271
+ ```bash
272
+ lmdeploy serve api_server internlm/internlm2-chat-20b --server-port 23333
273
+ ```
274
+
275
+ 然后你可以向服务端发起一个聊天请求:
276
+
277
+ ```bash
278
+ curl http://localhost:23333/v1/chat/completions \
279
+ -H "Content-Type: application/json" \
280
+ -d '{
281
+ "model": "internlm2-chat-20b",
282
+ "messages": [
283
+ {"role": "system", "content": "你是个友善的AI助手。"},
284
+ {"role": "user", "content": "介绍一下深度学习。"}
285
+ ]
286
+ }'
287
+ ```
288
+
289
+ 更多信息请查看 [LMDeploy 文档](https://lmdeploy.readthedocs.io/en/latest/)
290
+
291
+ ### vLLM
292
+
293
+ 使用`vLLM>=0.3.2`启动兼容 OpenAI API 的服务:
294
+
295
+ ```bash
296
+ pip install vllm
297
+ ```
298
+
299
+ ```bash
300
+ python -m vllm.entrypoints.openai.api_server --model internlm/internlm2-chat-20b --trust-remote-code
301
+ ```
302
+
303
+ 然后你可以向服务端发起一个聊天请求:
304
+
305
+ ```bash
306
+ curl http://localhost:8000/v1/chat/completions \
307
+ -H "Content-Type: application/json" \
308
+ -d '{
309
+ "model": "internlm2-chat-20b",
310
+ "messages": [
311
+ {"role": "system", "content": "你是个友善的AI助手。"},
312
+ {"role": "user", "content": "介绍一下深度学习。"}
313
+ ]
314
+ }'
315
+ ```
316
+
317
+ 更多信息请查看 [vLLM 文档](https://docs.vllm.ai/en/latest/index.html)
318
+
319
  ## 开源许可证
320
 
321
+ 本仓库的代码依照 Apache-2.0 协议开源。模型权重对学术研究完全开放,也可申请免费的商业使用授权([申请表](https://wj.qq.com/s2/12725412/f7c1/))。其他问题与合作请联系 <internlm@pjlab.org.cn>。
322
+
323
+ ## 引用
324
+
325
+ ```
326
+ @misc{cai2024internlm2,
327
+ title={InternLM2 Technical Report},
328
+ 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},
329
+ year={2024},
330
+ eprint={2403.17297},
331
+ archivePrefix={arXiv},
332
+ primaryClass={cs.CL}
333
+ }
334
+ ```
generation_config.json CHANGED
@@ -1,7 +1,9 @@
1
  {
2
- "_from_model_config": true,
3
  "bos_token_id": 1,
4
- "eos_token_id": 2,
 
 
 
5
  "pad_token_id": 2,
6
  "transformers_version": "4.37.1"
7
  }
 
1
  {
 
2
  "bos_token_id": 1,
3
+ "eos_token_id": [
4
+ 2,
5
+ 92542
6
+ ],
7
  "pad_token_id": 2,
8
  "transformers_version": "4.37.1"
9
  }
tokenizer_config.json CHANGED
@@ -93,7 +93,7 @@
93
  "chat_template": "{{ bos_token }}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
94
  "clean_up_tokenization_spaces": false,
95
  "decode_with_prefix_space": false,
96
- "eos_token": "<|im_end|>",
97
  "model_max_length": 1000000000000000019884624838656,
98
  "pad_token": "</s>",
99
  "sp_model_kwargs": null,
 
93
  "chat_template": "{{ bos_token }}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
94
  "clean_up_tokenization_spaces": false,
95
  "decode_with_prefix_space": false,
96
+ "eos_token": "</s>",
97
  "model_max_length": 1000000000000000019884624838656,
98
  "pad_token": "</s>",
99
  "sp_model_kwargs": null,