Improve language tag
#1
by
lbourdois
- opened
README.md
CHANGED
@@ -1,118 +1,132 @@
|
|
1 |
-
---
|
2 |
-
library_name: peft
|
3 |
-
base_model: Qwen/Qwen2.5-7B-Instruct
|
4 |
-
pipeline_tag: text-generation
|
5 |
-
license: apache-2.0
|
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 |
-
|
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 |
- PEFT 0.11.1
|
|
|
1 |
+
---
|
2 |
+
library_name: peft
|
3 |
+
base_model: Qwen/Qwen2.5-7B-Instruct
|
4 |
+
pipeline_tag: text-generation
|
5 |
+
license: apache-2.0
|
6 |
+
language:
|
7 |
+
- zho
|
8 |
+
- eng
|
9 |
+
- fra
|
10 |
+
- spa
|
11 |
+
- por
|
12 |
+
- deu
|
13 |
+
- ita
|
14 |
+
- rus
|
15 |
+
- jpn
|
16 |
+
- kor
|
17 |
+
- vie
|
18 |
+
- tha
|
19 |
+
- ara
|
20 |
+
---
|
21 |
+
|
22 |
+
# Model Card for Model ID
|
23 |
+
|
24 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
## Model Details
|
29 |
+
|
30 |
+
### Model Description
|
31 |
+
|
32 |
+
<!-- Provide a longer summary of what this model is. -->
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
- **Developed by: hack337**
|
37 |
+
- **Model type: qwen2**
|
38 |
+
- **Finetuned from model: Qwen/Qwen2.5-7B-Instruct**
|
39 |
+
|
40 |
+
### Model Sources [optional]
|
41 |
+
|
42 |
+
<!-- Provide the basic links for the model. -->
|
43 |
+
|
44 |
+
- **Repository: https://huggingface.co/Hack337/WavGPT-2**
|
45 |
+
- **Demo (WavGPT-1.0): https://huggingface.co/spaces/Hack337/WavGPT**
|
46 |
+
|
47 |
+
## How to Get Started with the Model
|
48 |
+
|
49 |
+
Use the code below to get started with the model.
|
50 |
+
|
51 |
+
```python
|
52 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
53 |
+
device = "cuda" # the device to load the model onto
|
54 |
+
|
55 |
+
model = AutoModelForCausalLM.from_pretrained(
|
56 |
+
"Hack337/WavGPT-2",
|
57 |
+
torch_dtype="auto",
|
58 |
+
device_map="auto"
|
59 |
+
)
|
60 |
+
tokenizer = AutoTokenizer.from_pretrained("Hack337/WavGPT-2")
|
61 |
+
|
62 |
+
prompt = "Give me a short introduction to large language model."
|
63 |
+
messages = [
|
64 |
+
{"role": "system", "content": "Вы очень полезный помощник."},
|
65 |
+
{"role": "user", "content": prompt}
|
66 |
+
]
|
67 |
+
text = tokenizer.apply_chat_template(
|
68 |
+
messages,
|
69 |
+
tokenize=False,
|
70 |
+
add_generation_prompt=True
|
71 |
+
)
|
72 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
73 |
+
|
74 |
+
generated_ids = model.generate(
|
75 |
+
model_inputs.input_ids,
|
76 |
+
max_new_tokens=512
|
77 |
+
)
|
78 |
+
generated_ids = [
|
79 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
80 |
+
]
|
81 |
+
|
82 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
83 |
+
|
84 |
+
```
|
85 |
+
|
86 |
+
Use the code below to get started with the model using NPU.
|
87 |
+
|
88 |
+
```python
|
89 |
+
from transformers import AutoTokenizer, TextStreamer
|
90 |
+
from intel_npu_acceleration_library import NPUModelForCausalLM
|
91 |
+
import torch
|
92 |
+
|
93 |
+
# Load the NPU-optimized model without LoRA
|
94 |
+
model = NPUModelForCausalLM.from_pretrained(
|
95 |
+
"Hack337/WavGPT-2",
|
96 |
+
use_cache=True,
|
97 |
+
dtype=torch.float16 # Use float16 for the NPU
|
98 |
+
).eval()
|
99 |
+
|
100 |
+
# Load the tokenizer
|
101 |
+
tokenizer = AutoTokenizer.from_pretrained("Hack337/WavGPT-2")
|
102 |
+
tokenizer.pad_token_id = tokenizer.eos_token_id
|
103 |
+
streamer = TextStreamer(tokenizer, skip_special_tokens=True)
|
104 |
+
|
105 |
+
# Prompt handling
|
106 |
+
prompt = "Give me a short introduction to large language model."
|
107 |
+
messages = [
|
108 |
+
{"role": "system", "content": "Вы очень полезный помощник."},
|
109 |
+
{"role": "user", "content": prompt}
|
110 |
+
]
|
111 |
+
|
112 |
+
# Convert to a text format compatible with the model
|
113 |
+
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
114 |
+
prefix = tokenizer([text], return_tensors="pt")["input_ids"].to("npu")
|
115 |
+
|
116 |
+
# Generation configuration
|
117 |
+
generation_kwargs = dict(
|
118 |
+
input_ids=prefix,
|
119 |
+
streamer=streamer,
|
120 |
+
do_sample=True,
|
121 |
+
top_k=50,
|
122 |
+
top_p=0.9,
|
123 |
+
max_new_tokens=512,
|
124 |
+
)
|
125 |
+
|
126 |
+
# Run inference on the NPU
|
127 |
+
print("Run inference")
|
128 |
+
_ = model.generate(**generation_kwargs)
|
129 |
+
|
130 |
+
```
|
131 |
+
|
132 |
- PEFT 0.11.1
|