Update README.md
Browse files
README.md
CHANGED
@@ -37,16 +37,16 @@ class Chatbot:
|
|
37 |
self.model = AutoModelForCausalLM.from_pretrained(model_name, load_in_4bit=True, torch_dtype=torch.bfloat16)
|
38 |
if self.tokenizer.pad_token_id is None:
|
39 |
self.tokenizer.pad_token_id = self.tokenizer.eos_token_id
|
40 |
-
|
41 |
def get_response(self, prompt):
|
42 |
inputs = self.tokenizer.encode_plus(prompt, return_tensors="pt", padding='max_length', max_length=100)
|
43 |
if next(self.model.parameters()).is_cuda:
|
44 |
inputs = {name: tensor.to('cuda') for name, tensor in inputs.items()}
|
45 |
start_time = time.time()
|
46 |
tokens = self.model.generate(input_ids=inputs['input_ids'],
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
end_time = time.time()
|
51 |
output_tokens = tokens[0][inputs['input_ids'].shape[-1]:]
|
52 |
output = self.tokenizer.decode(output_tokens, skip_special_tokens=True)
|
@@ -67,6 +67,7 @@ def main():
|
|
67 |
if __name__ == "__main__":
|
68 |
main()
|
69 |
|
|
|
70 |
|
71 |
Training Procedure
|
72 |
The base WizardCoder model was finetuned on the Guanaco dataset using QLORA, which was trimmed to within 2 standard deviations of token size for question sets and randomized. All non-English data was also removed from this finetuning dataset.
|
|
|
37 |
self.model = AutoModelForCausalLM.from_pretrained(model_name, load_in_4bit=True, torch_dtype=torch.bfloat16)
|
38 |
if self.tokenizer.pad_token_id is None:
|
39 |
self.tokenizer.pad_token_id = self.tokenizer.eos_token_id
|
40 |
+
|
41 |
def get_response(self, prompt):
|
42 |
inputs = self.tokenizer.encode_plus(prompt, return_tensors="pt", padding='max_length', max_length=100)
|
43 |
if next(self.model.parameters()).is_cuda:
|
44 |
inputs = {name: tensor.to('cuda') for name, tensor in inputs.items()}
|
45 |
start_time = time.time()
|
46 |
tokens = self.model.generate(input_ids=inputs['input_ids'],
|
47 |
+
attention_mask=inputs['attention_mask'],
|
48 |
+
pad_token_id=self.tokenizer.pad_token_id,
|
49 |
+
max_new_tokens=400)
|
50 |
end_time = time.time()
|
51 |
output_tokens = tokens[0][inputs['input_ids'].shape[-1]:]
|
52 |
output = self.tokenizer.decode(output_tokens, skip_special_tokens=True)
|
|
|
67 |
if __name__ == "__main__":
|
68 |
main()
|
69 |
|
70 |
+
```
|
71 |
|
72 |
Training Procedure
|
73 |
The base WizardCoder model was finetuned on the Guanaco dataset using QLORA, which was trimmed to within 2 standard deviations of token size for question sets and randomized. All non-English data was also removed from this finetuning dataset.
|