Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def generate_text(usertitle, content, temperature, max_length, N=3):
|
|
27 |
# 'content': content
|
28 |
# }
|
29 |
input_text = f"[[[title:]]] {usertitle}\n[[[content:]]]{content}\n\n"
|
30 |
-
inputs = tokenizer.apply_chat_template(
|
31 |
attention_mask = torch.ones(inputs['input_ids'].shape, dtype=torch.long, device='cuda')
|
32 |
generated_sequences = model.generate(inputs['input_ids'], attention_mask=attention_mask, temperature=temperature, max_length=max_length, pad_token_id=tokenizer.eos_token_id, num_return_sequences=N, do_sample=True)
|
33 |
decoded_sequences = [tokenizer.decode(g) for g in generated_sequences]#.strip().split(tokenizer.eos_token)[0]
|
|
|
27 |
# 'content': content
|
28 |
# }
|
29 |
input_text = f"[[[title:]]] {usertitle}\n[[[content:]]]{content}\n\n"
|
30 |
+
inputs = tokenizer.apply_chat_template(input_text, return_tensors='pt').cuda()
|
31 |
attention_mask = torch.ones(inputs['input_ids'].shape, dtype=torch.long, device='cuda')
|
32 |
generated_sequences = model.generate(inputs['input_ids'], attention_mask=attention_mask, temperature=temperature, max_length=max_length, pad_token_id=tokenizer.eos_token_id, num_return_sequences=N, do_sample=True)
|
33 |
decoded_sequences = [tokenizer.decode(g) for g in generated_sequences]#.strip().split(tokenizer.eos_token)[0]
|