
Z3 प्रमेय सिद्धांत, CTL मॉडल जाँच, और प्रमाणित रूप से सही डेटा निष्कर्षण के लिए कंफर्मल भविष्यवाणी के माध्यम से औपचारिक सत्यापन के साथ LLM वर्कफ़्लो को स्टेट मशीन के रूप में बनाने के लिए पायथन फ्रेमवर्क।
एक Python फ्रेमवर्क जो LLM वर्कफ़्लो को स्टेट मशीन के रूप में बनाने के लिए है, जिसमें फॉर्मल वेरिफिकेशन अंतर्निहित है।
pip install git+https://github.com/munshi007/Aura-State.git
अधिकांश LLM फ्रेमवर्क आपको API कॉल को जोड़ने और सर्वश्रेष्ठ की उम्मीद करने देते हैं। Aura-State एक अलग दृष्टिकोण अपनाता है: आप अपने वर्कफ़्लो को नोड्स के एक ग्राफ़ के रूप में परिभाषित करते हैं, प्रत्येक का एक विशिष्ट कार्य होता है, और फ्रेमवर्क एक्सट्रैक्शन, वेरिफिकेशन और रूटिंग को संभालता है।
नोड्स के बीच मुख्य अंतर यह है:
from aura_state import AuraEngine, Node, CompiledTransition
from pydantic import BaseModel, Field
from openai import OpenAI
# Define what you want to extract
class LeadData(BaseModel):
name: str = Field(description="Full name")
budget: int = Field(description="Budget in USD")
timeline: str = Field(description="Buying timeline")
# Define a node that extracts it
class ExtractLead(Node):
system_prompt = "Extract lead info from a sales call transcript."
extracts = LeadData
def handle(self, user_text, extracted_data=None, memory=None):
return "QualifyBudget", extracted_data.model_dump()
# Define a node that does deterministic math (no LLM)
class QualifyBudget(Node):
system_prompt = "Score the lead."
sandbox_rule = "result = budget > 100000" # runs in sandboxed AST, not LLM
def handle(self, user_text, extracted_data=None, memory=None):
return "END", memory
# Wire it up
engine = AuraEngine(llm_client=OpenAI())
engine.register(ExtractLead, QualifyBudget)
engine.connect([
CompiledTransition(from_node=ExtractLead, to_node=QualifyBudget),
])
# Run
next_state, data = engine.process("ExtractLead", user_text="Hi, I'm Sarah. Budget is $450k.")
जब आप engine.process() को कॉल करते हैं, तो यह क्रम में इन चरणों से गुज़रता है:
1. Adaptive DAG health check → Should this node be skipped or retried?
2. GraphRAG cache lookup → Have we seen this exact input before? Skip the LLM.
3. Few-shot injection → Find similar past successes, inject as examples.
4. LLM extraction + verification → Extract data, verify with Z3, retry if wrong.
5. Your node's handle() method → Your business logic runs here.
6. MCTS Routing (UCB1) → Score branches using UCB1 + AdaptiveDAG metrics.
7. State serialization → Save state for time-travel debugging.
8. Speculative execution → Pre-compute likely next nodes in parallel.
यही वास्तव में Aura-State को अन्य फ्रेमवर्क से अलग बनाता है।
आपका नोड ग्राफ़ एक Kripke संरचना में संकलित होता है और टेम्पोरल लॉजिक गुणों के विरुद्ध जाँचा जाता है:
from aura_state import verify_engine, reachability, mutual_exclusion, eventual_completion
results = verify_engine(engine, [
{"description": "QualifyBudget is reachable", "formula": reachability("QualifyBudget")},
{"description": "All paths terminate", "formula": eventual_completion("QualifyBudget")},
])
# Result: PROVEN or VIOLATED, with the exact states that satisfy/violate
यह वही तकनीक है जिसका उपयोग हार्डवेयर सर्किट और उड़ान नियंत्रण प्रणालियों को सत्यापित करने के लिए किया जाता है (CTL मॉडल चेकिंग, Clarke et al. 1986)।
LLM द्वारा मान निकालने के बाद, Z3 (Microsoft Research से एक थ्योरम प्रोवर) औपचारिक रूप से साबित कर सकता है कि वे आपकी बाधाओं को संतुष्ट करते हैं:
from aura_state import prove_extraction
result = prove_extraction(
{"budget": 450000, "cost_per_sqft": 3, "total": 1350000},
obligations=["budget > 0", "total == budget * cost_per_sqft"],
)
# result.verified = True
# If False, Z3 gives you a counterexample showing exactly what broke
एक्सट्रैक्शन को कई बार चलाएँ और वितरण-मुक्त विश्वास अंतराल प्राप्त करें:
from aura_state import conformal_interval
budgets = [450000, 452000, 448000, 450000, 451000]
ci = conformal_interval(budgets, confidence=0.95)
# ci.lower = 447800, ci.upper = 452200
यह कॉन्फॉर्मल प्रेडिक्शन (Vovk et al., 2005) का उपयोग करता है — किसी वितरणीय धारणा की आवश्यकता नहीं है।
हमने GPT-4o-mini का उपयोग करके 3 रियल-एस्टेट सेल्स ट्रांसक्रिप्ट को 4-नोड पाइपलाइन के माध्यम से चलाया (कुल 30 API कॉल):
फ़ील्ड सटीकता
────────────── ──────────
नाम 100%
बजट 100%
बेडरूम 100%
पूर्व-अनुमोदित 90%
समयरेखा 90%
शहर 80%
टेम्पोरल गुण: 3/3 साबित
Z3 प्रूफ दायित्व: 20/20 पास
रूटिंग सटीकता: 90%
औसत विलंबता: 1.4s
# Try it yourself — no API key needed
python examples/benchmark/run_benchmark.py
# With real LLM calls (needs OPENAI_API_KEY in .env)
python examples/benchmark/run_live.py --model gpt-4o-mini --runs 3
aura_state/
├── core/
│ ├── engine.py # Main engine — process() + MCTS/UCB1 routing
│ ├── adaptive_graph.py # Node health monitoring
│ ├── verification_loop.py # Extract → verify → retry loop
│ └── providers.py # Multi-model routing + cost tracking
├── compiler/
│ ├── schema_compiler.py # JSON Schema → Node classes
│ └── dspy_tuner.py # KNN few-shot selection
├── verification/
│ ├── temporal_verifier.py # Kripke + CTL model checking
│ ├── conformal.py # Conformal prediction intervals
│ └── proof_engine.py # Z3 proofs
├── execution/
│ ├── tracer.py # State serialization (time-travel debug)
│ └── sandbox.py # Safe math execution (AST validated)
├── memory/
│ ├── trajectory_cache.py # Subgraph isomorphism cache
│ └── pruner.py # Context window optimization
└── consensus/
└── auto_vote.py # Multi-run extraction with voting
pip install git+https://github.com/munshi007/Aura-State.git
Python 3.10+ आवश्यक है। निर्भरताएँ: pydantic, instructor, openai, networkx, pyModelChecking, z3-solver, pyyaml।
python -m pytest tests/ -v
# 65 tests passing
MIT