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

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-1.0.0.tar.gz (38.0 kB view hashes)

Uploaded Source

Built Distribution

pse-1.0.0-py3-none-any.whl (61.8 kB view hashes)

Uploaded Python 3

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