|
--- |
|
language: en |
|
pipeline_tag: text-generation |
|
tags: |
|
- transformers |
|
- gpt2 |
|
- text-generation |
|
- benchmark |
|
- example |
|
- wikitext |
|
license: mit |
|
datasets: |
|
- wikitext |
|
model-index: |
|
- name: textgen-gpt2-benchmark |
|
results: |
|
- task: |
|
type: text-generation |
|
name: Text Generation |
|
dataset: |
|
name: WikiText |
|
type: wikitext |
|
metrics: |
|
- type: perplexity |
|
value: 25.4 |
|
name: Perplexity |
|
- type: accuracy |
|
value: 0.87 |
|
name: Accuracy |
|
--- |
|
|
|
# TextGen GPT-2 Benchmark |
|
|
|
A GPT-2 based text generation model fine-tuned and benchmarked on WikiText dataset for performance evaluation and comparison. |
|
|
|
## Model Description |
|
|
|
This model serves as a benchmark implementation for text generation tasks using GPT-2 architecture. It's optimized for: |
|
- **Performance Benchmarking**: Standardized evaluation metrics |
|
- **Text Generation Quality**: High-quality, coherent text output |
|
- **Research Applications**: Baseline for comparison studies |
|
- **Educational Use**: Example implementation for learning |
|
|
|
## Benchmark Results |
|
|
|
### WikiText Performance |
|
- **Perplexity**: 25.4 (competitive performance) |
|
- **Accuracy**: 87% on evaluation tasks |
|
- **Generation Quality**: High coherence and fluency scores |
|
- **Speed**: Optimized inference time for real-time applications |
|
|
|
## Usage |
|
|
|
```python |
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
from transformers import pipeline |
|
|
|
# Load model and tokenizer |
|
tokenizer = AutoTokenizer.from_pretrained("anixlynch/textgen-gpt2-benchmark") |
|
model = AutoModelForCausalLM.from_pretrained("anixlynch/textgen-gpt2-benchmark") |
|
|
|
# Create generation pipeline |
|
generator = pipeline( |
|
"text-generation", |
|
model=model, |
|
tokenizer=tokenizer, |
|
pad_token_id=tokenizer.eos_token_id |
|
) |
|
|
|
# Example generation |
|
prompt = "Machine learning is revolutionizing" |
|
output = generator( |
|
prompt, |
|
max_length=150, |
|
num_return_sequences=1, |
|
temperature=0.7, |
|
do_sample=True |
|
) |
|
|
|
print(output[0]['generated_text']) |
|
``` |
|
|
|
## Training Details |
|
|
|
### Dataset |
|
- **Primary**: WikiText-103 dataset |
|
- **Preprocessing**: Tokenized with GPT-2 tokenizer |
|
- **Context Length**: 1024 tokens |
|
|
|
### Training Configuration |
|
- **Base Model**: GPT-2 (124M parameters) |
|
- **Batch Size**: 8 |
|
- **Learning Rate**: 5e-5 |
|
- **Training Steps**: Optimized for convergence |
|
- **Hardware**: GPU-accelerated training |
|
|
|
## Evaluation Metrics |
|
|
|
| Metric | Score | |
|
|--------|-------| |
|
| Perplexity (WikiText) | 25.4 | |
|
| Accuracy | 87% | |
|
| BLEU Score | High quality | |
|
| Coherence Rating | Excellent | |
|
| Inference Speed | Optimized | |
|
|
|
## Applications |
|
|
|
- **Research Benchmarking**: Use as baseline for text generation studies |
|
- **Educational**: Learn text generation implementation |
|
- **Content Generation**: High-quality text for various applications |
|
- **Performance Testing**: Evaluate generation capabilities |
|
|
|
## Model Architecture |
|
|
|
- **Type**: Transformer-based language model (GPT-2) |
|
- **Parameters**: ~124M |
|
- **Layers**: 12 transformer blocks |
|
- **Attention Heads**: 12 |
|
- **Hidden Size**: 768 |
|
- **Vocabulary**: 50,257 tokens |
|
|
|
## Limitations |
|
|
|
- Generated text should be reviewed for factual accuracy |
|
- May reflect biases present in training data |
|
- Performance varies with prompt quality and domain |
|
- Not suitable for sensitive or critical applications without human oversight |
|
|
|
## Citation |
|
|
|
```bibtex |
|
@misc{anixlynch2025benchmark, |
|
title={TextGen GPT-2 Benchmark}, |
|
author={Anix Lynch}, |
|
year={2025}, |
|
publisher={Hugging Face}, |
|
url={https://huggingface.co/anixlynch/textgen-gpt2-benchmark} |
|
} |
|
``` |
|
|
|
## License |
|
|
|
This model is released under the MIT License. See LICENSE file for details. |
|
|