hfl-rc commited on
Commit
b3dc86c
·
verified ·
1 Parent(s): ba7cc62

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -1
README.md CHANGED
@@ -29,11 +29,57 @@ The model is compatible with the latest `transformers` library (which can run no
29
  | **Qwen2.5-VL-7B-Instruct-GPTQ-Int4** | 6.5 GB | 81.48 | 845 |
30
 
31
 
32
- ### Note
33
 
34
  - Evaluations are performed using [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval) with default setting.
35
  - GPTQ models are computationally more effective (fewer VRAM usage, faster inference speed) than AWQ series in these evaluations.
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  ### Disclaimer
39
  - **This is NOT an official model by Qwen. Use at your own risk.**
 
29
  | **Qwen2.5-VL-7B-Instruct-GPTQ-Int4** | 6.5 GB | 81.48 | 845 |
30
 
31
 
32
+ #### Note
33
 
34
  - Evaluations are performed using [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval) with default setting.
35
  - GPTQ models are computationally more effective (fewer VRAM usage, faster inference speed) than AWQ series in these evaluations.
36
 
37
+ ### Quick Tour
38
+
39
+ Install the required libraries:
40
+ ```
41
+ pip install git+https://github.com/huggingface/transformers accelerate qwen-vl-utils
42
+ pip install gptqmodel tokenicer # optional
43
+ ```
44
+
45
+ Sample code:
46
+ ```python
47
+ from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
48
+ from qwen_vl_utils import process_vision_info
49
+
50
+ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
51
+ "hfl/Qwen2.5-VL-3B-Instruct-GPTQ-Int4",
52
+ attn_implementation="flash_attention_2",
53
+ device_map="auto"
54
+ )
55
+ processor = AutoProcessor.from_pretrained("hfl/Qwen2.5-VL-3B-Instruct-GPTQ-Int4")
56
+
57
+ messages = [{
58
+ "role": "user",
59
+ "content": [
60
+ {"type": "image", "image": "https://raw.githubusercontent.com/ymcui/Chinese-LLaMA-Alpaca-3/refs/heads/main/pics/banner.png"},
61
+ {"type": "text", "text": "请你描述一下这张图片。"},
62
+ ],
63
+ }]
64
+
65
+ text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
66
+ image_inputs, video_inputs = process_vision_info(messages)
67
+ inputs = processor(
68
+ text=[text], images=image_inputs, videos=video_inputs,
69
+ padding=True, return_tensors="pt",
70
+ ).to("cuda")
71
+
72
+ generated_ids = model.generate(**inputs, max_new_tokens=512)
73
+ generated_ids_trimmed = [out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)]
74
+ output_text = processor.batch_decode(generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False)
75
+ print(output_text)
76
+ ```
77
+
78
+ Results:
79
+ ```
80
+ ['这张图片展示了一个中文和英文的标志,内容为“中文LLaMA & Alpaca大模型”和“Chinese LLaMA & Alpaca Large Language Models”。标志左侧有两个卡通形象,一个是红色围巾的羊驼,另一个是白色毛发的羊驼,背景是一个绿色的草地和一座红色屋顶的建筑。标志右侧有一个数字3,旁边有一些电路图案。整体设计简洁明了,使用了明亮的颜色和可爱的卡通形象来吸引注意力。']
81
+ ```
82
+
83
 
84
  ### Disclaimer
85
  - **This is NOT an official model by Qwen. Use at your own risk.**