Modified Regex for Syntactically Constrained LLM Sampling
The scs_re package is a modified version of the python re module that returns a match for any prefix of a string matching the original regex pattern. For example, the pattern ^abcd matches the string abc. This behavior is used to consider the validity of beams under a particular regex pattern during a language model's output generation.
Note: This behavior is only expected for patterns that begin with ^ and end with $ and therefore define a match contstraint over all characters in a sequence.
Building from source
We use the _sre module from the python 3.11 branch of Python/cpython/Modules/_sre. You can clone the original source by running
svn export https://github.com/python/cpython/branches/3.11/Modules/_sre _sre
The module requires python 3.11 headers to compile. To install run
wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tar.xz
tar xf Python-3.11.3.tar.xz
cd Python-3.11.3
./configure --enable-optimizations --enable-shared
make -j$(nproc)
sudo make altinstall
Then you can install the package with sudo python3.11 setup.py install to install. The python version you install to must be the same version whose headers were compiled against.
Metadata
Release files for scs-re 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| scs_re-1.0.3.tar.gz | 43.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scs_re-1.0.3-py3.11-linux-x86_64.egg | Legacy Egg format | - | - | Details |
Total release size: 356.6 kB
Release files / scs_re-1.0.3.tar.gz
| Download URL | scs_re-1.0.3.tar.gz |
|---|---|
| Size | 43.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fdc3086ec3720bf87d3f80bf9d946e96d05537fc56bffad9b9f8591d3487ed4
|
|
BLAKE2b-256 checksum How to use checksums |
03591a553d28b71c64df76133b296df7bd6c2cb591790f7d9427af8ea87d092d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / scs_re-1.0.3-py3.11-linux-x86_64.egg
| Download URL | scs_re-1.0.3-py3.11-linux-x86_64.egg |
|---|---|
| Size | 313.5 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
d4e565caf9a451b4ae562eaf803b0f258e3ea5bd3dc9993d94c81e88d1469066
|
|
BLAKE2b-256 checksum How to use checksums |
ee79315368f9dc3e63f0499f0ecac0100efc5fc80f9a5d637ae21d3480467f35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for scs-re 1.0.3
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.