harpreetsahota
commited on
Commit
•
1fb44f8
1
Parent(s):
b0b6c53
Update README.md
Browse files
README.md
CHANGED
@@ -43,19 +43,41 @@ The model is intended for commercial and research use in English.
|
|
43 |
|
44 |
Use the code below to get started with the model.
|
45 |
|
46 |
-
```
|
47 |
import torch
|
48 |
-
from transformers import AutoModelForCausalLM,
|
49 |
|
50 |
model_name = "Deci/DeciLM-7B-instruct"
|
|
|
51 |
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
52 |
|
53 |
-
|
54 |
-
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
```
|
60 |
|
61 |
## Evaluation
|
|
|
43 |
|
44 |
Use the code below to get started with the model.
|
45 |
|
46 |
+
```python
|
47 |
import torch
|
48 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
|
49 |
|
50 |
model_name = "Deci/DeciLM-7B-instruct"
|
51 |
+
|
52 |
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
53 |
|
54 |
+
bnb_config = BitsAndBytesConfig(
|
55 |
+
load_in_4bit = True,
|
56 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
57 |
+
)
|
58 |
|
59 |
+
model = AutoModelForCausalLM.from_pretrained(
|
60 |
+
model_name,
|
61 |
+
device_map="auto",
|
62 |
+
trust_remote_code=True,
|
63 |
+
quantization_config=bnb_config
|
64 |
+
)
|
65 |
+
|
66 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
67 |
+
tokenizer.pad_token = tokenizer.eos_token
|
68 |
+
|
69 |
+
deci_generator = pipeline("text-generation",
|
70 |
+
model=model,
|
71 |
+
tokenizer=tokenizer,
|
72 |
+
temperature=0.1,
|
73 |
+
device_map="auto",
|
74 |
+
max_length=4096,
|
75 |
+
return_full_text=False
|
76 |
+
)
|
77 |
+
|
78 |
+
prompt = "How do I make the most delicious pancakes the world has ever tasted?"
|
79 |
+
response = deci_generator(prompt)[0]['generated_text']
|
80 |
+
print(response)
|
81 |
```
|
82 |
|
83 |
## Evaluation
|