Constrained Reasoning for Regulated Industries

A Go plugin that pre-computes deterministic results, constrains the LLM to narrate around them, and validates every output before it reaches the user. Open source. Domain agnostic. MIT licensed.

Reduced HallucinationsAudit-ReadyLLM-Agnostic
Lao Zi dragon-tiger yin-yang logo representing the balance of deterministic constraints and LLM intelligence
The Challenge

The Rules-vs-LLM Tradeoff

Rules-based systems are rigid but verifiable. Unconstrained LLMs are flexible but unreliable. Lao Zi combines both.

Rules-Based Systems

Can't Scale

5 metrics × 3 age groups × 2 genders = 30 rules. Add medications and interactions and the count exceeds 1,000. Combinatorial growth makes manual maintenance impractical.

Unconstrained LLMs

Hallucinate

Feeding raw data to an LLM and asking it to analyze produces inconsistent outputs with no audit trail and no verifiability.

The Solution

Lao Zi

Solves Both

LLM flexibility within deterministic boundaries. Pre-computed analytics narrated by a constrained model. Same data in, same answer out.

"The LLM never interprets raw data. It narrates pre-computed analytics."

— Lao Zi Core Design Principle
What is Lao Zi?

Constrained Reasoning Instead of Rules

Lao Zi is a domain-agnostic Go plugin that wraps LLM calls inside deterministic constraint layers. It pre-computes severity from thresholds, feeds the result to the LLM, then validates the output and retries on failure. The LLM writes prose — it does not compute.

Designed for regulated industries that require accuracy, traceability, and compliance as baseline properties of any production system.

Pre-Computed Analytics

All numerical calculations happen deterministically before the LLM is invoked. The framework evaluates data — the AI narrates results.

Three-Tier Constraints

Hard thresholds, RAG knowledge bases, and output validation guardrails work together to dramatically reduce hallucinations and errors.

Narrator, Not Analyst

The LLM only narrates pre-computed insights. It never interprets raw data, calculates numbers, or drives numerical conclusions.

Audit-Ready by Design

Every claim traces to a specific guideline and source URL. Full approval workflows and deterministic validation logging from day one.

architecture overview
Lao Zi constrained reasoning architecture showing the constraint layer, LLM pipeline, pre-computed analytics, and validation flow
View full architecture ↓
4 stages · Generate → Parse → Validate → Narrate

The framework's value is that failures have limited authority because the LLM has limited authority.

No technology eliminates hallucinations entirely. Lao Zi validates each output against the deterministic inputs and retries up to three times when they diverge. On the third failure, the system falls back to the deterministic result or returns a failure, depending on configuration.

Capabilities

Core Capabilities

What Lao Zi adds to any LLM-powered application.

Pre-Computed Comparison

Severity is computed deterministically from thresholds before the LLM runs. The LLM writes prose around the result — it cannot change the numbers, the severity, or the source citations.

Deterministic wins over LLM when they conflict

Core Feature

Lao Zi DSL

A purpose-built expression language for aggregation-over-data calculations. Supports SUM, AVG, ZSCORE, GINI, BENFORD, and temporal windowing (YTD, MTD, QTD). Compiles deterministically to SQL — validated at parse time, not runtime.

No raw SQL exposure, PEMDAS-enforced

Explore the DSL

Build-Time Configuration

All settings — LLM model, temperature, max tokens, parallel call limits, RAG parameters, retry counts — live in config.go and compile into the binary. No runtime config files to manage.

Settings compiled into the binary

Open Source — MIT License

Full transparency. Inspect the constraint stack. Verify the validation logic. Fork and customize for your needs. No vendor lock-in, ever.

Complete code transparency

Validation + Regeneration

Every LLM output is parsed and checked: text length, no placeholders, severity match, valid reference. Failures trigger automatic retry with the specific error fed back to the LLM.

Auto-retry on invalid output

Explore Adaptive Context

Full Audit Trail

Every claim traces back to a specific guideline + URL. Human approval workflows, metric lifecycle management, and deterministic validation logging. Audit-ready from day one.

Every insight is traceable

Explore Compliance
Architecture

How Lao Zi Works

