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)

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

Build Status License

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-1.1.0.tar.gz (36.8 kB view details)

Uploaded Source

Built Distribution

pse-1.1.0-py3-none-any.whl (59.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pse-1.1.0.tar.gz
Algorithm Hash digest
SHA256 933c2587e05c04eca52441714f7fdef996737c163986fc47412d5baa15a3ad82
MD5 023567780e16d100c9af215e762734fc
BLAKE2b-256 6ac7fe88a66d4aa845755e7106888ce938a97aa715c8c234f0b09ea3765613ca

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pse-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76dafb5ba691fa8b18b1024659ac5fc8a06f3b01e570432b65f9196877444d15
MD5 07d442fce7b099a2eca18b1d098cd629
BLAKE2b-256 9b90872ad9789f9a26b909a4cbd9c6e45f33ac73a0af635ebe40621e38e6953f

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