File size: 2,435 Bytes
1f59e8d
 
 
 
 
 
27cd12c
 
 
 
 
 
 
2113392
 
 
1f59e8d
 
 
 
 
 
 
27cd12c
1f59e8d
 
27cd12c
1f59e8d
27cd12c
1f59e8d
27cd12c
1f59e8d
27cd12c
1f59e8d
27cd12c
 
1f59e8d
27cd12c
 
 
 
 
1f59e8d
27cd12c
 
 
 
 
 
 
1f59e8d
27cd12c
 
1f59e8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27cd12c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
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: []
---

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

# 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