czczup commited on
Commit
b08541a
1 Parent(s): 6d68017

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +192 -5
README.md CHANGED
@@ -53,12 +53,12 @@ InternVL 2.0 is a multimodal large language model series, featuring models of va
53
 
54
  - It is important to mention that the MMVet scores we report are evaluated using GPT-4-0613 as the judge model. Different versions of GPT-4 can lead to significant variations in the scores for this dataset. For instance, using GPT-4-Turbo would result in significantly lower scores.
55
 
56
- 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.
57
-
58
  ### Video Benchmarks
59
 
60
  TBD
61
 
 
 
62
  ## Quick Start
63
 
64
  We provide an example code to run InternVL2-8B using `transformers`.
@@ -296,22 +296,101 @@ LMDeploy is a toolkit for compressing, deploying, and serving LLM, developed by
296
  pip install lmdeploy
297
  ```
298
 
299
- You can run batch inference locally with the following python code:
 
 
300
 
301
  ```python
 
302
  from lmdeploy.vl import load_image
303
- from lmdeploy import ChatTemplateConfig, pipeline
304
 
305
  model = 'OpenGVLab/InternVL2-8B'
306
  system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
307
  image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
308
  chat_template_config = ChatTemplateConfig('internlm2-chat')
309
  chat_template_config.meta_instruction = system_prompt
310
- pipe = pipeline(model, chat_template_config=chat_template_config)
 
311
  response = pipe(('describe this image', image))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  print(response)
313
  ```
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  ## License
316
 
317
  This project is released under the MIT license, while InternLM is licensed under the Apache-2.0 license.
@@ -379,8 +458,116 @@ InternVL 2.0 是一个多模态大语言模型系列,包含各种规模的模
379
 
380
  - 需要提到的是,我们报告的 MMVet 分数是使用 GPT-4-0613 作为评判模型评估的。不同版本的 GPT-4 会导致该数据集分数的显著变化。例如,使用 GPT-4-Turbo 会导致分数显著降低。
381
 
 
 
 
 
382
  限制:尽管在训练过程中我们非常注重模型的安全性,尽力促使模型输出符合伦理和法律要求的文本,但受限于模型大小以及概率生成范式,模型可能会产生各种不符合预期的输出,例如回复内容包含偏见、歧视等有害内容,请勿传播这些内容。由于传播不良信息导致的任何后果,本项目不承担责任。
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  ## 开源许可证
385
 
386
  该项目采用 MIT 许可证发布,而 InternLM 则采用 Apache-2.0 许可证。
 
53
 
54
  - It is important to mention that the MMVet scores we report are evaluated using GPT-4-0613 as the judge model. Different versions of GPT-4 can lead to significant variations in the scores for this dataset. For instance, using GPT-4-Turbo would result in significantly lower scores.
55
 
 
 
56
  ### Video Benchmarks
57
 
58
  TBD
59
 
60
+ 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.
61
+
62
  ## Quick Start
63
 
64
  We provide an example code to run InternVL2-8B using `transformers`.
 
296
  pip install lmdeploy
297
  ```
298
 
299
+ LMDeploy abstracts the complex inference process of multi-modal Vision-Language Models (VLM) into an easy-to-use pipeline, similar to the Large Language Model (LLM) inference pipeline.
300
+
301
+ #### A 'Hello, world' example
302
 
