Skip to main content

Sequence Tagger for Partially Annotated Dataset in PyTorch

This is a CRF tagger for partially annotated dataset in PyTorch. You can easily utilize marginal log likelihood for CRF (Tsuboi, et al., 2008). The implementation of this library is based on Rush, 2020.

Usage

First, import some modules as follows.

from partial_tagger.crf.nn import CRF
from partial_tagger.crf import functional as F

Initialize CRF by giving it the number of tags.

num_tags = 2
crf = CRF(num_tags)

Prepare incomplete tag sequence (partial annotation) and convert it to a tag bitmap.
This tag bitmap represents the target value for CRF.

# 0-1 indicates a true tag
# -1 indicates that a tag is unknown
incomplete_tags = torch.tensor([[0, 1, 0, 1, -1, -1, -1, 1, 0, 1]])

tag_bitmap = F.to_tag_bitmap(incomplete_tags, num_tags=num_tags, partial_index=-1)

Compute marginal log likelihood from logits.

batch_size = 1
sequence_length = 10
# Dummy logits
logits = torch.randn(batch_size, sequence_length, num_tags)

log_potentials = crf(logits)

loss = F.marginal_log_likelihood(log_potentials, tag_bitmap).sum().neg()

Installation

To install this package:

pip install partial-tagger

References

  • Yuta Tsuboi, Hisashi Kashima, Shinsuke Mori, Hiroki Oda, and Yuji Matsumoto. 2008. Training Conditional Random Fields Using Incomplete Annotations. In Proceedings of the 22nd International Conference on Computational Linguistics (Coling 2008), pages 897–904, Manchester, UK. Coling 2008 Organizing Committee.
  • Alexander Rush. 2020. Torch-Struct: Deep Structured Prediction Library. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pages 335–342, Online. Association for Computational Linguistics.

Metadata

Release files for partial-tagger 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for partial-tagger 0.6.1
File Size Uploaded Provenance Actions
partial-tagger-0.6.1.tar.gz 7.7 kB Without provenance Details for partial-tagger-0.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for partial-tagger 0.6.1
File Interpreter ABI Platform Actions
partial_tagger-0.6.1-py3-none-any.whl Python 3 none any Details for partial_tagger-0.6.1-py3-none-any.whl

Total release size: 18.1 kB

Release files / partial-tagger-0.6.1.tar.gz

Download URL partial-tagger-0.6.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7dc0e818636c9f2a7a9b685aaeec34699455a0d593790da7cd386cfe4d4bfbfd
BLAKE2b-256 checksum
How to use checksums
2f06ac85e5e8893d5454298d0839eb04002f1ae37a6c81013d61618a574aa598
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / partial_tagger-0.6.1-py3-none-any.whl

Download URL partial_tagger-0.6.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63ce20f638708b6868804ab17ab0da9943338042c75b1e56bce4c3c1156fba84
BLAKE2b-256 checksum
How to use checksums
791264b179c718320c085852a183747fb9984f076be8b3b5cffbe46ecda4ec5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for partial-tagger 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page