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