Skip to main content

prsr

Checks PyPI Documentation

Latent-variable PCFG training and left-corner parsing in PyTorch, on CPU or GPU. prsr reimplements three ModelBlocks and Berkeley parser components:

  • prsr.gcg: the gcg15 reannotation of Penn Treebank trees.
  • prsr.train: split-merge training of latent-variable PCFGs, as the Berkeley parser 1.7 trains them.
  • prsr.Parser: compilation of a PCFG into left-corner factors and a batched beam parser that follows ModelBlocks' synproc and reports per-word surprisal.

prsr ships no treebank data. Training needs your own copy of the Penn Treebank or another treebank.

import prsr

from prsr.gcg import training_lines

lines = training_lines(open("train.gcg15").read().splitlines())
trees = [prsr.training_tree(line) for line in lines]
grammar = prsr.train([t for t in trees if t is not None])
grammar.save("grammar/")

parser = prsr.Parser.from_grammar(prsr.Grammar.load("grammar/"), beam=5000)
for index, parse in parser.parse_stream([s.split() for s in sentences]):
    print(parse.surprisal, parse.preterminals, parse.tree())

Each Parse holds a sentence's words, per-word surprisal in bits, and the states of the best path. parse.failed is true when the beam emptied; then tree() returns None. device="auto", the default of train and Parser.from_grammar, uses a GPU when one is visible.

The stable API is prsr.train, Grammar, Parser, Parse, Pcfg, Tree, training_tree, the version constants, and prsr.gcg. Other modules may change in minor versions.

prsr.TRAIN_VERSION and prsr.PARSE_VERSION change whenever the same input would give a different grammar, or a different exported model, parse, or surprisal. If you cache prsr's results, include them in the cache key.

Documentation

Metadata

Release files for prsr 0.1.1

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

Source distribution (sdist)

Source distribution for prsr 0.1.1
File Size Uploaded Provenance Actions
prsr-0.1.1.tar.gz 136.0 kB With provenance Details for prsr-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prsr 0.1.1
File Interpreter ABI Platform Actions
prsr-0.1.1-py3-none-any.whl Python 3 none any Details for prsr-0.1.1-py3-none-any.whl

Total release size: 263.3 kB

Release files / prsr-0.1.1.tar.gz

Download URL prsr-0.1.1.tar.gz
Size 136.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2df259e53e494de3eeb515b5a94842633d5b1b0c2ce0dae17a14059bb98f9642
BLAKE2b-256 checksum
How to use checksums
268188050a76e767fdb78b07defd2153d05d91b869f7fc2c9f98f0b0757fd30d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / prsr-0.1.1-py3-none-any.whl

Download URL prsr-0.1.1-py3-none-any.whl
Size 127.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc0488c59a8d4c6f07148809e7629efb0ffa2ce67a2583a2f15eb7e60b680183
BLAKE2b-256 checksum
How to use checksums
0156baee1d13b78e4d5513f1d8f87babaec4e83e7459f4f112aacc078684df13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for prsr 0.1.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for prsr-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

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