Skip to main content

A C++ implementation of the Lazy-k algorithm (A* with partial expansion)

Project description

main

lazyk

A C++/Python library for efficiently iterating over high-probability label-assignments.

Installation

You know the drill

pip install lazy-k

Usage

The library can be used to iterate over the high-probability label-assignments of a given probability matrix. The following example shows how to use the library to iterate over the high-probability label-assignments of a 3x3 probability matrix.

from lazyk import lazyk
import numpy as np

probs = np.arange(1, 10).reshape(3, -1)
probs = probs / probs.sum(axis=1, keepdims=True)

for seq in lazyk(probs, cache_assignments=True): # cache_assignments is true by default, but can be turned off for lower memory usage but might be slower
    print(seq)

The cache_assignments parameter indicates whether the algorithm should cache the intermediate label-assignments. This will improve the running speed of the algorithm but also require more memory. The default value is True but can be turned off if memory is a concern.

More information can be found in the paper "Lazy-k Decoding: Constrained Decoding for Information Extraction".

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lazy_k-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (135.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

lazy_k-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (135.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

lazy_k-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (136.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

lazy_k-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (134.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file lazy_k-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lazy_k-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af6bacecce7f6bb31ea0f7ab74b74cefd9bffcdcde00329cbf04dcab9de9a4fa
MD5 82e04a0b83c58950bf8d1a909a6c41fb
BLAKE2b-256 b054a8ad61023394a7423ad66c4a67fb8cbdfd520c59fe3ff6bc223599440729

See more details on using hashes here.

File details

Details for the file lazy_k-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lazy_k-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec255839b8406bb34149f35f1bab61d5eef9d7d8e68d8c14f73d9e11e53dda5f
MD5 e284ae7f49d6e8256896746d5cef84f7
BLAKE2b-256 9306eef3f7e1d153960fbd7063fc05cff4be096541e09f6459476cd3f9f5fdc0

See more details on using hashes here.

File details

Details for the file lazy_k-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lazy_k-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7a77a765fa740eb185c1b134f2f3a43274f1a78d12a4a2032066463b644da043
MD5 b3f5e4e49fa2d7dabb87bb39516434da
BLAKE2b-256 4448ad9c1c23dd2d399e2ec88a3426d275a39095fbf5ec1270bd7a463ee16997

See more details on using hashes here.

File details

Details for the file lazy_k-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lazy_k-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d833ef1542074b67c71b77d5790567ad8abeec04a3395a120b762c507a2bb370
MD5 501357d7bb43682cf60fe896ce34cfd9
BLAKE2b-256 1e53027318eabe06f0fd4f0936ab2ce8f3747b096c6ac14faf330a5e35a3b105

See more details on using hashes here.

Supported by

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