Skip to main content

Grammar-constrained token masking for LLM decoding

Project description

Shingleback Python bindings (glrmask)

Shingleback is the project name; the PyPI distribution and Python import remain glrmask. The bindings compile grammars together with a token vocabulary and expose incremental mask and commit operations.

Install

From PyPI:

python -m pip install glrmask==0.1.0

For a source build, from the repository root:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install ./python

Building from source requires a Rust toolchain and the platform linker/build tools (for example, Xcode Command Line Tools on macOS). pip installs Maturin in an isolated build environment and installs the Python runtime dependency (numpy).

Minimal example

import glrmask

vocab = glrmask.Vocab.from_dict({
    b"hello": 0,
    b" ": 1,
    b"world": 2,
})
constraint = glrmask.Constraint.from_ebnf(
    'start ::= "hello" " " "world"',
    vocab,
)
state = constraint.start()

assert state.mask().tolist() == [True, False, False]
state.commit_token(0)
assert state.mask().tolist() == [False, True, False]
state.commit_token(1)
assert state.mask().tolist() == [False, False, True]
state.commit_token(2)
assert state.is_finished()

The mask is tokenization-complete for the compiled byte language: a vocabulary token is admitted when appending its bytes leaves at least one valid completion, even when the token crosses grammar-terminal boundaries.

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

glrmask-0.1.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distributions

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

glrmask-0.1.0-cp313-cp313-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.13Windows x86-64

glrmask-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

glrmask-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

glrmask-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

glrmask-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

glrmask-0.1.0-cp312-cp312-win_amd64.whl (6.2 MB view details)

Uploaded CPython 3.12Windows x86-64

glrmask-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

glrmask-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

glrmask-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

glrmask-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

glrmask-0.1.0-cp311-cp311-win_amd64.whl (6.2 MB view details)

Uploaded CPython 3.11Windows x86-64

glrmask-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

glrmask-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