303
  ```python
304
+ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
305
  from lmdeploy.vl import load_image
 
306
 
307
  model = 'OpenGVLab/InternVL2-8B'
308
  system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
309
  image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
310
  chat_template_config = ChatTemplateConfig('internlm2-chat')
311
  chat_template_config.meta_instruction = system_prompt
312
+ pipe = pipeline(model, chat_template_config=chat_template_config,
313
+ backend_config=TurbomindEngineConfig(session_len=8192))
314
  response = pipe(('describe this image', image))
315
+ print(response.text)
316
+ ```
317
+
318
+ If `ImportError` occurs while executing this case, please install the required dependency packages as prompted.
319
+
320
+ #### Multi-images inference
321
+
322
+ When dealing with multiple images, you can put them all in one list. Keep in mind that multiple images will lead to a higher number of input tokens, and as a result, the size of the context window typically needs to be increased.
323
+
324
+ ```python
325
+ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
326
+ from lmdeploy.vl import load_image
327
+ from lmdeploy.vl.constants import IMAGE_TOKEN
328
+
329
+ model = 'OpenGVLab/InternVL2-8B'
330
+ system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
331
+ chat_template_config = ChatTemplateConfig('internlm2-chat')
332
+ chat_template_config.meta_instruction = system_prompt
333
+ pipe = pipeline(model, chat_template_config=chat_template_config,
334
+ backend_config=TurbomindEngineConfig(session_len=8192))
335
+
336
+ image_urls=[
337
+ 'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg',
338
+ 'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg'
339
+ ]
340
+
341
+ images = [load_image(img_url) for img_url in image_urls]
342
+ # Numbering images improves multi-image conversations
343
+ response = pipe((f'Image-1: {IMAGE_TOKEN} Image-2: {IMAGE_TOKEN}\ndescribe these two images', images))
344
+ print(response.text)
345
+ ```
346
+
347
+ #### Batch prompts inference
348
+
349
+ Conducting inference with batch prompts is quite straightforward; just place them within a list structure:
350
+
351
+ ```python
352
+ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
353
+ from lmdeploy.vl import load_image
354
+
355
+ model = 'OpenGVLab/InternVL2-8B'
356
+ system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科���进步和产业发展。'
357
+ chat_template_config = ChatTemplateConfig('internlm2-chat')
358
+ chat_template_config.meta_instruction = system_prompt
359
+ pipe = pipeline(model, chat_template_config=chat_template_config,
360
+ backend_config=TurbomindEngineConfig(session_len=8192))
361
+
362
+ image_urls=[
363
+ "https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg",
364
+ "https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg"
365
+ ]
366
+ prompts = [('describe this image', load_image(img_url)) for img_url in image_urls]
367
+ response = pipe(prompts)
368
  print(response)
369
  ```
370
 
371
+ #### Multi-turn conversation
372
+
373
+ There are two ways to do the multi-turn conversations with the pipeline. One is to construct messages according to the format of OpenAI and use above introduced method, the other is to use the `pipeline.chat` interface.
374
+
375
+ ```python
376
+ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig, GenerationConfig
377
+ from lmdeploy.vl import load_image
378
+
379
+ model = 'OpenGVLab/InternVL2-8B'
380
+ system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
381
+ chat_template_config = ChatTemplateConfig('internlm2-chat')
382
+ chat_template_config.meta_instruction = system_prompt
383
+ pipe = pipeline(model, chat_template_config=chat_template_config,
384
+ backend_config=TurbomindEngineConfig(session_len=8192))
385
+
386
+ image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg')
387
+ gen_config = GenerationConfig(top_k=40, top_p=0.8, temperature=0.8)
388
+ sess = pipe.chat(('describe this image', image), gen_config=gen_config)
389
+ print(sess.response.text)
390
+ sess = pipe.chat('What is the woman doing?', session=sess, gen_config=gen_config)
391
+ print(sess.response.text)
392
+ ```
393
+
394
  ## License
395
 
396
  This project is released under the MIT license, while InternLM is licensed under the Apache-2.0 license.
 
458
 
459
  - 需要提到的是,我们报告的 MMVet 分数是使用 GPT-4-0613 作为评判模型评估的。不同版本的 GPT-4 会导致该数据集分数的显著变化。例如,使用 GPT-4-Turbo 会导致分数显著降低。
460
 
461
+ ### 视频相关评测
462
+
463
+ TBD
464
+
465
  限制:尽管在训练过程中我们非常注重模型的安全性,尽力促使模型输出符合伦理和法律要求的文本,但受限于模型大小以及概率生成范式,模型可能会产生各种不符合预期的输出,例如回复内容包含偏见、歧视等有害内容,请勿传播这些内容。由于传播不良信息导致的任何后果,本项目不承担责任。
466
 
