Introducing a Python-Based Reasoning Engine for Deterministic AI

As the demand for deterministic systems grows reviving foundational ideas for the age of large language models (LLMs) is here.

The Challenge

One of the critical issues with modern AI systems is establishing constraints around how they validate and reason about incoming data. As we increasingly rely on stochastic LLMs to process unstructured data, enforcing rules and guardrails becomes vital for ensuring reliability and consistency.

The Solution

Thus a company has developed a Python-based reasoning and validation framework inspired by Pydantic, designed to empower developers and non-technical domain experts to create sophisticated rule engines. The system is:

  • Extensible: Developers can easily customize it to fit specific use cases.
  • Automated: A fine-tuned model generates rules from natural language instructions, streamlining the process.
  • Versatile: Applicable across industries with similar logic frameworks, such as logistics or compliance.

By transforming Standard Operating Procedures (SOPs) and business guardrails into enforceable code, this symbolic reasoning framework addresses the need for structured, interpretable, and reliable AI systems.

Key Features

  • Compatibility with Graph Data: Works with JSON-based graph data structures but is adaptable to relational and NoSQL databases.
  • Python-Based: Avoids the complexity of semantic tools like SHACL and RDF, providing a developer-friendly experience within familiar Python ecosystems.
  • Integrated State Machines: Supports reasoning and decision-making processes with state tracking.

System Architecture

The framework includes five core components:

  1. Data Structure: Represents the objects or elements within the system (e.g., chess pieces in a game analogy).
  2. Rules: Define the constraints or logic for the system (e.g., rules of chess).
  3. Reasoning Framework: Simulates decision-making processes (e.g., the chess player).
  4. Agent: Executes actions based on decisions (e.g., moving the chess pieces).
  5. State Machine: Tracks the system’s current state and transitions (e.g., the chessboard layout).

Types of Engines

  • Validation Engines: Focus on rule compliance, validating inputs without maintaining state.
  • Reasoning Engines: Navigate complex problem spaces, making decisions based on defined rules and a state machine.

Case Studies

1. Validation Engine: Mining Company Compliance

A mining company needed to validate employee qualifications against region-specific requirements. The system was configured to check rules such as minimum age and required certifications for specific roles.

Input Example:
Employee data and validation rules were modeled as JSON:

jsonCopy code{
  "employees": [
    { "name": "Sarah", "age": 25, "documents": [{ "type": "safe_handling_at_work" }] },
    { "name": "John", "age": 17, "documents": [{ "type": "heavy_lifting" }] }
  ],
  "rules": [
    { "type": "min_age", "parameters": { "min_age": 18 } }
  ]
}

Output:
Violations, such as “Minimum age must be 18,” were flagged immediately, enabling quick remediation.


2. Reasoning Engine: Solving the River Crossing Puzzle

To showcase its capabilities, we modeled the classic river crossing puzzle, where a farmer must transport a wolf, a goat, and a cabbage across a river without leaving incompatible items together.

Steps Taken:

  1. Translated the puzzle into data structures and rules.
  2. Enabled natural language input to add and modify rules.
  3. Used the engine to solve the puzzle while tracking states and ensuring rule compliance.

Enhanced Scenario:
Adding a new rule—“Wolf cannot be left with a chicken”—created an unsolvable scenario. By introducing a compensatory rule, “Farmer can carry two items at once,” the system adapted and solved the puzzle with fewer moves.


Developer Insights

The system supports rapid iteration and debugging. For example, adding rules is as simple as defining Python classes:

pythonCopy codeclass GoatCabbageRule(Rule):
    def evaluate(self, state):  
        return not (state.goat == state.cabbage and state.farmer != state.goat)  

    def get_description(self):  
        return "Goat cannot be left alone with cabbage"

Real-World Impact

This framework accelerates development by enabling non-technical stakeholders to contribute to rule creation through natural language, with developers approving and implementing these rules. This process reduces development time by up to 5x and adapts seamlessly to varied use cases, from logistics to compliance.

🔔🔔 Follow us on LinkedIn 🔔🔔

Related Posts
Salesforce OEM AppExchange
Salesforce OEM AppExchange

Expanding its reach beyond CRM, Salesforce.com has launched a new service called AppExchange OEM Edition, aimed at non-CRM service providers. Read more

The Salesforce Story
The Salesforce Story

In Marc Benioff's own words How did salesforce.com grow from a start up in a rented apartment into the world's Read more

Salesforce Jigsaw
Salesforce Jigsaw

Salesforce.com, a prominent figure in cloud computing, has finalized a deal to acquire Jigsaw, a wiki-style business contact database, for Read more

Health Cloud Brings Healthcare Transformation
Health Cloud Brings Healthcare Transformation

Following swiftly after last week's successful launch of Financial Services Cloud, Salesforce has announced the second installment in its series Read more

author avatar
get-admin