patil-suraj/question_generation

The number of answers extracted

nomoreoneday opened this issue · 0 comments

Great works!

I'm wondering how did you control the number of answers extracted when doing multitask-qa-qg tasks?
`
def _extract_answers(self,context):

    sents,inputs = self._prepare_inputs_for_ans_extraction(context)
    inputs = self._tokenize(inputs,padding = True,truncation = True) #encoding
    #print("inputs after encoding:",inputs)

    outs = self.ans_model.generate(
        input_ids = inputs['input_ids'].to(self.device),
        attention_mask = inputs['attention_mask'].to(self.device),
        max_length = 32,
    )
    dec = [self.ans_tokenizer.decode(ids,skip_special_tokens=False) for ids in outs] #decoding
    #print("dec:", dec)
    answers = [item.split('<sep>') for item in dec]
    #print("answers1:",answers)
    answers = [i[1:] for i in answers]
    #print("answers2:",answers)

    return sents, answers

`