{"id":28677484,"url":"https://github.com/theosorus/gpt2-hasktorch","last_synced_at":"2026-03-06T07:31:30.162Z","repository":{"id":293422284,"uuid":"979114191","full_name":"theosorus/GPT2-Hasktorch","owner":"theosorus","description":"GPT2 implementation in Haskell with the Hasktorch library, inspired by Andrej Karpathy's Pytorch implementation.","archived":false,"fork":false,"pushed_at":"2025-06-11T00:22:57.000Z","size":1005,"stargazers_count":24,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-14T00:06:32.429Z","etag":null,"topics":["deep-learning","gpt-2","haskell","hasktorch","transformer"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theosorus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2025-05-07T02:46:34.000Z","updated_at":"2025-06-13T18:44:50.000Z","dependencies_parsed_at":"2025-06-03T02:19:46.975Z","dependency_job_id":null,"html_url":"https://github.com/theosorus/GPT2-Hasktorch","commit_stats":null,"previous_names":["gazeux33/gpt2-haskell","gazeux33/gpt2-hasktorch","theosorus/gpt2-hasktorch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/theosorus/GPT2-Hasktorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theosorus%2FGPT2-Hasktorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theosorus%2FGPT2-Hasktorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theosorus%2FGPT2-Hasktorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theosorus%2FGPT2-Hasktorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theosorus","download_url":"https://codeload.github.com/theosorus/GPT2-Hasktorch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theosorus%2FGPT2-Hasktorch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30165618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T04:43:31.446Z","status":"ssl_error","status_checked_at":"2026-03-06T04:40:30.133Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["deep-learning","gpt-2","haskell","hasktorch","transformer"],"created_at":"2025-06-14T00:06:31.944Z","updated_at":"2026-03-06T07:31:30.113Z","avatar_url":"https://github.com/theosorus.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GPT2 Hasktorch implementation\n\nThe goal of this project is to reproduce GPT-2, created by OpenAI, in the Haskell programming language using the Hasktorch library, drawing inspiration from Andrej Karpathy's implementation in PyTorch.\n\n**Haskell** : https://www.haskell.org/\n\n**Haskorch** : http://hasktorch.org/\n\n**Nano GPT(Karpathy's implementation)** : https://github.com/karpathy/nanoGPT\n\n**GPT2 Paper** : https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf\n\n\u003cbr\u003e\n\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"assets/gpt_image.png\" width=\"300\"\u003e\n\u003c/div\u003e\n\n\n\n\n## GPT2 Parameters\n\n| Parameters       | Value         |\n|----------------|---------------|\n| nBlock      | 12       |\n| nHead        | 12      |\n| nEmbd      | 768         |\n| vocabSize      | 50 257         |\n| nbParameters      | 117M          |\n| seqLen      | 1024          |\n| activation     | gelu          |\n| optimizer     | Adam         |\n\n## Features\n\n- All modules of GPT2 ✅\n- Forward Pass ✅\n- Backward Pass ✅\n- LazyDataloader to manage big txt files ✅\n- variable learning rate ✅\n- complete training ✅\n- use gradient accumation ✅\n- Save the training state ✅\n- Performant training tracker ✅\n- Plot metrics in real time ✅\n- Load and use real GPT2 tokenizer ✅\n\n\n## TODOs\n\n- Variable Batch Size ❌\n- Weights sharing between the input token embedding layer (wte) and the output language modeling head (lm_head) ❌\n- Use Weights Decay ❌\n- Use Flash Attention ❌\n- Use Distributed Data Parallel ❌\n- Generation Function ❌\n  \n\n\n## Launch the program\n\n```bash\ndocker compose up -d  # launch the docker\n```\n\n```bash\nstack run  # launch the main\n```\n\n```bash\nstack test # launch the tests\n```\n\n\n## use Jupyter\n```http://localhost:8890/lab```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheosorus%2Fgpt2-hasktorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheosorus%2Fgpt2-hasktorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheosorus%2Fgpt2-hasktorch/lists"}