Metadata-Version: 2.1
Name: TorchCRF
Version: 1.0.6
Summary: An Implementation of Conditional Random Fields in pytorch
Home-page: https://github.com/s14t284/TorchCRF
Author: Ryuya Ikeda
Author-email: rikeda71@gmail.com
License: MIT
Description: # Torch CRF
        
        [![CircleCI](https://circleci.com/gh/s14t284/TorchCRF.svg?style=svg)](https://circleci.com/gh/s14t284/TorchCRF) [![Coverage Status](https://coveralls.io/repos/github/s14t284/TorchCRF/badge.svg)](https://coveralls.io/github/s14t284/TorchCRF)
        
        Implementation of CRF (Conditional Random Fields) in PyTorch
        
        ## Requirements
        
        - python3 (>=3.6)
        - PyTorch (>=1.0)
        
        ## Installation
        
            $ pip install TorchCRF
        
        ## Usage
        
        ```python
        >>> import torch
        >>> from TorchCRF import CRF
        >>> device = "cuda" if torch.cuda.is_available() else "cpu"
        >>> batch_size = 2
        >>> sequence_size = 3
        >>> num_labels = 5
        >>> mask = torch.ByteTensor([[1, 1, 1], [1, 1, 0]]).to(device) # (batch_size. sequence_size)
        >>> labels = torch.LongTensor([[0, 2, 3], [1, 4, 1]]).to(device)  # (batch_size, sequence_size)
        >>> hidden = torch.randn((batch_size, sequence_size, num_labels), requires_grad=True).to(device)
        >>> crf = CRF(num_labels)
        ```
        
        ### Computing log-likelihood (used where forward)
        
        ```python
        >>> crf.forward(hidden, labels, mask)
        tensor([-7.6204, -3.6124], device='cuda:0', grad_fn=<ThSubBackward>)
        ```
        
        ### Decoding (predict labels of sequences)
        
        ```python
        >>> crf.viterbi_decode(hidden, mask)
        [[0, 2, 2], [4, 0]]
        ```
        
        ## License
        
        MIT
        
        ## References
        
        - [threelittlemonkeys/lstm-crf-pytorch](https://github.com/threelittlemonkeys/lstm-crf-pytorch)
        - [kmkurn/pytorch-crf](https://github.com/kmkurn/pytorch-crf)
        
Keywords: crf,conditional random fields,nlp,natural language processing
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Text Processing
Description-Content-Type: text/markdown
