File size: 2,541 Bytes
628ca72
 
35b5d92
 
 
 
 
628ca72
 
 
 
 
455cc1c
628ca72
 
 
 
 
e8e3d96
35b5d92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8e3d96
628ca72
 
 
 
 
 
 
35b5d92
628ca72
 
 
 
 
e8e3d96
 
 
 
455cc1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
library_name: transformers
datasets:
- Joctor/cn_bokete_oogiri_caption
base_model:
- Qwen/Qwen2-VL-7B-Instruct
pipeline_tag: image-to-text
---

# Model Card for Model ID

<!-- Provide a quick summary of what the model is/does. -->
AI大喜利,简介 https://www.gcores.com/articles/188405

## How to Get Started with the Model

Use the code below to get started with the model.

```python
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
from qwen_vl_utils import process_vision_info

model_id = "Joctor/qwen2-vl-7b-instruct-ogiri"

# default: Load the model on the available device(s)
model = Qwen2VLForConditionalGeneration.from_pretrained(
    model_id, torch_dtype="auto", device_map="auto"
)

# default processer
processor = AutoProcessor.from_pretrained(model_id)

messages = [
    {
        "role": "user",
        "content": [
            {
                "type": "image",
                "image": "path/to/image",
            },
            {"type": "text", "text": "根据图片给出有趣巧妙的回答"},
        ],
    }
]

# Preparation for inference
text = processor.apply_chat_template(
    messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
    text=[text],
    images=image_inputs,
    videos=video_inputs,
    padding=True,
    return_tensors="pt",
)
inputs = inputs.to("cuda")

# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
    out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
    generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
```

## Training Details

### Training Data

<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->

https://huggingface.co/datasets/Joctor/cn_bokete_oogiri_caption

### Training Procedure

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

基础模型:qwen2vl  
微调方式:数据量充足,采用SFT微调  
微调参数:max_length=1024(短就是好!), num_train_epochs=1, per_device_train_batch_size=1, gradient_accumulation_steps=1  
训练设备:10 * 4090D  
训练时长:22小时