nhanv commited on
Commit
2ca26d3
1 Parent(s): 0c7484a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -14
README.md CHANGED
@@ -80,22 +80,11 @@ def has_close_elements(numbers: List[float], threshold: float) -> bool:
80
  messages = [
81
  {"role": "user", "content": prompt}
82
  ]
83
- text = tokenizer.apply_chat_template(
84
- messages,
85
- tokenize=False,
86
- add_generation_prompt=True
87
- )
88
- model_inputs = tokenizer([text], return_tensors="pt").to(device)
89
 
90
- generated_ids = model.generate(
91
- model_inputs.input_ids,
92
- max_new_tokens=512
93
- )
94
- generated_ids = [
95
- output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
96
- ]
97
 
98
- response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
99
  ```
100
 
101
  ### Contact information
 
80
  messages = [
81
  {"role": "user", "content": prompt}
82
  ]
 
 
 
 
 
 
83
 
84
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
85
+ 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)
86
+ res = tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)
 
 
 
 
87
 
 
88
  ```
89
 
90
  ### Contact information