Spaces:
Sleeping
Sleeping
File size: 4,021 Bytes
6a6b31d f8a5148 c9ca991 763b6bb 75e9ce0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
---
title: Gpt2 Tinystories Generator
emoji: ๐ข
colorFrom: yellow
colorTo: red
sdk: gradio
sdk_version: 5.13.2
app_file: app.py
pinned: false
license: apache-2.0
short_description: Gradio
---
# GPT-2 TinyStories Generator ๐ FableWeaver AI
## Overview
This project fine-tunes a **GPT-2 model** on the **TinyStories dataset** to generate structured, coherent, and engaging short narratives. The model is hosted on **Hugging Face Spaces** and provides a user-friendly interface for story generation.
## Features
- โ
**Story Generation:** Produces structured, child-friendly short stories.
- โ
**Bias Monitoring:** Ensures balanced gender and cultural representation.
- โ
**Efficient Training:** Fine-tuned on **200,000 training samples** and **20,000 test samples**.
- โ
**Grammar & Readability Enhancements:** Integrated grammar-checking tools and text refinement.
- โ
**Optimized Performance:** Uses loss tracking, sampling techniques, and bias mitigation strategies.
## ๐ System Architecture
The model is designed for easy interaction via Hugging Face Spaces and follows this workflow:
1. **Data Preprocessing & Cleaning**
- Tokenization, formatting, and encoding normalization.
- Bias mitigation and balanced data preparation.
2. **Model Fine-Tuning**
- Fine-tuned **GPT-2 (124M parameters)** using **Hugging Face Transformers**.
- Hyperparameter optimization (batch size, learning rate, weight decay).
3. **Story Generation Pipeline**
- Uses **top-k filtering (k=50)**, **top-p nucleus sampling (p=0.9)**, and **temperature adjustments**.
4. **Post-Processing & Bias Mitigation**
- Contextual reinforcement and diversity-aware storytelling.
- No-repeat n-gram settings and logical scene transitions.
5. **Evaluation & Performance Monitoring**
- Tracked using **Weights & Biases (W&B)** and **TensorBoard**.
- Analyzed validation loss and coherence checks.
## ๐น Getting Started
### Accessing the Model
The model is available on **Hugging Face Spaces**: [GPT-2 TinyStories Generator](https://huggingface.co/spaces/cpv2280/gpt2-tinystories-generator)
### Usage Instructions
1. Visit the **Hugging Face Space** linked above.
2. Enter a prompt (e.g., *"Once upon a time..."*) in the input field.
3. Click **Generate** to receive an AI-generated short story.
4. Modify the prompt and settings (temperature, top-k, top-p) for different results.
## ๐ Training Details
- **Model:** GPT-2 (124M)
- **Dataset:** RonenEldan/TinyStories
- **Training:** 3 epochs on Google Colab GPU (T4)
- **Loss Metrics:**
- Training Loss: **3.08 โ 2.86**
- Validation Loss: **1.46 โ 1.40**
## ๐ Evaluation & Observations
- **Perplexity improved from 8.12 โ 2.09**, indicating better text fluency.
- **Validation loss decreased consistently**, suggesting effective generalization.
- **Human evaluation highlighted minor inconsistencies**, such as abrupt scene shifts and simplistic narratives.
## โ๏ธ Ethical Considerations
- **Bias Monitoring:** Pronoun analysis and diversity checks to ensure fairness.
- **Harmful Content Mitigation:** Manually reviewed outputs for stereotypes.
- **Text Processing Issues:** UTF-8 encoding applied to prevent character errors.
## ๐ฎ Future Improvements
- **Enhancing Creativity:** Fine-tune temperature and randomness settings.
- **Genre-Specific Training:** Introduce theme-based datasets.
- **Larger Model Training:** Experiment with **GPT-2 (355M)** for richer storytelling.
## ๐ค Contributors
- **Charla Pia Vella** (Project Developer)
- **Affiliation:** ARI3333 Generative AI
## ๐ License
This project is released under the **Apache-2.0 License**.
## ๐ Acknowledgments
- **OpenAI** for GPT-2
- **Hugging Face** for the fine-tuning framework
- **Ronen Eldan** for the TinyStories dataset
๐ For more details, visit the [Hugging Face Space](https://huggingface.co/spaces/cpv2280/gpt2-tinystories-generator).
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|