Closed shamanez closed 3 years ago
Hello, sorry for the slow response.
Are you using this repo or the model directly from huggingface?
If you install this repo as a package you can just input the text you want to use. It should create candidate answers automatically.
installation:
git clone https://github.com/amontgomerie/question_generator
python -m pip install -e question_generator
cd question_generator
example usage:
from questiongenerator import QuestionGenerator, print_qa
text = (
"The central government will decide Thursday when it plans to declare a state of emergency "
"in parts of the greater Tokyo metropolitan area, Prime Minister Yoshihide Suga said Tuesday "
"during an executive meeting of the ruling Liberal Democratic Party. "
"The numbers of new COVID-19 cases reported each day have increased more than tenfold since a "
"state of emergency was previously declared, by then-Prime Minister Shinzo Abe in April of last "
"year. "
"Eight months later, experts say it’s no longer clear the public will comply to the same degree, "
"nor is it certain the government has the financial strength to support businesses that "
"voluntarily close."
)
qg = QuestionGenerator()
result = qg.generate(text, num_questions=2)
print_qa(result)
output:
1) Q: what is the state of emergency in the greater tokyo metropolitan area?
A: The central government will decide Thursday when it plans to declare a state of emergency in parts of the greater Tokyo metropolitan area, Prime Minister Yoshihide Suga said Tuesday during an executive meeting of the ruling Liberal Democratic Party.
2) Q: how many cases of COVID-19 have been reported?
A: The numbers of new COVID-19 cases reported each day have increased more than tenfold since a state of emergency was previously declared, by then-Prime Minister Shinzo Abe in April of last year.
If you're using the model directly from huggingface like:
model = AutoModelForSeq2SeqLM.from_pretrained("iarfmoose/t5-base-question-generator")
Then you will need to choose answers yourself and concatenate them with the text to make model inputs. For example:
answer = "This is the answer to the question."
text = "This is the full text containing the answer."
qg_input = f"{ANSWER_TOKEN} {answer} {CONTEXT_TOKEN} {text}"
Thanks a lot.
Hi great work. I tried to generate question using your model. But I have a question about the input. Should input consist of source text or text+answer?
answer_token context_token
If yes, can you please show me an example input, that I can use with your hugging face API ?