467
+ ## 部署
468
+
469
+ ### LMDeploy
470
+
471
+ LMDeploy 是由 MMRazor 和 MMDeploy 团队开发的用于压缩、部署和服务大语言模型(LLM)的工具包。
472
+
473
+ ```sh
474
+ pip install lmdeploy
475
+ ```
476
+
477
+ LMDeploy 将多模态视觉-语言模型(VLM)的复杂推理过程抽象为一个易于使用的管道,类似于大语言模型(LLM)的推理管道。
478
+
479
+ #### 一个“你好,世界”示例
480
+
481
+ ```python
482
+ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
483
+ from lmdeploy.vl import load_image
484
+
485
+ model = 'OpenGVLab/InternVL2-8B'
486
+ system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
487
+ image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
488
+ chat_template_config = ChatTemplateConfig('internlm2-chat')
489
+ chat_template_config.meta_instruction = system_prompt
490
+ pipe = pipeline(model, chat_template_config=chat_template_config,
491
+ backend_config=TurbomindEngineConfig(session_len=8192))
492
+ response = pipe(('describe this image', image))
493
+ print(response.text)
494
+ ```
495
+
496
+ 如果在执行此示例时出现 `ImportError`,请按照提示安装所需的依赖包。
497
+
498
+ #### 多图像推理
499
+
500
+ 在处理多张图像时,可以将它们全部放入一个列表中。请注意,多张图像会导致输入 token 数量增加,因此通常需要增加上下文窗口的大小。
501
+
502
+ ```python
503
+ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
504
+ from lmdeploy.vl import load_image
505
+ from lmdeploy.vl.constants import IMAGE_TOKEN
506
+
507
+ model = 'OpenGVLab/InternVL2-8B'
508
+ system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
509
+ chat_template_config = ChatTemplateConfig('internlm2-chat')
510
+ chat_template_config.meta_instruction = system_prompt
511
+ pipe = pipeline(model, chat_template_config=chat_template_config,
512
+ backend_config=TurbomindEngineConfig(session_len=8192))
513
+
514
+ image_urls=[
515
+ 'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg',
516
+ 'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg'
517
+ ]
518
+
519
+ images = [load_image(img_url) for img_url in image_urls]
520
+ response = pipe((f'Image-1: {IMAGE_TOKEN} Image-2: {IMAGE_TOKEN}\ndescribe these two images', images))
521
+ print(response.text)
522
+ ```
523
+
524
+ #### 批量Prompt推理
525
+
526
+ 使用批量Prompt进行推理非常简单;只需将它们放在一个列表结构中:
527
+
528
+ ```python
529
+ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
530
+ from lmdeploy.vl import load_image
531
+
532
+ model = 'OpenGVLab/InternVL2-8B'
533
+ system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
534
+ chat_template_config = ChatTemplateConfig('internlm2-chat')
535
+ chat_template_config.meta_instruction = system_prompt
536
+ pipe = pipeline(model, chat_template_config=chat_template_config,
537
+ backend_config=TurbomindEngineConfig(session_len=8192))
538
+
539
+ image_urls=[
540
+ "https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg",
541
+ "https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg"
542
+ ]
543
+ prompts = [('describe this image', load_image(img_url)) for img_url in image_urls]
544
+ response = pipe(prompts)
545
+ print(response)
546
+ ```
547
+
548
+ #### 多轮对话
549
+
550
+ 使用管道进行多轮对话有两种方法。一种是根据 OpenAI 的格式构建消息并使用上述方法,另一种是使用 `pipeline.chat` 接口。
551
+
552
+ ```python
553
+ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig, GenerationConfig
554
+ from lmdeploy.vl import load_image
555
+
556
+ model = 'OpenGVLab/InternVL2-8B'
557
+ system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态基础模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
558
+ chat_template_config = ChatTemplateConfig('internlm2-chat')
559
+ chat_template_config.meta_instruction = system_prompt
560
+ pipe = pipeline(model, chat_template_config=chat_template_config,
561
+ backend_config=TurbomindEngineConfig(session_len=8192))
562
+
563
+ image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg')
564
+ gen_config = GenerationConfig(top_k=40, top_p=0.8, temperature=0.8)
565
+ sess = pipe.chat(('describe this image', image), gen_config=gen_config)
566
+ print(sess.response.text)
567
+ sess = pipe.chat('What is the woman doing?', session=sess, gen_config=gen_config)
568
+ print(sess.response.text)
569
+ ```
570
+
571
  ## 开源许可证
572
 
573
  该项目采用 MIT 许可证发布,而 InternLM 则采用 Apache-2.0 许可证。