GauravGosain commited on
Commit
1878f5b
·
verified ·
1 Parent(s): 8f2af79

Fix generate: apply_chat_template return_dict + unpack (attention mask)

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -59,13 +59,13 @@ def _messages(message, history, system_prompt):
59
  @spaces.GPU(duration=120)
60
  def chat(message, history, system_prompt, temperature, max_new_tokens):
61
  msgs = _messages(message, history, system_prompt)
62
- input_ids = tokenizer.apply_chat_template(
63
- msgs, add_generation_prompt=True, return_tensors="pt"
64
  ).to(model.device)
65
 
66
  streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
67
  gen_kwargs = dict(
68
- input_ids=input_ids,
69
  streamer=streamer,
70
  max_new_tokens=int(max_new_tokens),
71
  do_sample=temperature > 0,
 
59
  @spaces.GPU(duration=120)
60
  def chat(message, history, system_prompt, temperature, max_new_tokens):
61
  msgs = _messages(message, history, system_prompt)
62
+ inputs = tokenizer.apply_chat_template(
63
+ msgs, add_generation_prompt=True, return_tensors="pt", return_dict=True
64
  ).to(model.device)
65
 
66
  streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
67
  gen_kwargs = dict(
68
+ **inputs,
69
  streamer=streamer,
70
  max_new_tokens=int(max_new_tokens),
71
  do_sample=temperature > 0,