guoday commited on
Commit
509e48e
1 Parent(s): 0ed36bf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +5 -14
README.md CHANGED
@@ -32,24 +32,15 @@ Here give some examples of how to use our model.
32
  #### Chat Model Inference
33
  ```python
34
  from transformers import AutoTokenizer, AutoModelForCausalLM
35
- tokenizer = AutoTokenizer.from_pretrained("deepseek-coder-6.7b-instruct", trust_remote_code=True)
36
- model = AutoModelForCausalLM.from_pretrained("deepseek-coder-6.7b-instruct", trust_remote_code=True).cuda()
37
- system_prompt = "You are an AI programming assistant, utilizing the Deepseek Coder model, developed by Deepseek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer.\n"
38
  messages=[
39
  { 'role': 'user', 'content': "write a quick sort algorithm in python."}
40
  ]
41
- prompt = system_prompt
42
- for content in messages:
43
- if content['role'] == 'user':
44
- prompt += f"### Instruction:\n{content['content']}\n"
45
- else:
46
- prompt += f"### Response:\n{content['content']}\n"
47
- prompt += "<|EOT|>\n"
48
- prompt += "### Response:\n"
49
- inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
50
  # 32021 is the id of <|EOT|> token
51
- outputs = model.generate(**inputs, max_new_tokens=256, do_sample=True, top_k=50, top_p=0.95, num_return_sequences=1, eos_token_id=32021)
52
- print(tokenizer.decode(outputs[0]))
53
  ```
54
 
55
  ### 4. Lincense
 
32
  #### Chat Model Inference
33
  ```python
34
  from transformers import AutoTokenizer, AutoModelForCausalLM
35
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-instruct", trust_remote_code=True)
36
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-instruct", trust_remote_code=True).cuda()
 
37
  messages=[
38
  { 'role': 'user', 'content': "write a quick sort algorithm in python."}
39
  ]
40
+ inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
 
 
 
 
 
 
 
 
41
  # 32021 is the id of <|EOT|> token
42
+ 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=32021)
43
+ print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
44
  ```
45
 
46
  ### 4. Lincense