{"id":25535579,"url":"https://github.com/mihaicristianfarcas/GPT","last_synced_at":"2026-01-29T02:30:16.577Z","repository":{"id":277008281,"uuid":"930857899","full_name":"Forquosh/GPT","owner":"Forquosh","description":"Generative Pretrained Transformer built from scratch using PyTorch.","archived":false,"fork":false,"pushed_at":"2025-02-11T15:59:16.000Z","size":16968,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T17:23:00.383Z","etag":null,"topics":["feedforward-neural-network","generative-ai","gpt","jupyter-notebook","large-language-models","learning-by-doing","neural-network","python","pytorch","self-attention","transformers"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Forquosh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-02-11T10:25:44.000Z","updated_at":"2025-02-11T16:06:53.000Z","dependencies_parsed_at":"2025-02-11T17:33:32.192Z","dependency_job_id":null,"html_url":"https://github.com/Forquosh/GPT","commit_stats":null,"previous_names":["forquosh/gpt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forquosh%2FGPT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forquosh%2FGPT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forquosh%2FGPT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forquosh%2FGPT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Forquosh","download_url":"https://codeload.github.com/Forquosh/GPT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239774637,"owners_count":19694792,"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":["feedforward-neural-network","generative-ai","gpt","jupyter-notebook","large-language-models","learning-by-doing","neural-network","python","pytorch","self-attention","transformers"],"created_at":"2025-02-20T04:22:03.711Z","updated_at":"2026-01-29T02:30:16.545Z","avatar_url":"https://github.com/Forquosh.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GPT\n\nA PyTorch implementation of a GPT-like language model with text preprocessing utilities.\n\n## Overview\n\nThis project implements a transformer-based language model similar to GPT, designed for character-level text generation. It includes utilities for vocabulary generation and dataset splitting.\n\nIn this example, I tested it on the fabulous book **The Brothers Karamazov**, downloaded from **Project Gutenberg**. Feel free to change the text file or even try training it on an consacrated dataset (like OpenWebText for example), though on larger datasets the `vocab.py` and `split.py` might not work properly.\n\n## Features\n\n- Character-level language modeling\n- Multi-head self-attention mechanism\n- Memory-efficient data loading using memory mapping\n- Text preprocessing utilities\n- Configurable model architecture\n\n## Requirements\n\n- Python 3.9+\n- PyTorch\n- Jupyter Notebooks\n- CUDA (optional, for GPU acceleration, **on Windows**)\n\n## Project Structure\n\n- `vocab.py` - Generates vocabulary from input text\n- `split.py` - Splits text data into training and validation sets\n- `GPT.ipynb` - Main model implementation and training\n\n## Usage\n\n### 1. Initialization\n\n### INITIALIZATION STEPS FOR **MAC OS**\n\nRun the terminal in a directory of choice.\n\nCreate a _Python Virtual Environment_ and _activate_ it:\n\n```bash\npython3 -m venv venv\nsource ./venv/bin/activate\n```\n\nInstall the _MacOS requirements_:\n\n```bash\npip3 install -r requirements_macos.txt\n```\n\n### INITIALIZATION STEPS FOR **WINDOWS**\n\nInstall [Python](https://www.python.org/downloads/) on your system. If you have it already, skip this step.\n\nInstall [Anaconda](https://www.anaconda.com/download). Follow the steps from this link.\n\nOnce installed, run **Anaconda Prompt** in a directory of choice.\n\nCreate a _Python Virtual Environment_ and _activate_ it:\n\n```bash\npython3 -m venv venv\nvenv\\Scripts\\activate\n```\n\nInstall the _Windows requirements_:\n\n```bash\npip3 install -r requirements_windows.txt\n```\n\n### ! These requirements are different. On Windows, PyTorch is installed with _CUDA_ support, if available\n\n### 2. Prepare Your Data\n\nFirst, _add your desired data file and generate the vocabulary from your text_:\n\n```bash\npython3 vocab.py\n```\n\nThen, _split your data into training and validation sets_:\n\n```bash\npython3 split.py\n```\n\n### 2. Train the Model\n\nInstall a _new kernel_ to use in your Jupyter Notebook:\n\n```bash\npython3 -m ipykernel install --user --name=venv --display-name \"GPTKernel\"\n```\n\nRun _Jupyter Notebook_:\n\n```bash\njupyter notebook\n```\n\nOpen `GPT.ipynb`.\n\nSelect `GPTKernel` and run the cells _sequentially_. The notebook contains:\n\n- Model architecture implementation\n- Training loop\n- Text generation functionality\n\n### Model Parameters\n\nThe default hyperparameters are:\n\n- Batch size: 32\n- Block size: 128\n- Maximum training iterations: 300\n- Learning Rate: 2e-5\n- Evaluation: every 50 iterations\n- Embedding dimension: 300\n- Number of heads: 4\n- Number of layers: 4\n- Dropout: 0.2\n\nThese can be adjusted based on your hardware capabilities and requirements.\n\n## Model Architecture\n\nThe model implements a transformer architecture with:\n\n- Multi-head self-attention\n- Position embeddings\n- Layer normalization\n- Feed-forward networks\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihaicristianfarcas%2FGPT","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmihaicristianfarcas%2FGPT","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihaicristianfarcas%2FGPT/lists"}