This model is a fine-tuned version of distilroberta-base specialized to complete positive, inspirational quotes. It was trained on the Abirate/english_quotes dataset. The project demonstrates transfer learning by taking a general-purpose model and specializing it for a niche task, resulting in a model that outperforms its base version on that task. It achieves the following results on the evaluation set:
The goal of this project was to fine-tune the distilroberta-base model to specialize in completing inspirational quotes, making it more contextually relevant and accurate for this specific task compared to the base model.
You can use this model directly with a pipeline for fill-mask tasks:
from transformers import pipeline
# Load the fine-tuned model from the Hub
fine_tuned_pipe = pipeline("fill-mask", model="Boinbo/distilroberta-inspirational-quotes")
# Define a prompt
prompt = f"The only way to do great work is to {fine_tuned_pipe.tokenizer.mask_token} what you do."
# Get predictions
print(fine_tuned_pipe(prompt))
# Expected output might include words like "love", "enjoy", etc.
The fine-tuned model provides more contextually relevant predictions for inspirational quotes compared to the original distilroberta-base model.
| Prompt | Base Model (distilroberta-base) Output |
Fine-Tuned Model Output |
|---|---|---|
The secret to getting ahead is getting <mask> |
1. ahead (0.19) 2. married (0.13) 3. started (0.04) 4. drunk (0.03) |
1. ahead (0.55) 2. started (0.06) 3. prepared (0.02) 4. ready (0.02) |
As shown, the fine-tuned model correctly identifies "started" as a more probable completion than the base model and removes irrelevant suggestions like "married" and "drunk".
AutoModelForMaskedLM: Loading the distilroberta-base model.AutoTokenizer: Loading the correct tokenizer for the model.Trainer and TrainingArguments: Managing the fine-tuning loop.pipeline: For easy inference with the final model.train split of the Abirate/english_quotes dataset.DataCollatorForLanguageModeling to randomly mask tokens. The model was then trained using the Trainer class from the transformers library.The following hyperparameters were used during the final successful training run:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.7341 | 1.0 | 157 | 1.6612 |
| 1.7427 | 2.0 | 314 | 1.5811 |
| 1.8748 | 3.0 | 471 | 1.5843 |
A key challenge in this project was overcoming initial poor results. The first fine-tuned versions of the model produced garbage output. The investigation revealed three main issues:
learning_rate was too high and the num_train_epochs was excessive. This caused the model's pre-trained weights to be destroyed, leading to nonsensical output. Adjusting the learning rate to 2e-05 and reducing epochs to 3 was critical for a stable training process.pipeline function loading an old, broken version of the model from a local cache in Google Colab. The problem was solved by modifying the testing script to load the model directly from the local output directory (distilroberta-inspirational-quotes/) instead of from the Hugging Face Hub ID, ensuring the most recently trained model was used.This experience highlighted the importance of careful hyperparameter selection for transfer learning, the need to be aware of underlying mechanisms like caching during the development and testing cycle, and the significance of proper dataset selection and splitting.
model.safetensors 329 MBtraining_args.bin 5.4 kB