sagorbrur / EmailWriter

Email Writer is a GPT-2 based email generator application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Email Writer

Email writer is a gpt-2 based email generator application. It is a fine-tune version of gpt-2-medium model which is trained on this datasets. Model published in huggingface model hub

API request and response schema

request = {
    "prompt": str,
    "token_count": int,
    "temperature": float,
    "n_gen": int,
    "keywords": list
}

response = {
    "status": str,
    "ai_results": [
        {
            "generated_text": str,
            "text_length": int
        },
    ]
}

Installation

Method-1

environment setup using environment.yml file

conda env create -f environment.yml
conda activate email_writer_env

Method-2

pip install -r requirements.txt
# install pytorch >= 1.11
conda install pytorch cudatoolkit=11.3 -c pytorch

Run Application

This application is based one Flask framework. Default port for this application is 5000.

python app.py

Test Application

Change input data in tests/test_app.py to test different inputs.

python -m tests.test_app

or

import requests

data = {
    "prompt": "love to visit again", # subject of the email
    "token_count": 128,
    "temperature": 0.6,
    "n_gen": 4,
    "keywords": ['experience', 'joyfull', 'sea'] # relevant keywords
}

response = requests.post('http://localhost:5000/generate', json=data)
print(response.json())

About

Email Writer is a GPT-2 based email generator application


Languages

Language:Jupyter Notebook 61.5%Language:Python 38.4%Language:Shell 0.1%