{"id":19345179,"url":"https://github.com/rikeda71/torchcrf","last_synced_at":"2026-03-10T12:30:48.737Z","repository":{"id":49357685,"uuid":"156511147","full_name":"rikeda71/TorchCRF","owner":"rikeda71","description":"An Inplementation of CRF (Conditional Random Fields) in PyTorch 1.0","archived":false,"fork":false,"pushed_at":"2020-08-01T09:26:36.000Z","size":65,"stargazers_count":136,"open_issues_count":4,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-01T14:46:31.786Z","etag":null,"topics":["conditional-random-fields","crf","named-entity-recognition","ner","pytorch"],"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/rikeda71.png","metadata":{"files":{"readme":"README.ja.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-11-07T08:03:53.000Z","updated_at":"2024-11-17T07:08:38.000Z","dependencies_parsed_at":"2022-08-27T22:55:00.688Z","dependency_job_id":null,"html_url":"https://github.com/rikeda71/TorchCRF","commit_stats":null,"previous_names":["rikeda71/torchcrf","s14t284/torchcrf"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikeda71%2FTorchCRF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikeda71%2FTorchCRF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikeda71%2FTorchCRF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rikeda71%2FTorchCRF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rikeda71","download_url":"https://codeload.github.com/rikeda71/TorchCRF/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227763246,"owners_count":17816141,"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":["conditional-random-fields","crf","named-entity-recognition","ner","pytorch"],"created_at":"2024-11-10T04:05:14.583Z","updated_at":"2025-11-05T04:02:17.421Z","avatar_url":"https://github.com/rikeda71.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Torch CRF\n\n[![CircleCI](https://circleci.com/gh/s14t284/TorchCRF.svg?style=svg)](https://circleci.com/gh/s14t284/TorchCRF)\n[![Coverage Status](https://coveralls.io/repos/github/s14t284/TorchCRF/badge.svg)](https://coveralls.io/github/s14t284/TorchCRF)\n[![MIT License](https://img.shields.io/github/license/s14t284/TorchCRF)](LICENSE)\n\n[![Python Versions](https://img.shields.io/pypi/pyversions/TorchCRF.svg)](https://pypi.org/project/TorchCRF/)\n[![PyPI version](https://badge.fury.io/py/TorchCRF.svg)](https://badge.fury.io/py/TorchCRF)\n\nPyTorch 1.0 による条件付き確率場 (CRF) の実装\n\n## Requirements\n\n- python3 (\u003e=3.6)\n- PyTorch 1.0\n\n## Installation\n\n    $ pip install TorchCRF\n\n## Usage\n\n```python\n\u003e\u003e\u003e import torch\n\u003e\u003e\u003e from TorchCRF import CRF\n\u003e\u003e\u003e batch_size = 2\n\u003e\u003e\u003e sequence_size = 3\n\u003e\u003e\u003e num_labels = 5\n\u003e\u003e\u003e mask = torch.FloatTensor([[1, 1, 1], [1, 1, 0]]) # (batch_size. sequence_size)\n\u003e\u003e\u003e labels = torch.LongTensor([[0, 2, 3], [1, 4, 1]])  # (batch_size, sequence_size)\n\u003e\u003e\u003e hidden = torch.randn((batch_size, sequence_size, num_labels), requires_grad=True)\n\u003e\u003e\u003e crf = CRF(num_labels)\n```\n\n### 推論\n\n```python\n\u003e\u003e\u003e crf.forward(hidden, labels, mask)\ntensor([-7.6204, -3.6124], grad_fn=\u003cThSubBackward\u003e)\n```\n\n### 系列ラベルの予測\n\n```python\n\u003e\u003e\u003e crf.viterbi_decode(hidden, mask)\n[[0, 2, 2], [4, 0]]\n```\n\n## License\n\nMIT\n\n## References\n\n- [threelittlemonkeys/lstm-crf-pytorch](https://github.com/threelittlemonkeys/lstm-crf-pytorch)\n- [kmkurn/pytorch-crf](https://github.com/kmkurn/pytorch-crf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frikeda71%2Ftorchcrf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frikeda71%2Ftorchcrf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frikeda71%2Ftorchcrf/lists"}