x54-729 commited on
Commit
8b32993
1 Parent(s): ace525c

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