x54-729 RangiLyu commited on
Commit
d5fadd8
1 Parent(s): a928a63

Update generation_config.json and fix eos token id (#14)

Browse files

- Update generation_config.json and fix eos token id (5486307e394730c9fca8b4f2ea6ee3d8c08fc32d)
- update tokenizer and readme (f47004506c78b5107b33b4ed3005a30965531049)
- update readme (292bc88c12a57d7096c5519c4a046b19a3b811c0)
- update readme (dadcf02defc87934f18f5dcf6f107c0620bb7176)


Co-authored-by: RangiLyu <RangiLyu@users.noreply.huggingface.co>

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