Update README.md
Browse files
README.md
CHANGED
@@ -17,7 +17,44 @@ datasets:
|
|
17 |
- **Developed by:** Wajdi1976
|
18 |
- **License:** apache-2.0
|
19 |
- **Finetuned from model :** unsloth/qwen2.5-3b-bnb-4bit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
22 |
|
23 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
17 |
- **Developed by:** Wajdi1976
|
18 |
- **License:** apache-2.0
|
19 |
- **Finetuned from model :** unsloth/qwen2.5-3b-bnb-4bit
|
20 |
+
### First, Load the Model
|
21 |
+
```python
|
22 |
+
from unsloth import FastLanguageModel
|
23 |
+
import torch
|
24 |
+
max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
|
25 |
+
dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
|
26 |
+
load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
|
27 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
28 |
+
model_name = "Wajdi1976/alpaca_arabic_Qwen2.5-3B",
|
29 |
+
max_seq_length = max_seq_length,
|
30 |
+
dtype = dtype,
|
31 |
+
load_in_4bit = load_in_4bit,
|
32 |
+
# token = "hf_...", # use one if using gated models like meta-llama/Llama-2-7b-hf
|
33 |
+
)
|
34 |
+
```
|
35 |
|
36 |
+
### Second, Try the model
|
37 |
+
```python
|
38 |
+
alpaca_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.
|
39 |
+
### Instruction:
|
40 |
+
{}
|
41 |
+
### Input:
|
42 |
+
{}
|
43 |
+
### Response:
|
44 |
+
{}"""
|
45 |
+
# alpaca_prompt = Copied from above
|
46 |
+
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
|
47 |
+
inputs = tokenizer(
|
48 |
+
[
|
49 |
+
alpaca_prompt.format(
|
50 |
+
"استخدم البيانات المعطاة لحساب الوسيط.", # instruction
|
51 |
+
"[2 ، 3 ، 7 ، 8 ، 10]", # input
|
52 |
+
"", # output - leave this blank for generation!
|
53 |
+
)
|
54 |
+
], return_tensors = "pt").to("cuda")
|
55 |
+
outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
|
56 |
+
tokenizer.batch_decode(outputs)
|
57 |
+
```
|
58 |
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
59 |
|
60 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|