Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the char end and char start in the generated question and answers from valhalla/t5-base-qg-hl? #104

Open
monk1337 opened this issue Oct 9, 2022 · 1 comment

Comments

@monk1337
Copy link

monk1337 commented Oct 9, 2022

Hi, The output of model valhalla/t5-base-qg-hl is {question and answer} is it possible to get char end and char start?

@lightshifted
Copy link

Yes, but in a roundabout way:

import pipelines

# load text
inputs = text_dataset

# instantiate QGPipeline
qgp = pipelines.QGPipeline(model, ans_model, tokenizer, ans_tokenizer)

# extract sentence and answers
sentence, extracted_answers = qgp._prepare_inputs_for_ans_extraction(inputs)

# search an answer for location char_start
index = 0
answer = extracted_answers[index]

char_start = extracted_answer.find('<hl>') + 5

Similarly, you can use rrfind('') to search for char_end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants