Skip to main content

sequence-classifier

sequence-classifier is an open-source library designed for sequence classification in PyTorch. It provides utilities for sequence classifiers, particularly Conditional random fields (CRFs), and it can calculate the log likelihood of tag sequences and retrieve the best label sequences. sequence-classifier also offers the capability to compute the marginal log likelihood and the marginal probability. These features are handy when working with partially annotated datasets.

If you are searching for libraries to handle sequence labeling tasks such as named-entity recognition or part-of-speech tagging combined with the use of foundation models like BERT, RoBERTa, or DeBERTa, you will find sequence-classifier to be helpful.

Prerequisites

  • Python 3.8+

Installation

You can install sequence-classifier via pip:

pip install sequence-classifier

Basic Usage

import torch
from sequence_classifier.crf import Crf

batch_size = 3
sequence_length = 15
num_tags = 6

logits = torch.randn(batch_size, sequence_length, num_tags)
tag_indices = torch.randint(0, num_tags, (batch_size, sequence_length))

model = Crf(num_tags)

dist = model(logits)

nll_loss = dist.log_likelihood(tag_indices).sum().neg()
best_sequence = dist.argmax

References

  • 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.
  • 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.

Metadata

Release files for sequence-classifier 0.1.4

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

Source distribution (sdist)

Source distribution for sequence-classifier 0.1.4
File Size Uploaded Provenance Actions
sequence_classifier-0.1.4.tar.gz 12.3 kB Without provenance Details for sequence_classifier-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sequence-classifier 0.1.4
File Interpreter ABI Platform Actions
sequence_classifier-0.1.4-py3-none-any.whl Python 3 none any Details for sequence_classifier-0.1.4-py3-none-any.whl

Total release size: 19.7 kB

Release files / sequence_classifier-0.1.4.tar.gz

Download URL sequence_classifier-0.1.4.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cb8cc48a43c46a48814b771b1a004e3fb119cfac17b502903f98229b563ecb02
BLAKE2b-256 checksum
How to use checksums
fe4b835296a4445b02b9f24e63cde5c22a97abee85ee0fc270a03a821c32fc4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / sequence_classifier-0.1.4-py3-none-any.whl

Download URL sequence_classifier-0.1.4-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
173521d28e7fbe0ad2eccb79fbabe6cdb745cd56f0d57b1bc558c8f0f7da1fdf
BLAKE2b-256 checksum
How to use checksums
b16300ea27b7b1044a748696dfafe2cd91684366179070287a9aeced68d8a76a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for sequence-classifier 0.1.4

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