A four-stage pipeline that separates compute from narration, ensuring every number is verified before the LLM ever sees it.

Pre-Computed Comparison

Thresholds are defined per category with min/max ranges, units, and source URLs. The engine compares actual values against these ranges and computes severity deterministically — before the LLM is ever called.

Example: glucose 105 vs range 70–99 → BELOW minimum → severity = warning. This is computed before the LLM call.

Pre-Compute
Generate
Parse
Validate
Retry / Fallback
Applications

Applied Use Cases

The constraint architecture is domain-agnostic. Swap thresholds and RAG entries to target a different vertical.

Powering the Glint Platform

Personal Health Intelligence

Lao Zi powers Glint, a personal health intelligence platform that integrates CGM data with food, medication, exercise, and sleep logs to deliver clinically-grounded insights.

  • Event correlations: "Pizza → +47 mg/dL peak at +90min, recovery 3.2hrs"
  • Wearable integration: Garmin, Fitbit, Apple Health, CGM devices
  • Clinical metrics with DB-driven thresholds (ADA, CDC sources)
  • Health outlook pipeline: RAG pre-fetch → parallel generation → dedup → summarizer
  • Extensible insight categories — add new health domains without retraining

Key Features

Constrained Reasoning
Deterministic boundaries around every LLM call
Adaptive Context
System gets smarter with every interaction
Extensible with DSL
Purpose-built language for domain analytics
Approval & Audit Loops
Full compliance lifecycle from draft to production
Integration

Drop-In Plugin Architecture

Lao Zi wraps your existing LLM. It doesn't replace it. Add constrained reasoning to any application with a simple Go import.

main.go
import "github.com/Phoenix-Innovation/laozi"

engine := laozi.New(
  laozi.NewDefaultLLMClient(),
  laozi.NewInMemoryRAG(),
)

engine.AddCategory(laozi.Category{
  ID:   "glucose",
  Name: "Blood Glucose",
  Thresholds: []laozi.Threshold{{
    Metric: "glucose", Min: 70, Max: 99,
    Unit: "mg/dL", Source: "ADA",
  }},
})

metrics := map[string]float64{"glucose": 105}
insights, _ := engine.AnalyzeAll(ctx, metrics)
< 5 min
Setup
Minimal
Dependencies
MIT
License

LLM Backends

OpenAI GPT-4oAzure OpenAIvLLM (Llama, Qwen)OllamaAbacus.AI RouteLLMCustom LLMClient

RAG Stores

In-Memory RAGPGVectorPineconeWeaviateMilvusCustom RAGStore

Databases

PostgreSQLMySQLSQLiteTimescaleDBPrisma ORM

Infrastructure

RabbitMQAzure Service BusRedis StreamsNATS JetStreamPrometheusKubernetes
Performance

Production Architecture

Ingest and evaluate are separate stages. Workers operate on pre-aggregated summaries, not raw records.

Minutes
Large-batch processing
Parallel workers with cache layer
Aggregates
Not raw data
Workers evaluate pre-computed summaries
Columnar
Storage compression
TimescaleDB or equivalent
Constrained
Output validation
Deterministic guardrails on every call
Cached
Repeated queries
Semantic response caching layer
Any
LLM backend
OpenAI, vLLM, or custom models

System Architecture

Lao Zi Plugin detailed software architecture showing the constraint layer, LLM pipeline, RAG stores, and data flow
Click to expand

Lao Zi Plugin — Detailed Software Architecture: Constraint Layer, LLM Pipeline & Data Flow

Deployment Options

Runs on a single VM or scales horizontally across distributed clusters. Contact Pi.Tech to discuss architecture for your workload.

Contact Pi.Tech

Defense in Depth

Lao Zi provides external constraints (framework layer). A domain-tuned LLM provides internal biases. Together they create defense in depth — the LLM cannot change severity, invent numbers, or drop citations.

"The architecture's value is that failures have limited authority because the LLM has limited authority."

Get Started

Get Started with Lao Zi

Lao Zi is open-source under MIT. Browse the code, read the docs, or reach out to discuss integration with your stack.

Contact Pi.Tech

Get in touch about enterprise deployments