Skip to main content

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

Project description

Proxy Structuring Engine (PSE)

PSE Logo

Bringing Order to Chaos: Efficient schema-guided sampling for LLMs

Python CI Coverage License

OverviewFeaturesBenchmarks

Overview

The Proxy Structuring Engine (PSE) works in tandem with LLMs to ensure generated output conforms to a defined JSON schema.

The PSE 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 a Directed Acyclic Word Graph (DAWG) and finite state machines.

Installation

pip install pse

Features

  • JSON Schema Sampling: Enforces schema constraints while maintaining creativity in model outputs.
  • Enhanced Tool Calling: Enables precise tool integration by guaranteeing valid JSON output, streamlining workflows and automation.
  • Universal Compatibility: Works with any LLM that provides logits or log probabilities, both locally and via API.
  • Enhanced Creativity: Balances structure with quality, generating actionable and creative outputs that meet your schema requirements.
  • Performance Optimized: Incorporates several optimizations for speed and efficiency, including:
    • DAWG (Directed Acyclic Word Graph): Efficiently validates tokens against the schema.
    • Lazy Evaluation with Logits: Processes tokens only as needed.
  • Expanded Schema Support: Supports JSON Schema with plans to expand to other formats (SQL, Cypher, Python, U-DIFF).
  • Direct HuggingFace Integration: Seamlessly integrates with HuggingFace transformers.
  • Comprehensive Unit Testing: Ensures code reliability with 90% test coverage.
  • Detailed Documentation and Type Hinting: Improves readability and developer experience.
  • Hooks for Custom Logic: start_hook and end_hook callbacks 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:

// add benchmarks here //

Acknowledgements

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


Made with care ❤️

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

Uploaded Source

Built Distribution

pse-0.0.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pse-0.0.1.tar.gz
  • Upload date:
  • Size: 8.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.0.1.tar.gz
Algorithm Hash digest
SHA256 ad1ee91ce81e5d595bced95a6a5c0fd866cc190b76f413bd11ff2491d2b854f5
MD5 18fd046ee9d5cbb400bdc49adc507f15
BLAKE2b-256 65ea12e8793611615b35bc913c3b2f619347558dfb4f3c6481be4e29bd98ddde

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pse-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a8c1bebecae658a2ce7963ae835670afed5b60c9fa2d598aa271f289dd829a6
MD5 3f5b3c35371b8885ce851125868e6171
BLAKE2b-256 6efa46e52ab8f15ca4529b8dc6fd8786db7153b9a68b4344a540be9756e5a29a

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