Update pipeline.py
Browse files- pipeline.py +10 -1
pipeline.py
CHANGED
@@ -40,9 +40,18 @@ class PreTrainedPipeline():
|
|
40 |
questions, qg_examples = self.prepare_and_generate_questions(sents, answers)
|
41 |
output = [{'answer': example['answer'], 'question': que} for example, que in zip(qg_examples, questions)]
|
42 |
output = self.clean_generated_QAs(output, max_words_per_answer)
|
43 |
-
|
|
|
44 |
return output
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
def prepare_and_generate_questions(self, sents, answers):
|
47 |
qg_examples = self._prepare_inputs_for_qg_from_answers_hl(sents, answers)
|
48 |
|
|
|
40 |
questions, qg_examples = self.prepare_and_generate_questions(sents, answers)
|
41 |
output = [{'answer': example['answer'], 'question': que} for example, que in zip(qg_examples, questions)]
|
42 |
output = self.clean_generated_QAs(output, max_words_per_answer)
|
43 |
+
new = self.generate_probability_acceptances(inputs, output)
|
44 |
+
return [{"hello": new}]
|
45 |
return output
|
46 |
|
47 |
+
def generate_probability_acceptances(inputs, output):
|
48 |
+
model_inputs = []
|
49 |
+
for output in outputs:
|
50 |
+
text = f"Question: " + output['question'] + f" {split_char} Answer: " + output['answer'] + f" {split_char} Context: " + inputs
|
51 |
+
model_inputs.append(text)
|
52 |
+
return self.pipe(model_inputs)
|
53 |
+
|
54 |
+
|
55 |
def prepare_and_generate_questions(self, sents, answers):
|
56 |
qg_examples = self._prepare_inputs_for_qg_from_answers_hl(sents, answers)
|
57 |
|