{"id":18587624,"url":"https://github.com/sgrvinod/a-pytorch-tutorial-to-text-classification","last_synced_at":"2025-06-14T10:33:30.603Z","repository":{"id":53819795,"uuid":"153237357","full_name":"sgrvinod/a-PyTorch-Tutorial-to-Text-Classification","owner":"sgrvinod","description":"Hierarchical Attention Networks | a PyTorch Tutorial to Text Classification","archived":false,"fork":false,"pushed_at":"2020-06-03T03:52:17.000Z","size":729,"stargazers_count":247,"open_issues_count":9,"forks_count":55,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-08T21:03:23.476Z","etag":null,"topics":["attention-mechanism","document-classification","hierarchical-attention-networks","pytorch","pytorch-tutorial","text-classification","text-classifier"],"latest_commit_sha":null,"homepage":"","language":"Python","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/sgrvinod.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}},"created_at":"2018-10-16T06:57:59.000Z","updated_at":"2025-04-14T15:25:39.000Z","dependencies_parsed_at":"2022-08-21T18:20:13.448Z","dependency_job_id":null,"html_url":"https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgrvinod%2Fa-PyTorch-Tutorial-to-Text-Classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgrvinod%2Fa-PyTorch-Tutorial-to-Text-Classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgrvinod%2Fa-PyTorch-Tutorial-to-Text-Classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgrvinod%2Fa-PyTorch-Tutorial-to-Text-Classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgrvinod","download_url":"https://codeload.github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgrvinod%2Fa-PyTorch-Tutorial-to-Text-Classification/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259802313,"owners_count":22913608,"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":["attention-mechanism","document-classification","hierarchical-attention-networks","pytorch","pytorch-tutorial","text-classification","text-classifier"],"created_at":"2024-11-07T00:39:49.219Z","updated_at":"2025-06-14T10:33:30.576Z","avatar_url":"https://github.com/sgrvinod.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a **[PyTorch](https://pytorch.org) Tutorial to Text Classification**.\n\nThis is the fourth in [a series of tutorials](https://github.com/sgrvinod/Deep-Tutorials-for-PyTorch) I plan to write about _implementing_ cool models on your own with the amazing PyTorch library.\n\nBasic knowledge of PyTorch, recurrent neural networks is assumed.\n\nIf you're new to PyTorch, first read [Deep Learning with PyTorch: A 60 Minute Blitz](https://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html) and [Learning PyTorch with Examples](https://pytorch.org/tutorials/beginner/pytorch_with_examples.html).\n\nQuestions, suggestions, or corrections can be posted as issues.\n\nI'm using `PyTorch 1.1` in `Python 3.6`.\n\n---\n\n**27 Jan 2020**: Working code for two new tutorials has been added — [Super-Resolution](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Super-Resolution) and [Machine Translation](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Machine-Translation)\n\n---\n\n# Contents\n\n[***Objective***](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification#objective)\n\n[***Concepts***](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification#tutorial-in-progress)\n\n[***Overview***](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification#tutorial-in-progress)\n\n[***Implementation***](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification#tutorial-in-progress)\n\n[***Training***](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification#tutorial-in-progress)\n\n[***Inference***](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification#tutorial-in-progress)\n\n[***Frequently Asked Questions***](https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Text-Classification#tutorial-in-progress)\n\n# Objective\n\n**To build a model that can label a text document as one of several categories.**\n\n We will be implementing the [Hierarchial Attention Network (HAN)](https://www.cs.cmu.edu/~hovy/papers/16HLT-hierarchical-attention-networks.pdf), one of the more interesting and interpretable text classification models.\n\nThis model not only classifies a document, but also _chooses_ specific parts of the text –  sentences and individual words – that it thinks are most important.\n\n---\n\n\u003e \"I think I'm falling sick. There was some indigestion at first. But now a fever is beginning to take hold.\"\n\n![](./img/health.png)\n\n---\n\n\u003e \"But think about it! It's so cool. Physics is really all about math. What Feynman said, hehe.\"\n\n![](./img/science.png)\n\n---\n\n\u003e \"I want to tell you something important. Get into the stock market and investment funds. Make some money so you can buy yourself some yogurt.\"\n\n![](./img/finance.png)\n\n---\n\n\u003e \"How do computers work? I have a CPU I want to use. But my keyboard and motherboard do not help.\"\n\u003e\n\u003e \"You can just google how computers work. Honestly, its easy.\"\n\n![](./img/computers.png)\n\n---\n\n\u003e \"You know what's wrong with this country? Republicans and democrats. Always at each other's throats\"\n\u003e\n\u003e \"There's no respect, no bipartisanship.\"\n\n![](./img/politics.png)\n\n---\n\n# Tutorial in Progress\n\nI am still writing this tutorial.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./img/incomplete.jpg\"\u003e\n\u003c/p\u003e\n\nIn the meantime, you could take a look at the code – it works!\n\nWe achieve an accuracy of **75.1%** (against **75.8%** in the paper) on the Yahoo Answer dataset.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgrvinod%2Fa-pytorch-tutorial-to-text-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgrvinod%2Fa-pytorch-tutorial-to-text-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgrvinod%2Fa-pytorch-tutorial-to-text-classification/lists"}