glrmask-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (5.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

glrmask-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

glrmask-0.1.0-cp310-cp310-win_amd64.whl (6.2 MB view details)

Uploaded CPython 3.10Windows x86-64

glrmask-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

glrmask-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

glrmask-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (5.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

glrmask-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

glrmask-0.1.0-cp39-cp39-win_amd64.whl (6.2 MB view details)

Uploaded CPython 3.9Windows x86-64

glrmask-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

glrmask-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

glrmask-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (5.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

glrmask-0.1.0-cp39-cp39-macosx_10_12_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

File details

Details for the file glrmask-0.1.0.tar.gz.

File metadata

  • Download URL: glrmask-0.1.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for glrmask-0.1.0.tar.gz
Algorithm Hash digest
SHA256 96785fac4f0f94984bb51a786412d761a9765fdab3cb4fac1759610652d212de
MD5 4a628a101de3324164d83bc388a68b12
BLAKE2b-256 fa9e6f4646f2afd6e28751a132466dfcc519ece9d4bdbb3c5250602eec74e6c6

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e802475862569e664fef53454f0f25e5dd2b888447b7c10e0962cb2c6b7235db
MD5 d6791c517febbb9f7f6d6deaa9ec052d
BLAKE2b-256 eba07c264bc488c57d19cb4888055fffa0e55c7a3f22a961363a7a560178c938

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4254c3dbe7c6719c44ee23794fe1f44ff890ad6d9d6f32105ba1561671f113e7
MD5 c155095b4aaced8fc75f8b2910648a64
BLAKE2b-256 aa96767f7375916ab19ac1b6638555fd7cd65cb8cd6d643893c31a6e3c617413

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2760e2dd17d86988ac5a5e132aa212172b6ad66b180ef9ae7622e55d48c4602e
MD5 974bda18310bab3cc14d94786568e1c3
BLAKE2b-256 572492487f0f4396f8134c2f6ed42f37bb67709ab51dd01e7b1743841f63a306

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1418e16b157613a302582af855a2d3a864248c3d34d0f498c3bd9fac44108d41
MD5 24e715495c6114ea6472d0d67464214d
BLAKE2b-256 0a55c2dc66c52023ccef94c5ddd3c84feae5363467e852bb860ec618365518b0

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 857f7287c00ac7246b790dc70a11d5173b87b176649539ce9342756898868584
MD5 122b8b69774c64825bb26d9d0f9061ec
BLAKE2b-256 377620e77de0a38a48581a8bc121469f9f7ac3d694885477f8c1d80385ca68c6

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e90481e6ba911d8fa9ea3d59bc36df7a461466106515035412781662e76601ec
MD5 5c70d751ca263fea31e3772376d3b104
BLAKE2b-256 b10c74777069fcf3d3c1461a9076f3e2b8305b00e6d1a885e01d788e0bb57f6c

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac16f346af1201d7dc562f8a87a96ff5f31c9dfa065d7f67ababa5c392bc6781
MD5 dd44fdc185c473aec389077a1e4fc500
BLAKE2b-256 2f293fb1797a8adaf977d558b20747dc04ec7fc86c59a7f9042449da92bb5c44

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 76dbbb5a74057eb24ba261d0e9940e9691b6e0dd742404eccc7c72183bb77102
MD5 7081de3fcd09210f1547c375a4d14c90
BLAKE2b-256 9265fe7d8379394ee5142836f0ab85c45ccc25e393e6fa04b29237a7bdd09f00

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0eb109aaf3453a65cd9af24b690023b4a2bc165b8dfdfbdf4dab991e13cbb7ec
MD5 c4ca551a2df22ee0be6d783d8209478b
BLAKE2b-256 1076b6fd72a6227a2f5b2535a61d30a9d621868bf1535f7bdfa012d37da94f97

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9b50227deb9d42fc6e374c8c757f36a3f2729b451c0fe4459035a2da670a1371
MD5 859344397962ee716a740102565347b8
BLAKE2b-256 56a7cf5db5afe0220366a4817501b32c5e986ee958830e2afbe3bde8edf26096

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 612fa85a8bbc92585ffe4babac29ae84bd6577aa0854bbdb6e07fe7b0b233b8f
MD5 a4504bf82550a481cd6433265b1a4171
BLAKE2b-256 01b48edff623afb1f8922a931d14ab0dfc637fd2a670db7e809cb69c4deb54ed

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9ddefb951e5866c4bfc49a893b3ea0e99538724209b2e8d43c79a8e5a3e9de99
MD5 c0d106b062b6c10bc2b6fab181921234
BLAKE2b-256 6c84b6d1d296c1429254e552e09f9c9f75546fab0740aff12b7c945401506692

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 be029c14c42e12ff55c1b180cc8e7e643920b2ce128dca8ac37839f1e1846327
MD5 dd53f5e37742703f332bf6626a1626d2
BLAKE2b-256 1772bb4a5f494ae0e4c3dbff6ffa90ad5107a0b0531c21d93b87d99f1fab2dd1

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 147875a5352b6ea094e333bf9a0f99d26834104349a739dbc087990af9f3ff05
MD5 078e3d7dcb3756141ddada6911b89fba
BLAKE2b-256 7ae9e96927fb41146ec4b0718b00f0daec4d7e1c265a77ae8b3bc01b0b0ce253

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 24efa2db69c1108be5549853d3894f8f8dbe3cbf2c981274a8515ddcb47cd33c
MD5 57ca8484ee75005ae79f8e35ea80414b
BLAKE2b-256 343c8a7937b2183e14046b0d2a1e424f1dd3d86b6dc6591c693a93fa05112fdc

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0547f90a4389006ed703f2c90c20d137a9c50d7316515b621a85325802101d43
MD5 e54904e2a0d8dabb944b2cb094921479
BLAKE2b-256 e4fb0af43de0873792205af78b31ef1800d2d4e4b018dc10606be44a6bc54db2

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84a4589659f3c22c6045c36cb715236f12cb43341e9741443933a3d354b60114
MD5 70fee1cf87bc4b3c4601d2d2cf019e3a
BLAKE2b-256 85ed5face0c7c9a1d7288d0dc5529f119a00a945849ba36424cf1df6e9aad707

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8e75b32e424eb95e1a23c6e365c25b34effd93f27bf96233665114c46fbc0fb9
MD5 9244d6d6afdb7b53eb5980fd77b30fa4
BLAKE2b-256 9eb1cdfcc2193463deac05e2f64ef1de337f422b9e9564e9c01a6b45ff37d126

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b0baaaef196536d272c702fe70125a092cf926e848b6a37d2f202b356bbc67d
MD5 cad7f60cb4177faa6626500bb071c88a
BLAKE2b-256 e064f66a95fbf02fc1e691bb565b449f835170c02b08ed373139cae91ad8b38f

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 da79418ec74694eca5809c71b8308ed20bb24cd932fca4ea9ab52fac049641ae
MD5 ca290b88df14c112f6f7293616ea47e0
BLAKE2b-256 b3723d0296c733f6c9c07d505294c7109122affe56b41be427bc4b057494321d

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: glrmask-0.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 6.2 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for glrmask-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 fc6a852749cc5aa9d0370a42288dc339c35708d630e08d9f525de1f9edc44a96
MD5 8a644abb14770cc73f0cb3a633e1f803
BLAKE2b-256 b374d25af99d8f1f46d22987cc60367d2472f4271887747460b857850ccd6edc

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 710afe1aaa45dec83c65b68c709edcc07d131cc849bac6b7efcba7cb518846b3
MD5 571e69a8fc79f9261f40759aa189a260
BLAKE2b-256 203869d19eb8e9bf38073803d6f2095bbd4b60921d81bc71a1ef5c6d785c1839

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e725658fbb2d8953f9b40c0ea66d4c7df11af4b1eb597110089a09962569bc03
MD5 d4c099711e77b9a0d89f070245cf16f3
BLAKE2b-256 6a73835b42b3373c5118631912d8a5e848a0f37c6e41d1ebfd9cf4658ff6c5aa

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59e2416a5c47d70a0ed3440144eea6d680d3710a9efb9c7c4c550b4f8c4a8a9e
MD5 4b164095a56e09f99ef01fc8a8cac077
BLAKE2b-256 00485d023c1390e73dbe82bf787d485ef6c0263ef229e444ae67923a8ce8be11

See more details on using hashes here.

File details

Details for the file glrmask-0.1.0-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for glrmask-0.1.0-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 86e6937b020d8c373faba26badc6255b266bcfeac746112fb831b1e17f61ce8d
MD5 c4796c061ab189af51d49e6de654786b
BLAKE2b-256 243f75164072cd0b8bd71c984f7f1adf6ecda98410e3efce5347c74b252c73d6

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