Large language models like ChatGPT and Claude offer exceptional performance in instruction-following tasks but often suffer from large sizes and high latency, making them challenging to deploy for local or academic use. This project addresses the need for smaller, low-latency models that can perform similarly to their larger counterparts. By fine-tuning a small pre-trained model (T5-Base 250M) using synthetic data generated from the larger Mistral 7B model, we aim to improve performance in instruction-following tasks while maintaining the benefits of smaller model sizes, including reduced computational requirements and faster response times.
To mitigate the issues posed by large models, we implement instruction tuning for the T5-Base model. This process involves using data generated by the Mistral 7B model to fine-tune the smaller T5-Base model, aiming to improve its accuracy on instruction-based tasks. Fine-tuning is performed in a supervised manner, where the model is trained to predict each token in the output sequence based on the input and instruction.
The project demo is available in the Jupyter Notebook file demo.ipynb.
As we can see, our fine-tuned model follows the instruction and translates the text into French, while the base model fails to follow the instruction properly.

The instruction tuning process follows these steps:
declare-lab on GitHub.
We evaluated the fine-tuned T5-Base model using two main benchmarks:
Big Bench Hard (BBH):
After fine-tuning, the accuracy drops, likely due to the lack of diversity in the data used for fine-tuning.
Massive Multitask Language Understanding (MMLU):
Fine-tuning slightly improved accuracy on MMLU tasks, which evaluate models across 57 subjects, ranging from elementary to advanced levels.
For comparison, the FLAN-T5-Base model, already fine-tuned by Google, was evaluated on the same benchmarks:
| Model/Benchmark | Big Bench Hard (BBH) | MMLU |
|---|---|---|
| T5-Base (~250M) (Before Fine-tuning) | 27.8% | 25.7% |
| T5-Base (~250M) (After Fine-tuning) | 17.2% | 26.4% |
| Flan-T5-Base (~250M) (Before Fine-tuning) | 31.3% | 35.9% |
| Flan-T5-Base (~250M) (After Fine-tuning) | 27.29% | 32.4% |
Fine-tuning the T5-Base model with synthetic data generated from Mistral 7B improves its performance on some benchmarks but also reveals the limitations of using smaller models for complex tasks. While the model performs better on MMLU after fine-tuning, its performance on BBH decreases due to the noisy and non-diverse data used for fine-tuning. Future work can explore improving the data generation process or using more powerful models to generate training data for better results.
To use this model in your own projects:
Install the required libraries:
pip install transformers torch
Load the Fine-tuned Model and Tokenizer:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("SanketAI/FLAN-T5_instruct-mistral7b")
model = AutoModelForSeq2SeqLM.from_pretrained("SanketAI/FLAN-T5_instruct-mistral7b")
input_text = "Translate the following English text to French: 'Hello, how are you?'"
inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
outputs = model.generate(inputs["input_ids"], max_length=50, num_beams=5, early_stopping=True)
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_text)
13 commits
Python
84.8%
Jupyter Notebook
15.2%
Large language models like ChatGPT and Claude offer exceptional performance in instruction-following tasks but often suffer from large sizes and high latency, making them challenging to deploy for local or academic use. This project addresses the need for smaller, low-latency models that can perform similarly to their larger counterparts. By fine-tuning a small pre-trained model (T5-Base 250M) using synthetic data generated from the larger Mistral 7B model, we aim to improve performance in instruction-following tasks while maintaining the benefits of smaller model sizes, including reduced computational requirements and faster response times.
To mitigate the issues posed by large models, we implement instruction tuning for the T5-Base model. This process involves using data generated by the Mistral 7B model to fine-tune the smaller T5-Base model, aiming to improve its accuracy on instruction-based tasks. Fine-tuning is performed in a supervised manner, where the model is trained to predict each token in the output sequence based on the input and instruction.
The project demo is available in the Jupyter Notebook file demo.ipynb.
As we can see, our fine-tuned model follows the instruction and translates the text into French, while the base model fails to follow the instruction properly.

The instruction tuning process follows these steps:
declare-lab on GitHub.
We evaluated the fine-tuned T5-Base model using two main benchmarks:
Big Bench Hard (BBH):
After fine-tuning, the accuracy drops, likely due to the lack of diversity in the data used for fine-tuning.
Massive Multitask Language Understanding (MMLU):
Fine-tuning slightly improved accuracy on MMLU tasks, which evaluate models across 57 subjects, ranging from elementary to advanced levels.
For comparison, the FLAN-T5-Base model, already fine-tuned by Google, was evaluated on the same benchmarks:
| Model/Benchmark | Big Bench Hard (BBH) | MMLU |
|---|---|---|
| T5-Base (~250M) (Before Fine-tuning) | 27.8% | 25.7% |
| T5-Base (~250M) (After Fine-tuning) | 17.2% | 26.4% |
| Flan-T5-Base (~250M) (Before Fine-tuning) | 31.3% | 35.9% |
| Flan-T5-Base (~250M) (After Fine-tuning) | 27.29% | 32.4% |
Fine-tuning the T5-Base model with synthetic data generated from Mistral 7B improves its performance on some benchmarks but also reveals the limitations of using smaller models for complex tasks. While the model performs better on MMLU after fine-tuning, its performance on BBH decreases due to the noisy and non-diverse data used for fine-tuning. Future work can explore improving the data generation process or using more powerful models to generate training data for better results.
To use this model in your own projects:
Install the required libraries:
pip install transformers torch
Load the Fine-tuned Model and Tokenizer:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("SanketAI/FLAN-T5_instruct-mistral7b")
model = AutoModelForSeq2SeqLM.from_pretrained("SanketAI/FLAN-T5_instruct-mistral7b")
input_text = "Translate the following English text to French: 'Hello, how are you?'"
inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
outputs = model.generate(inputs["input_ids"], max_length=50, num_beams=5, early_stopping=True)
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_text)
13 commits
Python
84.8%
Jupyter Notebook
15.2%