Instructions to use mohammedaly22/t5-small-question-generation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mohammedaly22/t5-small-question-generation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mohammedaly22/t5-small-question-generation")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("mohammedaly22/t5-small-question-generation") model = AutoModelForSeq2SeqLM.from_pretrained("mohammedaly22/t5-small-question-generation") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use mohammedaly22/t5-small-question-generation with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mohammedaly22/t5-small-question-generation" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mohammedaly22/t5-small-question-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mohammedaly22/t5-small-question-generation
- SGLang
How to use mohammedaly22/t5-small-question-generation with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mohammedaly22/t5-small-question-generation" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mohammedaly22/t5-small-question-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mohammedaly22/t5-small-question-generation" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mohammedaly22/t5-small-question-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mohammedaly22/t5-small-question-generation with Docker Model Runner:
docker model run hf.co/mohammedaly22/t5-small-question-generation
YAML Metadata Warning:The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
t5-small-squad-qg-v2
This model is a fine-tuned version of t5-small on the SQuAD dataset. It achieves the following results on the evaluation set:
- Loss: 1.6608
- BLEU: 20.00
- Rouge1: 47.69
- Rouge2: 26.43
- RougeL: 44.15
- RougeLSum: 44.15
- METEOR: 45.84
- BertScore: 91.82
Model description
Intended uses & limitations
- Define some useful functions for highlighting the answer in the paragraph and preparing the instruction prompt that will be fed to the model:
def highlight_answer(context, answer):
context_splits = context.split(answer)
text = ""
for split in context_splits:
text += split
text += ' <h> '
text += answer
text += ' <h> '
text += split
return text
def prepare_instruction(answer_highlighted_context):
instruction_prompt = f"""Generate a question whose answer is highlighted by <h> from the context delimited by the triple backticks.
context:
```
{answer_highlighted_context}
```
"""
return instruction_prompt
- Use the model as a Hugging Face Pipeline:
from transformers import pipeline
pipe = pipeline('text2text-generation', model='mohammedaly22/t5-small-squad-qg-v2')
context = """During the 2011–12 season, he set the La Liga and European records\
for most goals scored in a single season, while establishing himself as Barcelona's\
all-time top scorer. The following two seasons, Messi finished second for the Ballon\
d'Or behind Cristiano Ronaldo (his perceived career rival), before regaining his best\
form during the 2014–15 campaign, becoming the all-time top scorer in La Liga and \
leading Barcelona to a historic second treble, after which he was awarded a fifth \
Ballon d'Or in 2015. Messi assumed captaincy of Barcelona in 2018, and won a record \
sixth Ballon d'Or in 2019. Out of contract, he signed for French club Paris Saint-Germain\
in August 2021, spending two seasons at the club and winning Ligue 1 twice. Messi \
joined American club Inter Miami in July 2023, winning the Leagues Cup in August of that year.
"""
answer_highlighted_context = highlight_answer(context=context, answer='Inter Miami')
prompt = prepare_instruction(answer_highlighted_context)
This will be the final prompt:
Generate a question whose answer is highlighted by <h> from the context delimited by the triple backticks
context:
```During the 2011–12 season, he set the La Liga and European records\
for most goals scored in a single season, while establishing himself as Barcelona's\
all-time top scorer. The following two seasons, Messi finished second for the Ballon\
d'Or behind Cristiano Ronaldo (his perceived career rival), before regaining his best\
form during the 2014–15 campaign, becoming the all-time top scorer in La Liga and \
leading Barcelona to a historic second treble, after which he was awarded a fifth \
Ballon d'Or in 2015. Messi assumed captaincy of Barcelona in 2018, and won a record\
sixth Ballon d'Or in 2019. Out of contract, he signed for French club Paris Saint-Germain\
in August 2021, spending two seasons at the club and winning Ligue 1 twice. Messi \
joined American club <h> Inter Miami <h> in July 2023, winning the Leagues Cup in August of that year.```
- Use the loaded
pipelineto generate questions their answer isInter Miami:
outputs = pipe(prompt, num_return_sequences=3, num_beams=5, num_beam_groups=5, diversity_penalty=1.0)
for output in outputs:
print(output['generated_text'])
Result:
1. What club did Messi join in the 2023 season?
2. What was Messi's name of the club that won the Leagues Cup on July 20?
3. What club did Messi join in the Leagues Cup in July 2023?
Training and evaluation data
More information needed
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 32
- eval_batch_size: 32
- seed: 42
- gradient_accumulation_steps: 4
- total_train_batch_size: 128
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-06
- lr_scheduler_type: linear
- lr_scheduler_warmup_steps: 1000
- num_epochs: 10
- mixed_precision_training: Native AMP
Training results
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 2.6867 | 0.73 | 500 | 1.9647 |
| 2.0737 | 1.46 | 1000 | 1.8141 |
| 1.9364 | 2.19 | 1500 | 1.7515 |
| 1.8745 | 2.92 | 2000 | 1.7215 |
| 1.8282 | 3.65 | 2500 | 1.7042 |
| 1.803 | 4.38 | 3000 | 1.6913 |
| 1.7797 | 5.11 | 3500 | 1.6796 |
| 1.7592 | 5.84 | 4000 | 1.6749 |
| 1.7435 | 6.57 | 4500 | 1.6697 |
| 1.7427 | 7.3 | 5000 | 1.6667 |
| 1.7245 | 8.04 | 5500 | 1.6614 |
| 1.7211 | 8.77 | 6000 | 1.6621 |
| 1.7137 | 9.5 | 6500 | 1.6608 |
Framework versions
- Transformers 4.38.1
- Pytorch 2.1.2
- Datasets 2.13.1
- Tokenizers 0.15.2
- Downloads last month
- 13
Model tree for mohammedaly22/t5-small-question-generation
Base model
google-t5/t5-smallDataset used to train mohammedaly22/t5-small-question-generation
Space using mohammedaly22/t5-small-question-generation 1
Evaluation results
- BLEUself-reported20.000
- Rouge1self-reported47.690
- Rouge2self-reported26.430
- RougeLself-reported44.150
- RougeLSumself-reported44.150
- METEORself-reported45.840
- BertScoreself-reported91.820