Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,9 @@ def generate_questions(email):
|
|
| 12 |
"""Generates questions based on the input email."""
|
| 13 |
# Encode the email and prompt together with tokenizer
|
| 14 |
inputs = tokenizer(email, return_tensors="pt", add_special_tokens=True)
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Generate questions using model
|
| 18 |
generation = model.generate(
|
|
@@ -26,6 +28,7 @@ def generate_questions(email):
|
|
| 26 |
return tokenizer.decode(generation[0], skip_special_tokens=True)
|
| 27 |
|
| 28 |
|
|
|
|
| 29 |
def generate_answers(questions):
|
| 30 |
"""Generates possible answers to the input questions."""
|
| 31 |
# Encode each question with tokenizer, separated by newline
|
|
|
|
| 12 |
"""Generates questions based on the input email."""
|
| 13 |
# Encode the email and prompt together with tokenizer
|
| 14 |
inputs = tokenizer(email, return_tensors="pt", add_special_tokens=True)
|
| 15 |
+
|
| 16 |
+
# Convert tensor to list before concatenation
|
| 17 |
+
inputs["input_ids"] = [tokenizer.cls_token_id] + inputs["input_ids"].tolist()
|
| 18 |
|
| 19 |
# Generate questions using model
|
| 20 |
generation = model.generate(
|
|
|
|
| 28 |
return tokenizer.decode(generation[0], skip_special_tokens=True)
|
| 29 |
|
| 30 |
|
| 31 |
+
|
| 32 |
def generate_answers(questions):
|
| 33 |
"""Generates possible answers to the input questions."""
|
| 34 |
# Encode each question with tokenizer, separated by newline
|