Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sequence_classifier-0.1.4.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

sequence_classifier-0.1.4-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file sequence_classifier-0.1.4.tar.gz.

File metadata

  • Download URL: sequence_classifier-0.1.4.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for sequence_classifier-0.1.4.tar.gz
Algorithm Hash digest
SHA256 cb8cc48a43c46a48814b771b1a004e3fb119cfac17b502903f98229b563ecb02
MD5 bdd9e62619fb23cb675c1fa694ea0c39
BLAKE2b-256 fe4b835296a4445b02b9f24e63cde5c22a97abee85ee0fc270a03a821c32fc4e

See more details on using hashes here.

File details

Details for the file sequence_classifier-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for sequence_classifier-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 173521d28e7fbe0ad2eccb79fbabe6cdb745cd56f0d57b1bc558c8f0f7da1fdf
MD5 4a534a5748fb816beba21b7719781b1c
BLAKE2b-256 b16300ea27b7b1044a748696dfafe2cd91684366179070287a9aeced68d8a76a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page