Views
No views yet
t5-base model fine-tuned for the specific task of generating technical multiple-choice questions (MCQs). Given a context paragraph and a correct answer, the model generates a relevant question.transformers library pipeline function for text-to-text generation.pip install transformers sentencepiece1from transformers import T5ForConditionalGeneration, T5Tokenizer
2
3model_name = "Ayush472/Technical_mcq_model"
4tokenizer = T5Tokenizer.from_pretrained(model_name)
5model = T5ForConditionalGeneration.from_pretrained(model_name)
6
7# The context from which the question should be generated
8context = "The `await` keyword pauses the execution of an async function until a Promise is settled, making asynchronous code look synchronous."
9# The desired answer to the question
10answer = "It pauses the execution of an async function until a Promise is settled"
11
12# Prepare the input for the model
13input_text = f"generate question: context: {context} answer: {answer}"
14
15inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
16
17# Generate the output
18outputs = model.generate(
19 inputs.input_ids,
20 attention_mask=inputs.attention_mask,
21 max_length=64,
22 num_beams=4,
23 early_stopping=True
24)
25
26# Decode the generated question
27generated_question = tokenizer.decode(outputs[0], skip_special_tokens=True)
28
29print(f"Context: {context}")
30print(f"Answer: {answer}")
31print(f"Generated Question: {generated_question}")
32
33# Expected Output:
34# Generated Question: What does the `await` keyword do in JavaScript?transformers library's Trainer API on a single NVIDIA T4 GPU. The t5-base model was used as the starting checkpoint. The training process involved formatting the dataset into context: {context} answer: {answer} inputs and the corresponding question as the target label.1@misc{ayush472_t5_mcq_2025,
2 author = {Ayush},
3 title = {T5 for Technical MCQ Generation},
4 year = {2025},
5 publisher = {Hugging Face},
6 journal = {Hugging Face repository},
7 howpublished = {\\url{https://huggingface.co/Ayush472/Technical_mcq_model}}
8}