Edit model card

Question generation using T5 transformer trained on SQuAD

Input format: context: "..." answer(optional): "..."

Import the pretrained model as well as tokenizer:

from transformers import T5ForConditionalGeneration, T5Tokenizer

model = T5ForConditionalGeneration.from_pretrained('AbhilashDatta/T5_qgen-squad_v2') 
tokenizer = T5Tokenizer.from_pretrained('AbhilashDatta/T5_qgen-squad_v2')

Then use the tokenizer to encode/decode and model to generate:

input = "context: My name is Abhilash Datta. answer: Abhilash"
batch = tokenizer(input, padding='longest', max_length=512, return_tensors='pt')
inputs_batch = batch['input_ids'][0]
inputs_batch = torch.unsqueeze(inputs_batch, 0)

ques_id = model.generate(inputs_batch, max_length=100, early_stopping=True)
ques_batch = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=False) for g in ques_id]

print(ques_batch)

Output:

['what is my name']
Downloads last month
5