Skip to main content

Proxy Structuring Engine: Ensures AI-generated output adheres to predefined schemas without compromising creativity, speed, or context.

Project description

Proxy Structuring Engine (PSE)

PSE Logo

Bringing Order to Chaos: Efficient Schema-Guided Sampling for LLMs

PyPI version License Build Status

OverviewInstallationFeaturesBenchmarks

Overview

The Proxy Structuring Engine (PSE) works in tandem with Large Language Models (LLMs) to ensure generated outputs adhere to predefined schemas without compromising creativity, speed, or context. This enables error-free custom tool calling, complex multi-step reasoning, and unlocks new creative possibilities for AI applications.

PSE achieves this through a novel schema-guided sampling approach, leveraging Directed Acyclic Word Graphs (DAWGs) and finite state machines to enforce constraints during text generation.

Installation

PSE supports multiple backends such as PyTorch, JAX, and mlx for maximum flexibility and performance.

To install the base package:

pip install pse

To install with optional backend support, use one of the following:

pip install pse[torch]  # PyTorch support
pip install pse[jax]    # JAX support
pip install pse[mlx]    # mlx support
pip install pse[all]    # All optional features

Features

  • 🚀 Multi-Backend Support: Compatible with PyTorch, JAX, and mlx backends.
  • 🛠 Schema-Guided Sampling: Enforces JSON schema constraints during text generation.
  • High Performance: Minimal overhead ensures fast generation speeds.
  • 🎨 Maintains Creativity: Preserves model creativity while enforcing structure.
  • 🤖 Easy Integration: Seamlessly integrates with Hugging Face Transformers.
  • 📚 Expanded Schema Support: Supports JSON Schema with plans to expand to other formats (SQL, Cypher, Python, U-DIFF).
  • Comprehensive Testing: Ensures code reliability with 90% test coverage.
  • 🔍 Detailed Documentation: Improves readability and developer experience.
  • 🧩 Customizable Hooks: start_hook and end_hook enable custom logic injection.
  • 🔄 Robust Error Handling: Facilitates debugging and integration.

Benchmarks

The Proxy Structuring Engine consistently outperforms traditional sampling methods in both speed and accuracy:

(Benchmarks will be added soon.)

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

Acknowledgements

PSE builds upon the groundwork laid by LLM Structured Output and utilizes lexpy for efficient lexicon analysis.


Made with care ❤️ by The Proxy Company

TwitterWebsiteContact

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

pse-0.5.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

pse-0.5-py3-none-any.whl (61.8 kB view details)

Uploaded Python 3

File details

Details for the file pse-0.5.tar.gz.

File metadata

  • Download URL: pse-0.5.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pse-0.5.tar.gz
Algorithm Hash digest
SHA256 8830344bf92f167b910c512a5b85227ac31edd48a98ea2912538d98abcdaae71
MD5 5ba414e65b628c93b824c733bfd39f80
BLAKE2b-256 9548d14dab79a0dab48abd0301667c1f330f9b8ee20675de975c1c2d54c85c51

See more details on using hashes here.

File details

Details for the file pse-0.5-py3-none-any.whl.

File metadata

  • Download URL: pse-0.5-py3-none-any.whl
  • Upload date:
  • Size: 61.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pse-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 25d2db7447acf081b15f9ea1f1df49c45ef3412e0173efdb7b2c486cd67fd579
MD5 04614aae126c7635cff9209ecb5fd4bd
BLAKE2b-256 7426ef9a2ae0bf5eb8313e5818d5ae49b9c2ed0f88dcb0475b67ddf6cf1595c4

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