Update README.md
Browse files
README.md
CHANGED
@@ -19,4 +19,64 @@ base_model: unsloth/gemma-7b-bnb-4bit
|
|
19 |
|
20 |
This gemma model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
19 |
|
20 |
This gemma model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
21 |
|
22 |
+
|
23 |
+
|
24 |
+
# Inference With Unsloth on colab
|
25 |
+
|
26 |
+
|
27 |
+
%%capture
|
28 |
+
import torch
|
29 |
+
major_version, minor_version = torch.cuda.get_device_capability()
|
30 |
+
# Must install separately since Colab has torch 2.2.1, which breaks packages
|
31 |
+
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
|
32 |
+
if major_version >= 8:
|
33 |
+
# Use this for new GPUs like Ampere, Hopper GPUs (RTX 30xx, RTX 40xx, A100, H100, L40)
|
34 |
+
!pip install --no-deps packaging ninja einops flash-attn xformers trl peft accelerate bitsandbytes
|
35 |
+
else:
|
36 |
+
# Use this for older GPUs (V100, Tesla T4, RTX 20xx)
|
37 |
+
!pip install --no-deps xformers trl peft accelerate bitsandbytes
|
38 |
+
pass
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
from unsloth import FastLanguageModel
|
43 |
+
import torch
|
44 |
+
max_seq_length = 2048
|
45 |
+
dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
|
46 |
+
load_in_4bit = False
|
47 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
48 |
+
model_name = "Xhaheen/Shaheen_Gemma_Urdu_",
|
49 |
+
max_seq_length = max_seq_length,
|
50 |
+
dtype = dtype,
|
51 |
+
load_in_4bit = load_in_4bit,
|
52 |
+
device_map="auto"
|
53 |
+
)
|
54 |
+
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
|
55 |
+
|
56 |
+
input_prompt = """
|
57 |
+
### Instruction:
|
58 |
+
{}
|
59 |
+
|
60 |
+
### Input:
|
61 |
+
{}
|
62 |
+
|
63 |
+
### Response:
|
64 |
+
{}"""
|
65 |
+
|
66 |
+
input_text = input_prompt.format(
|
67 |
+
"دیئے گئے موضوع کے بارے میں ایک مختصر پیراگراف لکھیں۔", # instruction
|
68 |
+
"قابل تجدید توانائی کے استعمال کی اہمیت", # input
|
69 |
+
"", # output - leave this blank for generation!
|
70 |
+
)
|
71 |
+
|
72 |
+
inputs = tokenizer([input_text], return_tensors = "pt").to("cuda")
|
73 |
+
|
74 |
+
outputs = model.generate(**inputs, max_new_tokens = 300, use_cache = True)
|
75 |
+
response = tokenizer.batch_decode(outputs)
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|