yilunzhao commited on
Commit
5bc259c
·
verified ·
1 Parent(s): e3dce0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -16,8 +16,8 @@ else:
16
  @spaces.GPU
17
  def generate_response(passage: str, question: str) -> str:
18
  # Prepare the input text by combining the passage and question
19
- user_message = f"Passage: {passage}\nQuestion: {question}"
20
- inputs = tokenizer(user_message, return_tensors="pt").to(model.device)
21
 
22
  # Generate text, focusing only on the new tokens added by the model
23
  outputs = model.generate(inputs.input_ids, max_new_tokens=150)
 
16
  @spaces.GPU
17
  def generate_response(passage: str, question: str) -> str:
18
  # Prepare the input text by combining the passage and question
19
+ message = [{"role": "user", "content": f"Passage: {passage}\nQuestion: {question}"}]
20
+ inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
21
 
22
  # Generate text, focusing only on the new tokens added by the model
23
  outputs = model.generate(inputs.input_ids, max_new_tokens=150)