hfl-rc commited on
Commit
a5511ee
·
verified ·
1 Parent(s): 982ab0b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -1
README.md CHANGED
@@ -29,11 +29,56 @@ 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-7B-Instruct-GPTQ-Int4",
52
+ attn_implementation="flash_attention_2",
53
+ device_map="auto"
54
+ )
55
+ processor = AutoProcessor.from_pretrained("hfl/Qwen2.5-VL-7B-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
+ ['这张图片展示了一个标志或图标,包含以下内容:\n\n1. 左侧有一个圆形的图标,里面有一幅插画,描绘了两只羊驼(Alpaca),背景中有树木和一座亭子。\n2. 中间部分用中文写着“中文LLaMA & Alpaca大模型”,意思是“Chinese LLaMA & Alpaca Large Language Models”。\n3. 右侧有一个黑色的数字“3”,旁边有一些电路板的图案。\n\n整体来看,这个标志可能与中文的大型语言模型(LLaMA和Alpaca)有关,可能是一个项目、平台或产品的名称。']
81
+ ```
82
 
83
  ### Disclaimer
84
  - **This is NOT an official model by Qwen. Use at your own risk.**