{"id":26644904,"url":"https://github.com/uni-creator/nanogpt","last_synced_at":"2026-05-04T03:36:33.036Z","repository":{"id":284224045,"uuid":"954239405","full_name":"Uni-Creator/NanoGPT","owner":"Uni-Creator","description":"NanoGPT is a lightweight GPT-style language model designed for text generation. It supports training on custom datasets, pretrained model inference, and minimal dependencies for efficient experimentation.","archived":false,"fork":false,"pushed_at":"2025-03-24T19:27:38.000Z","size":18830,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T20:28:03.726Z","etag":null,"topics":["gpt","implementation-from-scratch","machine-learning","nlp","python","pytorch","text-generation","transformers"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Uni-Creator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-24T19:18:08.000Z","updated_at":"2025-03-24T19:31:12.000Z","dependencies_parsed_at":"2025-03-24T20:38:31.745Z","dependency_job_id":null,"html_url":"https://github.com/Uni-Creator/NanoGPT","commit_stats":null,"previous_names":["uni-creator/nanogpt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uni-Creator%2FNanoGPT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uni-Creator%2FNanoGPT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uni-Creator%2FNanoGPT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uni-Creator%2FNanoGPT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Uni-Creator","download_url":"https://codeload.github.com/Uni-Creator/NanoGPT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245352277,"owners_count":20601120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpt","implementation-from-scratch","machine-learning","nlp","python","pytorch","text-generation","transformers"],"created_at":"2025-03-24T21:20:51.025Z","updated_at":"2026-05-04T03:36:33.007Z","avatar_url":"https://github.com/Uni-Creator.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NanoGPT - Shakespeare Text Generation\n\n![GitHub Repo stars](https://img.shields.io/github/stars/Uni-Creator/NanoGPT?style=social)  ![GitHub forks](https://img.shields.io/github/forks/Uni-Creator/NanoGPT?style=social)\n\n## Overview\nNanoGPT is a simple character-level transformer model built from scratch to generate Shakespearean-style text. It uses a custom tokenizer and trains on a dataset extracted from `shakes.txt`. The model is implemented in PyTorch and supports GPU acceleration.\n\n## 📌 Overview\nThe **NANOGPT** project is a lightweight implementation of GPT-style language models. It processes text data and can generate coherent text sequences based on a trained model. The project is designed to be simple and efficient while maintaining flexibility for experimentation.\n\n## 🚀 Features\n- **Lightweight GPT Model**: Efficient architecture for text generation.\n- **Pretrained Model Support**: Load existing `model.pth` for inference.\n- **Customizable Training**: Train on different text datasets.\n- **Evaluation \u0026 Testing**: Evaluate performance using test scripts.\n- **Minimal Dependencies**: Simple setup without heavy frameworks.\n\n## 🏗️ Tech Stack\n- **Python**\n- **PyTorch** (for model training)\n- **NumPy** (for data processing)\n- **Torchvision** (for potential dataset handling)\n- **Matplotlib** (for visualization)\n\n## 📂 Project Structure\n```\nNANOGPT/\n│── __pycache__/              # Cached Python files\n│── main.py                   # Loads trained model and generates text\n│── model.pth                 # Pretrained model checkpoint\n│── Nature_of_Code.pdf        # Reference material for training data\n│── shakes.txt                # Shakespeare dataset used for training\n│── test.py                   # Testing script for evaluation\n│── trainer.py                # Model training script\n│── README.md                 # Project documentation\n```\n\n## 📦 Installation \u0026 Setup\n1. **Prerequisites** - Ensure you have Python 3.8+ and PyTorch installed. If not, install PyTorch using:\n   ```sh\n   pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n   ```\n\n2. **Clone the repository**\n   ```sh\n   git clone https://github.com/Uni-Creator/NanoGPT.git\n   cd NanoGPT\n   ```\n3. **Install dependencies**\n   ```sh\n   pip install torch numpy matplotlib\n   ```\n4. **Train the model (if needed)**\n   ```sh\n   python trainer.py\n   ```\n\n## Usage\n1. **Train the Model** - To train the model from scratch, run:\n   ```sh\n   python trainer.py\n   ```\nThis will generate a `model.pth` file containing the trained weights.\n\n2. **Generate Text** - To generate text using the trained model, run:\n   ```sh\n   python main.py\n   ```\nYou will be prompted to enter a starting text, and the model will generate Shakespearean-style text based on your input.\n\n## Example Output\n```\nEnter text: Enter BERTRAM, the COUNTESS of Rousillon, HELENA, and LAFEU, all in black.\nGenerated text:\nHelena. And you, my lord, sir, captains again.\nFirst Lord. None you shall healt make royal he did\nOf daughter! Be thither was which\nnow wars; it in fither no fetters, or poor him appr.\n```\n\n## Customization\n- Modify `trainer.py` to change model architecture, training hyperparameters, or dataset.\n- Adjust `main.py` to refine text generation.\n\n## 📊 How It Works\n1. The model loads a pretrained `model.pth` or trains from scratch.\n2. It processes an input text prompt.\n3. The model generates a sequence of text based on learned patterns.\n4. The output text is displayed and can be saved.\n\n## 🛠️ Future Improvements\n- Implement Transformer-based architecture for better efficiency.\n- Expand dataset for broader language capabilities.\n- Create an interactive web-based demo.\n\n## 🤝 Contributing\nContributions are welcome! Feel free to open an **issue** or submit a **pull request**.\n\n## 📄 License\nThis project is licensed under the **MIT License**.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funi-creator%2Fnanogpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funi-creator%2Fnanogpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funi-creator%2Fnanogpt/lists"}