tomer-deci
commited on
Commit
•
abb8ae6
1
Parent(s):
fb62397
Update README.md
Browse filesUpdated README with chat_template
README.md
CHANGED
@@ -38,6 +38,15 @@ DeciLM-7B-instruct is a derivative of the recently released [DeciLM-7B](https://
|
|
38 |
- **Finetuning Notebook:** [DeciLM-7B Finetuning Notebook](https://colab.research.google.com/drive/1kEV6i96AQ94xTCvSd11TxkEaksTb5o3U?usp=sharing)
|
39 |
- **Text Generation Notebook:** [DeciLM-7B-instruct Text Generation Notebook](https://bit.ly/declm-7b-instruct)
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
## Uses
|
42 |
|
43 |
The model is intended for commercial and research use in English.
|
@@ -54,16 +63,21 @@ model_name = "Deci/DeciLM-7B-instruct"
|
|
54 |
|
55 |
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
model = AutoModelForCausalLM.from_pretrained(
|
63 |
model_name,
|
64 |
device_map="auto",
|
65 |
trust_remote_code=True,
|
66 |
-
|
67 |
)
|
68 |
|
69 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
@@ -75,25 +89,19 @@ deci_generator = pipeline("text-generation",
|
|
75 |
temperature=0.1,
|
76 |
device_map="auto",
|
77 |
max_length=4096,
|
78 |
-
return_full_text=False
|
79 |
-
)
|
80 |
|
81 |
-
|
82 |
|
83 |
-
|
84 |
-
### System:
|
85 |
-
You are an AI assistant that follows instruction extremely well. Help as much as you can.
|
86 |
-
### User:
|
87 |
-
{instruction}
|
88 |
-
### Assistant:
|
89 |
-
"""
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
94 |
|
95 |
-
response = deci_generator(
|
96 |
-
print(response)
|
97 |
```
|
98 |
|
99 |
## Evaluation
|
|
|
38 |
- **Finetuning Notebook:** [DeciLM-7B Finetuning Notebook](https://colab.research.google.com/drive/1kEV6i96AQ94xTCvSd11TxkEaksTb5o3U?usp=sharing)
|
39 |
- **Text Generation Notebook:** [DeciLM-7B-instruct Text Generation Notebook](https://bit.ly/declm-7b-instruct)
|
40 |
|
41 |
+
### Prompt Template
|
42 |
+
```
|
43 |
+
### System:
|
44 |
+
{system_prompt}
|
45 |
+
### User:
|
46 |
+
{user_prompt}
|
47 |
+
### Assistant:
|
48 |
+
```
|
49 |
+
|
50 |
## Uses
|
51 |
|
52 |
The model is intended for commercial and research use in English.
|
|
|
63 |
|
64 |
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
65 |
|
66 |
+
quantize = False # Optional. Useful for GPUs with less than 24GB memory
|
67 |
+
|
68 |
+
if quantize:
|
69 |
+
dtype_kwargs = dict(quantization_config=BitsAndBytesConfig(
|
70 |
+
load_in_4bit=True,
|
71 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
72 |
+
))
|
73 |
+
else:
|
74 |
+
dtype_kwargs = dict(torch_dtype="auto")
|
75 |
|
76 |
model = AutoModelForCausalLM.from_pretrained(
|
77 |
model_name,
|
78 |
device_map="auto",
|
79 |
trust_remote_code=True,
|
80 |
+
**dtype_kwargs
|
81 |
)
|
82 |
|
83 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
89 |
temperature=0.1,
|
90 |
device_map="auto",
|
91 |
max_length=4096,
|
92 |
+
return_full_text=False)
|
|
|
93 |
|
94 |
+
system_prompt = "You are an AI assistant that follows instruction extremely well. Help as much as you can."
|
95 |
|
96 |
+
user_prompt = "How do I make the most delicious pancakes the world has ever tasted?"
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
+
prompt = tokenizer.apply_chat_template([
|
99 |
+
{"role": "system", "content": system_prompt},
|
100 |
+
{"role": "user", "content": user_prompt},
|
101 |
+
], tokenize=False, add_generation_prompt=True)
|
102 |
|
103 |
+
response = deci_generator(prompt)[0]['generated_text']
|
104 |
+
print(prompt + response)
|
105 |
```
|
106 |
|
107 |
## Evaluation
|