Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ model.to(device)
|
|
18 |
def generate_text(question):
|
19 |
prompt = f'Q: {question}\nA:'
|
20 |
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
|
21 |
-
tokens = model.generate(input_ids, max_length=
|
22 |
response = tokenizer.decode(tokens[0], skip_special_tokens=False)
|
23 |
return response.split('\nA: ')[-1]
|
24 |
|
|
|
18 |
def generate_text(question):
|
19 |
prompt = f'Q: {question}\nA:'
|
20 |
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
|
21 |
+
tokens = model.generate(input_ids, max_length=50, pad_token_id=tokenizer.eos_token_id)
|
22 |
response = tokenizer.decode(tokens[0], skip_special_tokens=False)
|
23 |
return response.split('\nA: ')[-1]
|
24 |
|