usage update
Browse files
README.md
CHANGED
@@ -42,25 +42,32 @@ dtype: float16
|
|
42 |
|
43 |
## 💻 Usage
|
44 |
|
45 |
-
|
46 |
-
!pip install -qU transformers accelerate
|
47 |
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
import torch
|
51 |
|
52 |
-
model
|
53 |
-
|
|
|
|
|
|
|
|
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
pipeline = transformers.pipeline(
|
58 |
-
"text-generation",
|
59 |
-
model=model,
|
60 |
-
torch_dtype=torch.float16,
|
61 |
-
device_map="auto",
|
62 |
-
)
|
63 |
|
64 |
-
|
65 |
-
|
|
|
66 |
```
|
|
|
42 |
|
43 |
## 💻 Usage
|
44 |
|
45 |
+
First, you need to install some of below packages:
|
|
|
46 |
|
47 |
+
1. Bits and bytes
|
48 |
+
```python
|
49 |
+
!pip install bitsandbytes
|
50 |
+
```
|
51 |
+
2. Accelerate (to install the latest version)
|
52 |
+
```python
|
53 |
+
!pip install git+https://github.com/huggingface/accelerate.git
|
54 |
+
```
|
55 |
+
3. Usage
|
56 |
+
```python
|
57 |
+
# Usage
|
58 |
import torch
|
59 |
|
60 |
+
# Load model directly
|
61 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
62 |
+
|
63 |
+
# load the model in 4-bit quantization
|
64 |
+
tokenizer = AutoTokenizer.from_pretrained("shuvom/yuj-v1")
|
65 |
+
model = AutoModelForCausalLM.from_pretrained("shuvom/yuj-v1",torch_dtype=torch.bfloat16,load_in_4bit=True)
|
66 |
|
67 |
+
prompt = "युज शीर्ष द्विभाषी मॉडल में से एक है"
|
68 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
+
# Generate
|
71 |
+
generate_ids = model.generate(inputs.input_ids, max_length=65)
|
72 |
+
tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
73 |
```
|