--- library_name: transformers license: apache-2.0 base_model: distilbert/distilgpt2 tags: - generated_from_trainer datasets: - benchaffe/shakespeare-lines language: - en metrics: - perplexity pipeline_tag: text-generation model-index: - name: shakespeare-distilgpt2 results: [] --- # shakespeare-distilgpt2 This model is a fine-tuned version of [distilbert/distilgpt2](https://huggingface.co/distilbert/distilgpt2) on the [shakespeare-lines](https://huggingface.co/benchaffe/shakespeare-lines) dataset. It achieves the following results on the evaluation set: - Loss: 4.2490 - Perplexity: 74.01 ## Training and evaluation data The training and evaluation data was taken from the [shakespeare-lines](https://huggingface.co/benchaffe/shakespeare-lines) dataset. The dataset was shuffled with a seed of 24, and split into training and evaluation with a ratio of 80:20. ## Usage ```python from transformers import AutoModelForCausalLM, AutoTokenizer model = AutoModelForCausalLM.from_pretrained("benchaffe/shakespeare-distilgpt2") tokenizer = AutoTokenizer.from_pretrained("benchaffe/shakespeare-distilgpt2") prompt = "What light through yonder window breaks" inputs = tokenizer(prompt, return_tensors="pt") outputs = model.generate( **inputs, max_length=80, temperature=0.8, top_p=0.95, do_sample=True ) print(tokenizer.decode(outputs[0], skip_special_tokens=True)) ``` ### Training hyperparameters The following hyperparameters were used during training: - learning_rate: 5e-05 - train_batch_size: 4 - eval_batch_size: 4 - seed: 42 - optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments - lr_scheduler_type: linear - num_epochs: 5 ### Training results | Training Loss | Epoch | Step | Validation Loss | |:-------------:|:-----:|:------:|:---------------:| | 3.9479 | 1.0 | 22941 | 4.2781 | | 3.7527 | 2.0 | 45882 | 4.2111 | | 3.5778 | 3.0 | 68823 | 4.2035 | | 3.4214 | 4.0 | 91764 | 4.2129 | | 3.3513 | 5.0 | 114705 | 4.2490 | ### Framework versions - Transformers 4.52.4 - Pytorch 2.6.0+cu124 - Datasets 3.6.0 - Tokenizers 0.21.1