{"id":15415474,"url":"https://github.com/agasheaditya/handson-transformers","last_synced_at":"2025-10-11T08:30:58.644Z","repository":{"id":254911530,"uuid":"847936346","full_name":"agasheaditya/handson-transformers","owner":"agasheaditya","description":"End-to-end implementation of Transformers using PyTorch from scratch","archived":false,"fork":false,"pushed_at":"2024-10-13T09:23:21.000Z","size":2483,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T18:38:27.215Z","etag":null,"topics":["deep-learning","nlp","python3","pytorch","streamlit","transformers"],"latest_commit_sha":null,"homepage":"https://handson-transformers-production.up.railway.app/","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/agasheaditya.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":"2024-08-26T20:35:04.000Z","updated_at":"2024-10-13T09:23:25.000Z","dependencies_parsed_at":"2025-01-28T18:42:52.044Z","dependency_job_id":null,"html_url":"https://github.com/agasheaditya/handson-transformers","commit_stats":null,"previous_names":["agasheaditya/handson-transformers"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/agasheaditya/handson-transformers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agasheaditya%2Fhandson-transformers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agasheaditya%2Fhandson-transformers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agasheaditya%2Fhandson-transformers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agasheaditya%2Fhandson-transformers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agasheaditya","download_url":"https://codeload.github.com/agasheaditya/handson-transformers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agasheaditya%2Fhandson-transformers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006611,"owners_count":26084148,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","nlp","python3","pytorch","streamlit","transformers"],"created_at":"2024-10-01T17:08:30.664Z","updated_at":"2025-10-11T08:30:57.670Z","avatar_url":"https://github.com/agasheaditya.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hands-on Transformers\n**End-to-end implementation of Transformers using PyTorch from scratch**\n\nReferences:\n- Transformers Blog: https://pastoral-cloudberry-567.notion.site/Transformers-fdc33a784ae64e138bd6bf1e19f2bbdf\n- Attention is all you need: https://arxiv.org/pdf/1706.03762\n- HuggingFace Course: https://huggingface.co/learn/nlp-course/en/chapter1/3?fw=pt \n---\n\nImplementing end to end Transformer model using PyTorch from scratch, and training it to generate paragraphs if given a keyword or phrase as a input. \n\n### Files and usage:\n  - **TransformerModel.py** --\u003e Model class containing all logic and architecture of Transformer model\n  - **train_beta.ipynb** --\u003e Jupyter Notebook to train and do the sample inference on trained model\n  - **trained-transformer_model.pth** --\u003e Trained model checkpoint _(saved state dict)_\n  - **Articles.xlsx** --\u003e Dataset used to train the model (https://www.kaggle.com/datasets/asad1m9a9h6mood/news-articles)\n  - **requirements.txt** --\u003e pip freeze of dependencies \n--- \n\n### Working:\n_The model takes a keyword or phrase, tokenizes it, and then iteratively generates text by predicting the next token in the sequence.\nThe model uses embedding, positional encoding, and an encoder-decoder architecture to generate coherent text.\nSampling strategies like temperature scaling and top-k sampling help to produce varied and natural outputs._\n\n### Setup and Usage: \n* Hardware used:\n  - CPU: Intel i7-10750H (2.60 GHz)\n  - RAM: 16 GB\n  - GPU: NVIDIA GeForce RTX 2060 (6 GB)\n    \n* Create virtual environment\n```code\nvirtualenv env\n```\n\n* Activate virtual environment\n```code\n./env/Scripts/activate\n```\n\n* Installing dependancies\n```code\npip install -r requirements.txt\n```\n---\n\n### Dashboard:\nDashboard which can generate the paragrph using the trained model if given a keyword or phrase as a input. \n* Running a Streamlit app\n```code\nstreamlit run app.py\n```\n\n![Streamlit App](https://github.com/user-attachments/assets/7d373d93-5bdb-4f27-8686-55547e30801f)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagasheaditya%2Fhandson-transformers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagasheaditya%2Fhandson-transformers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagasheaditya%2Fhandson-transformers/lists"}