Views
No views yet
1# Example code for using the model
2from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
4# Load the tokenizer
5tokenizer = AutoTokenizer.from_pretrained("t5_tokenizer")
6
7# Load the model
8model = AutoModelForSeq2SeqLM.from_pretrained("t5_trained_model")
9
10# Generate a question
11input_text = "Provide a sample input text."
12input_ids = tokenizer.encode(input_text, return_tensors="pt", padding=True, max_length=512, truncation=True)
13
14# Generate question
15question_ids = model.generate(input_ids, max_length=32, num_return_sequences=1, num_beams=4)
16
17# Decode the generated question
18generated_question = tokenizer.decode(question_ids[0], skip_special_tokens=True)
19print(f"Generated Question: {generated_question}")