khulnasoft
commited on
Commit
•
688a63a
1
Parent(s):
a17614f
Update README.md
Browse files
README.md
CHANGED
@@ -2,4 +2,20 @@
|
|
2 |
license: other
|
3 |
license_name: deepcode-ai
|
4 |
license_link: LICENSE
|
5 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: other
|
3 |
license_name: deepcode-ai
|
4 |
license_link: LICENSE
|
5 |
+
---
|
6 |
+
|
7 |
+
### How to Use
|
8 |
+
Here give some examples of how to use our model.
|
9 |
+
#### Chat Model Inference
|
10 |
+
```python
|
11 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("deepcode-ai/coder", trust_remote_code=True)
|
13 |
+
model = AutoModelForCausalLM.from_pretrained("deepcode-ai/coder", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
|
14 |
+
messages=[
|
15 |
+
{ 'role': 'user', 'content': "write a quick sort algorithm in python."}
|
16 |
+
]
|
17 |
+
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
18 |
+
# tokenizer.eos_token_id is the id of <|EOT|> token
|
19 |
+
outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, top_k=50, top_p=0.95, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
|
20 |
+
print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
|
21 |
+
```
|