{"id":16194685,"url":"https://github.com/yasufumy/pytorch-partial-tagger","last_synced_at":"2026-05-02T02:39:25.856Z","repository":{"id":170970481,"uuid":"647175444","full_name":"yasufumy/pytorch-partial-tagger","owner":"yasufumy","description":"Sequence Tagger for Partially Annotated Dataset in PyTorch","archived":false,"fork":false,"pushed_at":"2023-11-23T15:13:23.000Z","size":130,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T08:08:20.853Z","etag":null,"topics":["machine-learning","named-entity-recognition","natural-language-processing","nlp","pytorch","semi-supervised-learning","torch"],"latest_commit_sha":null,"homepage":"https://pytorch-partial-tagger.readthedocs.io/en/latest/","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/yasufumy.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":"2023-05-30T08:11:31.000Z","updated_at":"2023-06-17T15:07:18.000Z","dependencies_parsed_at":"2023-11-11T06:24:48.757Z","dependency_job_id":"37bbb1b1-c0c8-4844-8f5b-1bdb21596d6e","html_url":"https://github.com/yasufumy/pytorch-partial-tagger","commit_stats":null,"previous_names":["yasufumy/pytorch-partial-tagger"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasufumy%2Fpytorch-partial-tagger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasufumy%2Fpytorch-partial-tagger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasufumy%2Fpytorch-partial-tagger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasufumy%2Fpytorch-partial-tagger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yasufumy","download_url":"https://codeload.github.com/yasufumy/pytorch-partial-tagger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247684543,"owners_count":20979073,"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":["machine-learning","named-entity-recognition","natural-language-processing","nlp","pytorch","semi-supervised-learning","torch"],"created_at":"2024-10-10T08:24:30.489Z","updated_at":"2026-05-02T02:39:25.809Z","avatar_url":"https://github.com/yasufumy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytorch-partial-tagger\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/17GcpKmYn49bMM-mCZhiuRu8dkPZ0WXuD?usp=sharing)\n\n`pytorch-partial-tagger` is a Python library for building a sequence tagger, specifically for the common NLP task Named Entity Recognition, with a partially annotated dataset in PyTorch.\nYou can build your own tagger using a distantly-supervised dataset obtained from unlabled text data and a dictionary that maps surface names to their entity type.\nThe algorithm of this library is based on Effland and Collins. (2021).\n\n\n## Usage\n\nImport all dependencies first:\n\n```py\nimport torch\nfrom sequence_label import SequenceLabel\n\nfrom partial_tagger.metric import Metric\nfrom partial_tagger.utils import create_trainer\n```\n\nPrepare your own datasets. Each item of dataset must have a pair of a string and a sequence label.\nA string represents text that you want to assign a label, which is defined as `text` below.\nA sequence label represent a set of a character-based tag, which has a start, a length, and a label, which are defined as `label` below.\nA start represents a position in the text where a tag starts.\nA length represents a distance in the text between the beginning of a tag and the end of a tag.\nA label represents what you want to assign to a span of the text defined by a start and a length.\n\n```py\ntext = \"Tokyo is the capital of Japan.\"\nlabel = SequenceLabel.from_dict(\n    tags=[\n        {\"start\": 0,  \"end\": 5, \"label\": \"LOC\"},  # Tag for Tokyo\n        {\"start\": 24,  \"end\": 29, \"label\": \"LOC\"},  # Tag for Japan\n    ],\n    size=len(text),\n)\n\ntrain_dataset = [(text, label), ...]\nvalidation_dataset = [...]\ntest_dataset = [...]\n```\n\nHere, you will train your tagger and evaluate its performance.\nYou will train it through an instance of `Trainer`, which you get by calling `create_trainer`.\nAfter a training, you will get an instance of `Recognizer` which predicts character-based tags from given texts.\nYou will evaluate the performance of your tagger using an instance of `Metric` as follows.\n\n\n```py\n\ndevice = torch.device(\"cuda\")\n\ntrainer = create_trainer()\nrecognizer = trainer(train_dataset, validation_dataset, device)\n\ntexts, ground_truths = zip(*test_dataset)\n\nbatch_size = 15\npredictions = recognizer(texts, batch_size, device)\n\nmetric = Metric()\nmetric(predictions, ground_truths)\n\nprint(metric.get_scores())  # Display F1-score, Precision, Recall\n```\n\n## Installation\n\n```bash\npip install pytorch-partial-tagger\n```\n\n## Documentation\n\nFor details about the `pytorch-partial-tagger` API,  see the [documentation](https://pytorch-partial-tagger.readthedocs.io/en/latest/).\n\n## References\n\n- Thomas Effland and Michael Collins. 2021. [Partially Supervised Named Entity Recognition via the Expected Entity Ratio Loss](https://aclanthology.org/2021.tacl-1.78/). _Transactions of the Association for Computational Linguistics_, 9:1320–1335.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasufumy%2Fpytorch-partial-tagger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyasufumy%2Fpytorch-partial-tagger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasufumy%2Fpytorch-partial-tagger/lists"}