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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-nc-4.0
|
3 |
+
datasets:
|
4 |
+
- MBZUAI/Bactrian-X
|
5 |
+
language:
|
6 |
+
- id
|
7 |
+
- en
|
8 |
+
tags:
|
9 |
+
- qlora
|
10 |
+
- wizardlm
|
11 |
+
- uncensored
|
12 |
+
- instruct
|
13 |
+
- alpaca
|
14 |
---
|
15 |
+
# DukunLM - Indonesian Language Model 🧙♂️
|
16 |
+
|
17 |
+
🚀 Welcome to the DukunLM repository! DukunLM is an open-source language model trained to generate Indonesian text using the power of AI. DukunLM, meaning "WizardLM" in Indonesian, is here to revolutionize language generation 🌟
|
18 |
+
|
19 |
+
## Model Details
|
20 |
+
|
21 |
+
| Name Model | Parameters | Demo | Base Model | Dataset | Prompt Format | Fine Tune Method |
|
22 |
+
|----------------------------------------------------------------------------------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|--------------------------------------------|
|
23 |
+
| [DukunLM-Uncensored-7B](https://huggingface.co/azale-ai/DukunLM-Uncensored-7B) | 7B | [](https://colab.research.google.com/drive/1WYhhfvFzQukGzEqWHu3gKmigStJTjWxV?usp=sharing) | [ehartford/WizardLM-7B-V1.0-Uncensored](https://huggingface.co/ehartford/WizardLM-7B-V1.0-Uncensored) | [MBZUAI/Bactrian-X (Indonesian subset)](https://huggingface.co/datasets/MBZUAI/Bactrian-X/viewer/id/train) | [Alpaca](https://github.com/tatsu-lab/stanford_alpaca) | [QLoRA](https://github.com/artidoro/qlora) |
|
24 |
+
| [DukunLM-Uncensored-13B](https://huggingface.co/azale-ai/DukunLM-Uncensored-13B) | 13B | [](https://colab.research.google.com/drive/1WYhhfvFzQukGzEqWHu3gKmigStJTjWxV?usp=sharing) | [ehartford/WizardLM-7B-V1.0-Uncensored](https://huggingface.co/ehartford/WizardLM-13B-V1.0-Uncensored) | [MBZUAI/Bactrian-X (Indonesian subset)](https://huggingface.co/datasets/MBZUAI/Bactrian-X/viewer/id/train) | [Alpaca](https://github.com/tatsu-lab/stanford_alpaca) | [QLoRA](https://github.com/artidoro/qlora) |
|
25 |
+
|
26 |
+
⚠️ **Warning**: DukunLM is an uncensored model without filters or alignment. Please use it responsibly as it may contain errors, cultural biases, and potentially offensive content. ⚠️
|
27 |
+
|
28 |
+
## Installation
|
29 |
+
|
30 |
+
To use DukunLM, ensure that PyTorch has been installed and that you have an Nvidia GPU (or use Google Colab). After that you need to install the required dependencies:
|
31 |
+
```bash
|
32 |
+
pip install -U git+https://github.com/huggingface/transformers.git
|
33 |
+
pip install -U git+https://github.com/huggingface/peft.git
|
34 |
+
pip install -U git+https://github.com/huggingface/accelerate.git
|
35 |
+
pip install -U bitsandbytes==0.39.0
|
36 |
+
pip install -U einops==0.6.1
|
37 |
+
pip install -U sentencepiece
|
38 |
+
```
|
39 |
+
|
40 |
+
## How to Use
|
41 |
+
|
42 |
+
### Normal Model
|
43 |
+
|
44 |
+
#### Stream Output
|
45 |
+
|
46 |
+
```python
|
47 |
+
import torch
|
48 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
49 |
+
|
50 |
+
model = AutoModelForCausalLM.from_pretrained("azale-ai/DukunLM-7B-V1.0-Uncensored")
|
51 |
+
tokenizer = AutoTokenizer.from_pretrained("azale-ai/DukunLM-7B-V1.0-Uncensored")
|
52 |
+
streamer = TextStreamer(tokenizer)
|
53 |
+
|
54 |
+
instruction_prompt = "Jelaskan mengapa air penting bagi kehidupan manusia."
|
55 |
+
input_prompt = ""
|
56 |
+
|
57 |
+
if not input_prompt:
|
58 |
+
prompt = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
59 |
+
|
60 |
+
### Instruction:
|
61 |
+
{instruction}
|
62 |
+
|
63 |
+
### Response:
|
64 |
+
"""
|
65 |
+
prompt = prompt.format(instruction=instruction_prompt)
|
66 |
+
|
67 |
+
else:
|
68 |
+
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
69 |
+
|
70 |
+
### Instruction:
|
71 |
+
{instruction}
|
72 |
+
|
73 |
+
### Input:
|
74 |
+
{input}
|
75 |
+
|
76 |
+
### Response:
|
77 |
+
"""
|
78 |
+
prompt = prompt.format(instruction=instruction_prompt, input=input_prompt)
|
79 |
+
|
80 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
81 |
+
_ = model.generate(
|
82 |
+
inputs=inputs.input_ids,
|
83 |
+
streamer=streamer,
|
84 |
+
pad_token_id=tokenizer.pad_token_id,
|
85 |
+
eos_token_id=tokenizer.eos_token_id,
|
86 |
+
max_length=2048, temperature=0.7,
|
87 |
+
do_sample=True, top_k=4, top_p=0.95
|
88 |
+
)
|
89 |
+
```
|
90 |
+
|
91 |
+
#### No Stream Output
|
92 |
+
|
93 |
+
```python
|
94 |
+
import torch
|
95 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
96 |
+
|
97 |
+
model = AutoModelForCausalLM.from_pretrained("azale-ai/DukunLM-7B-V1.0-Uncensored")
|
98 |
+
tokenizer = AutoTokenizer.from_pretrained("azale-ai/DukunLM-7B-V1.0-Uncensored")
|
99 |
+
|
100 |
+
instruction_prompt = "Jelaskan mengapa air penting bagi kehidupan manusia."
|
101 |
+
input_prompt = ""
|
102 |
+
|
103 |
+
if not input_prompt:
|
104 |
+
prompt = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
105 |
+
|
106 |
+
### Instruction:
|
107 |
+
{instruction}
|
108 |
+
|
109 |
+
### Response:
|
110 |
+
"""
|
111 |
+
prompt = prompt.format(instruction=instruction_prompt)
|
112 |
+
|
113 |
+
else:
|
114 |
+
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
115 |
+
|
116 |
+
### Instruction:
|
117 |
+
{instruction}
|
118 |
+
|
119 |
+
### Input:
|
120 |
+
{input}
|
121 |
+
|
122 |
+
### Response:
|
123 |
+
"""
|
124 |
+
prompt = prompt.format(instruction=instruction_prompt, input=input_prompt)
|
125 |
+
|
126 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
127 |
+
outputs = model.generate(
|
128 |
+
inputs=inputs.input_ids,
|
129 |
+
pad_token_id=tokenizer.pad_token_id,
|
130 |
+
eos_token_id=tokenizer.eos_token_id,
|
131 |
+
max_length=2048, temperature=0.7,
|
132 |
+
do_sample=True, top_k=4, top_p=0.95
|
133 |
+
)
|
134 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
135 |
+
```
|
136 |
+
|
137 |
+
### Quantize Model
|
138 |
+
|
139 |
+
#### Stream Output
|
140 |
+
|
141 |
+
```python
|
142 |
+
import torch
|
143 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextStreamer
|
144 |
+
|
145 |
+
model = AutoModelForCausalLM.from_pretrained(
|
146 |
+
"azale-ai/DukunLM-7B-V1.0-Uncensored",
|
147 |
+
load_in_4bit=True,
|
148 |
+
torch_dtype=torch.float32,
|
149 |
+
trust_remote_code=True,
|
150 |
+
quantization_config=BitsAndBytesConfig(
|
151 |
+
load_in_4bit=True,
|
152 |
+
llm_int8_threshold=6.0,
|
153 |
+
llm_int8_has_fp16_weight=False,
|
154 |
+
bnb_4bit_compute_dtype=torch.float16,
|
155 |
+
bnb_4bit_use_double_quant=True,
|
156 |
+
bnb_4bit_quant_type="nf4",
|
157 |
+
)
|
158 |
+
)
|
159 |
+
tokenizer = AutoTokenizer.from_pretrained("azale-ai/DukunLM-7B-V1.0-Uncensored")
|
160 |
+
streamer = TextStreamer(tokenizer)
|
161 |
+
|
162 |
+
instruction_prompt = "Jelaskan mengapa air penting bagi kehidupan manusia."
|
163 |
+
input_prompt = ""
|
164 |
+
|
165 |
+
if not input_prompt:
|
166 |
+
prompt = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
167 |
+
|
168 |
+
### Instruction:
|
169 |
+
{instruction}
|
170 |
+
|
171 |
+
### Response:
|
172 |
+
"""
|
173 |
+
prompt = prompt.format(instruction=instruction_prompt)
|
174 |
+
|
175 |
+
else:
|
176 |
+
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
177 |
+
|
178 |
+
### Instruction:
|
179 |
+
{instruction}
|
180 |
+
|
181 |
+
### Input:
|
182 |
+
{input}
|
183 |
+
|
184 |
+
### Response:
|
185 |
+
"""
|
186 |
+
prompt = prompt.format(instruction=instruction_prompt, input=input_prompt)
|
187 |
+
|
188 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
189 |
+
_ = model.generate(
|
190 |
+
inputs=inputs.input_ids,
|
191 |
+
streamer=streamer,
|
192 |
+
pad_token_id=tokenizer.pad_token_id,
|
193 |
+
eos_token_id=tokenizer.eos_token_id,
|
194 |
+
max_length=2048, temperature=0.7,
|
195 |
+
do_sample=True, top_k=4, top_p=0.95
|
196 |
+
)
|
197 |
+
```
|
198 |
+
|
199 |
+
#### No Stream Output
|
200 |
+
|
201 |
+
```python
|
202 |
+
import torch
|
203 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
204 |
+
|
205 |
+
model = AutoModelForCausalLM.from_pretrained(
|
206 |
+
"azale-ai/DukunLM-7B-V1.0-Uncensored",
|
207 |
+
load_in_4bit=True,
|
208 |
+
torch_dtype=torch.float32,
|
209 |
+
trust_remote_code=True,
|
210 |
+
quantization_config=BitsAndBytesConfig(
|
211 |
+
load_in_4bit=True,
|
212 |
+
llm_int8_threshold=6.0,
|
213 |
+
llm_int8_has_fp16_weight=False,
|
214 |
+
bnb_4bit_compute_dtype=torch.float16,
|
215 |
+
bnb_4bit_use_double_quant=True,
|
216 |
+
bnb_4bit_quant_type="nf4",
|
217 |
+
)
|
218 |
+
)
|
219 |
+
tokenizer = AutoTokenizer.from_pretrained("azale-ai/DukunLM-7B-V1.0-Uncensored")
|
220 |
+
|
221 |
+
instruction_prompt = "Jelaskan mengapa air penting bagi kehidupan manusia."
|
222 |
+
input_prompt = ""
|
223 |
+
|
224 |
+
if not input_prompt:
|
225 |
+
prompt = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
226 |
+
|
227 |
+
### Instruction:
|
228 |
+
{instruction}
|
229 |
+
|
230 |
+
### Response:
|
231 |
+
"""
|
232 |
+
prompt = prompt.format(instruction=instruction_prompt)
|
233 |
+
|
234 |
+
else:
|
235 |
+
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
236 |
+
|
237 |
+
### Instruction:
|
238 |
+
{instruction}
|
239 |
+
|
240 |
+
### Input:
|
241 |
+
{input}
|
242 |
+
|
243 |
+
### Response:
|
244 |
+
"""
|
245 |
+
prompt = prompt.format(instruction=instruction_prompt, input=input_prompt)
|
246 |
+
|
247 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
248 |
+
outputs = model.generate(
|
249 |
+
inputs=inputs.input_ids,
|
250 |
+
pad_token_id=tokenizer.pad_token_id,
|
251 |
+
eos_token_id=tokenizer.eos_token_id,
|
252 |
+
max_length=2048, temperature=0.7,
|
253 |
+
do_sample=True, top_k=4, top_p=0.95
|
254 |
+
)
|
255 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
256 |
+
```
|
257 |
+
|
258 |
+
## Limitations
|
259 |
+
|
260 |
+
- The base model language is English and fine-tuned to Indonesia
|
261 |
+
- Cultural and contextual biases
|
262 |
+
|
263 |
+
## License
|
264 |
+
|
265 |
+
DukunLM is licensed under the [Creative Commons NonCommercial (CC BY-NC 4.0) license](https://creativecommons.org/licenses/by-nc/4.0/legalcode).
|
266 |
+
|
267 |
+
## Contributing
|
268 |
+
|
269 |
+
We welcome contributions to enhance and improve DukunLM. If you have any suggestions or find any issues, please feel free to open an issue or submit a pull request.
|
270 |
+
|
271 |
+
## Contact Us
|
272 |
+
|
273 |
+
[contact@azale.ai](mailto:contact@azale.ai)
|