gpt-2-Pytorch  by graykode

Simple text generator with OpenAI GPT-2 PyTorch implementation

created 6 years ago
1,005 stars

Top 37.8% on sourcepulse

GitHubView on GitHub
Project Summary

This repository provides a simplified PyTorch implementation of OpenAI's GPT-2 text generation model. It's designed for researchers and developers interested in experimenting with GPT-2's capabilities without the complexity of the original TensorFlow implementation. The project aims to offer a more accessible way to explore large language models.

How It Works

The implementation leverages the Transformer architecture, specifically the self-attention mechanism, as detailed in the "Attention Is All You Need" paper. It focuses on next-word prediction, a core component of GPT-2's generative process. The code is compressed for simplicity, making it easier to understand and modify.

Quick Start & Requirements

  • Install: Clone the repository and install dependencies via pip install -r requirements.txt.
  • Model: Download the pre-trained PyTorch model from Hugging Face.
  • Run: Execute python main.py --text "Your starting sentence."
  • Dependencies: PyTorch (0.41+), regex (2017.4.5). Mac OS users require additional setup including libomp and environment variables.
  • Resources: Requires downloading a pre-trained model file.
  • Docs: OpenAI Blog, GPT-2 Paper, Transformer Paper.

Highlighted Details

  • Simplified PyTorch implementation of GPT-2.
  • Focus on text generation.
  • References to key papers and Hugging Face's BERT implementation for detailed understanding.
  • Offers parameters like temperature and top_k for controlling generation diversity.

Maintenance & Community

The project is authored by Tae Hwan Jung (@graykode). Acknowledgements are given to Jeff Wu and Thomas Wolf for code reference. No specific community channels or roadmap are detailed in the README.

Licensing & Compatibility

The project follows the MIT license, aligning with the original GPT-2 repository. It is compatible with commercial use and closed-source linking.

Limitations & Caveats

This is a simplified implementation and may not include all features or optimizations of the official OpenAI release. The README specifies PyTorch 0.41+, which is an older version, potentially requiring careful dependency management.

Health Check
Last commit

6 years ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
13 stars in the last 90 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n) and Georgios Konstantopoulos Georgios Konstantopoulos(CTO, General Partner at Paradigm).

mlx-gpt2 by pranavjad

0.5%
393
Minimal GPT-2 implementation for educational purposes
created 1 year ago
updated 1 year ago
Feedback? Help us improve.