ExtensityAI/symbolicai

A neurosymbolic perspective on LLMs

What it solves

SymbolicAI provides a way to combine classical Python programming with the capabilities of Large Language Models (LLMs) using a neuro-symbolic approach. It addresses the issue of LLM hallucinations and unpredictability by introducing structured validation and semantic reasoning directly into the Python code, allowing developers to build more reliable and predictable AI applications.

How it works

The framework is built around two core concepts: primitives and contracts.

  • Primitives (Symbols): The project introduces Symbol objects that can operate in two modes: Syntactic (behaving like standard Python values) and Semantic (wired to a neuro-symbolic engine to understand meaning and context). Users can switch between these modes using projections like .sem and .syn or by calling semantic functions like .map().
  • Contracts: Based on the "Design by Contract" principle, this system uses decorators to enforce constraints on LLM inputs and outputs. It utilizes LLMDataModel (compatible with Pydantic) to define data structures and validation rules. If a contract is violated, the framework can automatically attempt to fix the errors through a remedy system (pre-remedy and post-remedy) with configurable retry logic.
  • Engines: The framework is modular and supports various engines for text, speech, image generation, and web search, communicating via raw REST requests without requiring provider-specific SDKs.

Who it’s for

Python developers who want to integrate LLMs into their software with stronger guarantees of correctness, structured data output, and a a more natural Pythonic integration of semantic reasoning.

Highlights

  • Dual-mode Symbols: Seamlessly switch between literal Python operations and AI-driven semantic operations on the same object.
  • Design by Contract: Built-in validation and automatic remedy systems to reduce hallucinations and ensure type-validated outputs.
  • Modular Engine Architecture: Easily extensible design allowing for local hosting of engines or interfacing with external tools like web search and image generation.
  • Provider-Agnostic: Uses a shared transport layer to interact with various LLM providers (e.g., Anthropic, OpenAI, Gemini) via REST.

Related

  • Project
  • Project
  • Project
  • Project
  • Project