pytorch gpt2 text-generation dataset:aeslc transformers generated_from_trainer email generation email license:apache-2.0
---
license: apache-2.0
tags:
- generated_from_trainer
- email generation
- email
datasets:
- aeslc

widget:
- text: "Hey <NAME>,\n\nThank you for signing up for my weekly newsletter. Before we get started, you'll have to confirm your email address." 
  example_title: "newsletter"
- text: "Hi <NAME>,\n\nI hope this email finds you well. Let me start by saying that I am a big fan of your work." 
  example_title: "fan"
- text: "Greetings <NAME>,\n\nI hope you had a splendid evening at the Company sausage eating festival. I am reaching out because" 
  example_title: "festival"
- text: "Good Morning <NAME>,\n\nI was just thinking to myself about how much I love creating value" 
  example_title: "value"
- text: "URGENT - I need the TPS reports"
  example_title: "URGENT"
- text: "Hi <NAME>,\n\nI hope this email finds you extremely well." 
  example_title: "emails find you"

parameters:
  min_length: 4
  max_length: 96
  length_penalty: 0.7
  no_repeat_ngram_size: 2
  do_sample: False
  num_beams: 8
  early_stopping: True
  repetition_penalty: 2.5
---



# distilgpt2-email-generation

Why write the rest of your email when you can generate it?

```
from transformers import pipeline

model_tag = "pszemraj/distilgpt2-email-generation"
generator = pipeline(
              'text-generation', 
              model=model_tag, 
              use_fast=False,
              do_sample=False,
              early_stopping=True,
            )
            
prompt = """
Hello, 

Following up on the bubblegum shipment."""

generator(
    prompt,
    max_length=64,
) # generate
```

- A script to use this on CPU/command line can be found [here](https://gist.github.com/pszemraj/c1b0a76445418b6bbddd5f9633d1bb7f) :) 
- A more performant (but slightly more compute intensive) version is also available: [gpt-medium](https://huggingface.co/pszemraj/gpt2-medium-email-generation)

> For this model, formatting matters. The results may be (significantly) different between the structure outlined above and `prompt = "Hey, just wanted to ..."` etc.

## Model description

This model is a fine-tuned version of [distilgpt2](https://huggingface.co/distilgpt2) on the `aeslc` dataset.

It achieves the following results on the evaluation set:
- Loss: 2.8176

## Intended uses & limitations

More information needed

## Training and evaluation data

More information needed

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 0.0004
- train_batch_size: 8
- eval_batch_size: 8
- seed: 42
- distributed_type: multi-GPU
- gradient_accumulation_steps: 16
- total_train_batch_size: 128
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: cosine
- num_epochs: 6

### Training results

| Training Loss | Epoch | Step | Validation Loss |
|:-------------:|:-----:|:----:|:---------------:|
| 3.1589        | 1.0   | 129  | 3.0496          |
| 2.9914        | 2.0   | 258  | 2.9224          |
| 2.8058        | 3.0   | 387  | 2.8449          |
| 2.6141        | 4.0   | 516  | 2.8214          |
| 2.6337        | 5.0   | 645  | 2.8109          |
| 2.5428        | 6.0   | 774  | 2.8176          |


### Framework versions

- Transformers 4.20.1
- Pytorch 1.11.0+cu113
- Tokenizers 0.12.1
