Spaces:
Runtime error
Runtime error
BusinessDev
commited on
Commit
•
d1095eb
1
Parent(s):
59e0faa
Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,13 @@ model = MBartForConditionalGeneration.from_pretrained(model_name)
|
|
13 |
def answer_question(text, question):
|
14 |
# Prepare input text
|
15 |
input_text = f"context: {text} question: {question}"
|
16 |
-
inputs = tokenizer(input_text, return_tensors="pt", max_length=
|
17 |
|
18 |
# Generate answer
|
19 |
outputs = model.generate(
|
20 |
input_ids=inputs["input_ids"],
|
21 |
attention_mask=inputs["attention_mask"],
|
22 |
-
max_length=
|
23 |
num_beams=5,
|
24 |
early_stopping=True
|
25 |
)
|
|
|
13 |
def answer_question(text, question):
|
14 |
# Prepare input text
|
15 |
input_text = f"context: {text} question: {question}"
|
16 |
+
inputs = tokenizer(input_text, return_tensors="pt", max_length=1024, truncation=False, padding="max_length")
|
17 |
|
18 |
# Generate answer
|
19 |
outputs = model.generate(
|
20 |
input_ids=inputs["input_ids"],
|
21 |
attention_mask=inputs["attention_mask"],
|
22 |
+
max_length=1024,
|
23 |
num_beams=5,
|
24 |
early_stopping=True
|
25 |
)
|