| --- |
| title: Conversation Summary Generator |
| emoji: 📝 |
| colorFrom: blue |
| colorTo: green |
| sdk: gradio |
| sdk_version: "6.14.0" |
| python_version: "3.10" |
| app_file: app.py |
| pinned: false |
| --- |
| |
| # Dialogue Summarizer |
|
|
| An interactive Gradio app that summarizes chat-style conversations using a fine-tuned `google/flan-t5-small` model from Hugging Face. |
|
|
| The model was fine-tuned on the [SAMSum](https://huggingface.co/datasets/knkarthick/samsum) dialogue summarization dataset. Users can paste a conversation, click submit, and receive a short generated summary. |
|
|
| ## Demo |
|
|
| ```text |
| Tom: Did you submit the report? |
| Anika: Not yet, I'm fixing the charts. |
| Tom: The deadline is 5 pm. |
| Anika: I know. I'll send it by 4:30. |
| Tom: Great, please copy me on the email. |
| ``` |
|
|
| Expected output: |
|
|
| ```text |
| Anika is fixing the report charts and will send the report by 4:30, copying Tom. |
| ``` |
|
|
| ## Features |
|
|
| - Fine-tuned T5/FLAN-T5 sequence-to-sequence summarization model |
| - Simple Gradio web interface |
| - Built-in example conversations |
| - Beam search generation for better summaries |
| - Local model loading from the `conversation_summarizer/` folder |
|
|
| ## Project Structure |
|
|
| ```text |
| conversation_summarizer/ |
| +-- app.py |
| +-- model.py |
| +-- requirements.txt |
| +-- README.md |
| +-- conversation_summarizer/ |
| +-- config.json |
| +-- generation_config.json |
| +-- model.safetensors |
| +-- spiece.model |
| +-- tokenizer_config.json |
| +-- special_tokens_map.json |
| ``` |
|
|
| ## Setup |
|
|
| Create and activate a virtual environment: |
|
|
| ```bash |
| python -m venv env |
| ``` |
|
|
| Windows: |
|
|
| ```bash |
| env\Scripts\activate |
| ``` |
|
|
| macOS/Linux: |
|
|
| ```bash |
| source env/bin/activate |
| ``` |
|
|
| Install dependencies: |
|
|
| ```bash |
| pip install -r requirements.txt |
| ``` |
|
|
| ## Run The App |
|
|
| ```bash |
| python app.py |
| ``` |
|
|
| Gradio will start a local app and print a URL like: |
|
|
| ```text |
| http://127.0.0.1:7860 |
| ``` |
|
|
| Open the URL in your browser and try one of the example conversations. |
|
|
| ## Example Inputs |
|
|
| ```text |
| Nora: Are you picking up the groceries today? |
| Eli: Yes, after work. |
| Nora: Please get milk, eggs, and bread. |
| Eli: Got it. Anything else? |
| Nora: Bananas if they look fresh. |
| Eli: Okay, I'll be home around 6:30. |
| ``` |
|
|
| ```text |
| Priya: Did you call the dentist? |
| Karan: Yes, they had an opening tomorrow at 11. |
| Priya: Great. Did you book it? |
| Karan: Yes, I confirmed it. |
| Priya: Thanks. I'll leave work early to go. |
| ``` |
|
|
| ```text |
| Sam: The Wi-Fi is down again. |
| Lina: I restarted the router, but it didn't help. |
| Sam: Should I call the provider? |
| Lina: Yes, please. Tell them it stopped working an hour ago. |
| Sam: Okay, I'll call them now. |
| ``` |
|
|
| ## Training |
|
|
| The training script is in `model.py`. |
|
|
| It: |
|
|
| 1. Loads the SAMSum dataset. |
| 2. Loads `google/flan-t5-small`. |
| 3. Tokenizes dialogues as inputs and summaries as labels. |
| 4. Fine-tunes the model with `Seq2SeqTrainer`. |
| 5. Evaluates with ROUGE. |
| 6. Saves the trained model and tokenizer. |
|
|
| Run training with: |
|
|
| ```bash |
| python model.py |
| ``` |
|
|
| Note: training is much faster with a CUDA-enabled GPU. |
|
|
| ## Model Notes |
|
|
| The app expects a saved Hugging Face model folder at: |
|
|
| ```text |
| ./conversation_summarizer |
| ``` |
|
|
| This folder should contain files like: |
|
|
| ```text |
| model.safetensors |
| config.json |
| spiece.model |
| tokenizer_config.json |
| generation_config.json |
| ``` |
|
|
| If you retrain the model and save it to another folder, update this line in `app.py`: |
|
|
| ```python |
| model = T5ForConditionalGeneration.from_pretrained("./conversation_summarizer") |
| tokenizer = T5Tokenizer.from_pretrained("./conversation_summarizer") |
| ``` |
|
|
| ## Evaluation |
|
|
| The model is evaluated using ROUGE: |
|
|
| - `rouge1`: unigram overlap |
| - `rouge2`: bigram overlap |
| - `rougeL`: longest common subsequence overlap |
| - `rougeLsum`: summarization-oriented ROUGE-L |
|
|
| ROUGE scores usually range from `0` to `1`, where higher is better. |
|
|
| ## Before Pushing To GitHub |
|
|
| Do not commit the local virtual environment: |
|
|
| ```text |
| env/ |
| ``` |
|
|
| If the model file is large, consider using Git LFS or uploading the model to the Hugging Face Hub instead of committing `model.safetensors` directly. |
|
|
| Recommended `.gitignore`: |
|
|
| ```gitignore |
| env/ |
| __pycache__/ |
| *.pyc |
| .ipynb_checkpoints/ |
| results/ |
| logs/ |
| ``` |
|
|
| ## Git Commands |
|
|
| Initialize the repo: |
|
|
| ```bash |
| git init |
| git add app.py model.py requirements.txt README.md conversation_summarizer/ |
| git commit -m "Add dialogue summarizer app" |
| ``` |
|
|
| Connect to GitHub: |
|
|
| ```bash |
| git branch -M main |
| git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git |
| git push -u origin main |
| ``` |
|
|
| ## Tech Stack |
|
|
| - Python |
| - Hugging Face Transformers |
| - Hugging Face Datasets |
| - Evaluate |
| - ROUGE |
| - Gradio |
| - FLAN-T5 |
|
|
| ## Limitations |
|
|
| This is a small fine-tuned model, so it may occasionally miss details or infer something incorrectly. It works best when the dialogue clearly identifies speakers, actions, and decisions. |
|
|