alicekyting
commited on
Commit
•
06f5614
1
Parent(s):
3fff91c
Update README.md
Browse files
README.md
CHANGED
@@ -5,9 +5,8 @@ tags: []
|
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
## Model Details
|
13 |
|
@@ -17,183 +16,87 @@ tags: []
|
|
17 |
|
18 |
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
|
20 |
-
- **Developed by
|
21 |
-
- **
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
### Model Sources
|
29 |
|
30 |
<!-- Provide the basic links for the model. -->
|
31 |
|
32 |
-
- **Repository:**
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
## Uses
|
37 |
|
38 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
-
|
44 |
-
[More Information Needed]
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
-
|
52 |
-
### Out-of-Scope Use
|
53 |
-
|
54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
|
58 |
## Bias, Risks, and Limitations
|
59 |
|
60 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
-
|
62 |
-
[More Information Needed]
|
63 |
-
|
64 |
-
### Recommendations
|
65 |
-
|
66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
-
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
|
70 |
## How to Get Started with the Model
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
+
This model is a 4-bit quantized version of Qwen2-Audio-7B-Instruct.
|
9 |
+
(https://huggingface.co/Qwen/Qwen2-Audio-7B-Instruct)
|
|
|
10 |
|
11 |
## Model Details
|
12 |
|
|
|
16 |
|
17 |
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
18 |
|
19 |
+
- **Developed:** based on the original Qwen model by Alibaba Cloud
|
20 |
+
- **Model type:** Audio-Text Multimodal Large Language Model
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
### Model Sources
|
23 |
|
24 |
<!-- Provide the basic links for the model. -->
|
25 |
|
26 |
+
- **Repository:** https://huggingface.co/Qwen/Qwen2-Audio-7B-Instruct
|
|
|
|
|
27 |
|
28 |
## Uses
|
29 |
|
30 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
31 |
+
The 4-bit quantization allows for reduced memory usage and potentially faster inference times, especially on hardware with limited resources.
|
32 |
+
However, there might be a slight degradation in performance compared to the full-precision model.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
## Bias, Risks, and Limitations
|
35 |
|
36 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
37 |
+
GPU is needed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
## How to Get Started with the Model
|
40 |
|
41 |
+
Refer to the Qwen2-Audio-7B-Instruct model page on Hugging Face for usage examples and code snippets.
|
42 |
+
|
43 |
+
To use this model, you'll need to have the transformers library installed, along with bitsandbytes for 4-bit quantization support.
|
44 |
+
|
45 |
+
Here's a basic example of how to load and use the model:
|
46 |
+
|
47 |
+
```python
|
48 |
+
import torch
|
49 |
+
from io import BytesIO
|
50 |
+
from urllib.request import urlopen
|
51 |
+
import librosa
|
52 |
+
from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor, BitsAndBytesConfig
|
53 |
+
|
54 |
+
processor = AutoProcessor.from_pretrained("alicekyting/Qwen2-Audio-7B-Instruct-4bit")
|
55 |
+
bnb_config = BitsAndBytesConfig(
|
56 |
+
load_in_4bit=True,
|
57 |
+
bnb_4bit_compute_dtype=torch.float16
|
58 |
+
)
|
59 |
+
model = Qwen2AudioForConditionalGeneration.from_pretrained(
|
60 |
+
"alicekyting/Qwen2-Audio-7B-Instruct-4bit",
|
61 |
+
device_map="auto",
|
62 |
+
quantization_config=bnb_config
|
63 |
+
)
|
64 |
+
|
65 |
+
conversation = [
|
66 |
+
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
67 |
+
{"role": "user", "content": [
|
68 |
+
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/glass-breaking-151256.mp3"},
|
69 |
+
{"type": "text", "text": "What's that sound?"},
|
70 |
+
]},
|
71 |
+
{"role": "assistant", "content": "It is the sound of glass shattering."},
|
72 |
+
{"role": "user", "content": [
|
73 |
+
{"type": "text", "text": "What can you do when you hear that?"},
|
74 |
+
]},
|
75 |
+
{"role": "assistant", "content": "Stay alert and cautious, and check if anyone is hurt or if there is any damage to property."},
|
76 |
+
{"role": "user", "content": [
|
77 |
+
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/1272-128104-0000.flac"},
|
78 |
+
{"type": "text", "text": "What does the person say?"},
|
79 |
+
]},
|
80 |
+
]
|
81 |
+
text = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
|
82 |
+
audios = []
|
83 |
+
for message in conversation:
|
84 |
+
if isinstance(message["content"], list):
|
85 |
+
for ele in message["content"]:
|
86 |
+
if ele["type"] == "audio":
|
87 |
+
audios.append(
|
88 |
+
librosa.load(
|
89 |
+
BytesIO(urlopen(ele['audio_url']).read()),
|
90 |
+
sr=processor.feature_extractor.sampling_rate,
|
91 |
+
mono=True
|
92 |
+
)[0]
|
93 |
+
)
|
94 |
+
|
95 |
+
inputs = processor(text=text, audios=audios, return_tensors="pt", padding=True)
|
96 |
+
inputs = {k: v.to(model.device) for k, v in inputs.items()}
|
97 |
+
|
98 |
+
generate_ids = model.generate(**inputs, max_length=256)
|
99 |
+
generate_ids = generate_ids[:, inputs['input_ids'].size(1):]
|
100 |
+
|
101 |
+
response = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
102 |
+
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|