π 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
Model tree for hmnshudhmn24/emotion-rewrite-transformer
Base model
google-t5/t5-small