🎭 Emotional Tone Rewriter

A Transformer-based NLP model that rewrites sentences into different emotional tones such as:

  • friendly
  • angry
  • sad
  • corporate
  • romantic
  • sarcastic
  • motivational
  • formal
  • cheerful

Built using T5-small, this project includes a complete pipeline: preprocessing, training, evaluation, inference, FastAPI server, and Gradio UI.

πŸš€ Features

βœ“ Rewrite any sentence into a selected emotional tone
βœ“ Fully reproducible training pipeline (PyTorch + HuggingFace)
βœ“ Clean dataset preprocessing (CSV β†’ JSONL)
βœ“ Gradio UI for interactive demos
βœ“ FastAPI server for deployment
βœ“ Evaluation notebook with ROUGE metrics
βœ“ Apache 2.0 licensed (commercial-friendly)
βœ“ Production-grade project structure

πŸ“ Project Structure

emotional-tone-rewriter/
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ raw/
β”‚   β”œβ”€β”€ processed/
β”‚   └── README.md
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config.py
β”‚   β”œβ”€β”€ dataset_preprocessing.py
β”‚   β”œβ”€β”€ train.py
β”‚   β”œβ”€β”€ evaluate.py
β”‚   β”œβ”€β”€ inference.py
β”‚   └── model_utils.py
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api.py
β”‚   └── ui.py
β”œβ”€β”€ model/
β”œβ”€β”€ notebooks/
β”œβ”€β”€ huggingface/
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ LICENSE
└── README.md

πŸ“¦ Installation

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

πŸ”„ Dataset Preprocessing

python -m src.dataset_preprocessing --input data/raw/dataset_raw.csv --output data/processed/dataset_clean.jsonl

πŸ‹οΈ Train Model

python -m src.train

πŸ§ͺ Evaluate

python -m src.evaluate

πŸ€– Inference Example

from src.inference import rewrite_tone
print(rewrite_tone("I can't come today.", "sarcastic"))

🌐 FastAPI Server

uvicorn app.api:app --reload --port 7860

🎨 Gradio UI

python app/ui.py

πŸ“„ License

Apache License 2.0

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for hmnshudhmn24/emotion-rewrite-transformer

Base model

google-t5/t5-small
Finetuned
(2190)
this model