Skip to main content

Binary Knowledge Graph Format with Embedded Inference for AI Applications

Project description

dotcausal

Binary Knowledge Graph Format with Embedded Inference

PyPI version License: MIT

The .causal format is a binary storage format for causal knowledge graphs with embedded deterministic inference rules. Designed for AI applications requiring zero-hallucination guarantees.

Features

  • 72% smaller than SQLite for equivalent data
  • 1.9x fact amplification through 3-pass inference
  • 38x faster queries than traditional databases
  • Zero hallucination - pure deterministic logic
  • Single-file portable - like SQLite, but for knowledge graphs

Installation

pip install dotcausal

Quick Start

Python API

from dotcausal import CausalFile, CausalWriter, CausalReader

# Create a new .causal file
writer = CausalWriter()
writer.add_triplet(
    trigger="SARS-CoV-2 infection",
    mechanism="causes",
    outcome="mitochondrial dysfunction",
    confidence=0.9,
    source="paper1.pdf"
)
writer.add_triplet(
    trigger="mitochondrial dysfunction",
    mechanism="leads to",
    outcome="chronic fatigue",
    confidence=0.85,
    source="paper2.pdf"
)
stats = writer.save("knowledge.causal")
print(f"Saved {stats['triplets']} triplets")

# Read and query with inference
reader = CausalReader("knowledge.causal")

# Get explicit facts only
explicit = reader.get_all_triplets(include_inferred=False)
print(f"Explicit: {len(explicit)}")

# Get amplified facts (explicit + inferred)
all_facts = reader.get_all_triplets(include_inferred=True)
print(f"Total with inference: {len(all_facts)}")

# Search
results = reader.search("COVID", field="all")
for r in results:
    print(f"{r['trigger']}{r['mechanism']}{r['outcome']}")

Command Line

# Show file statistics
dotcausal stats knowledge.causal

# Query the graph
dotcausal query knowledge.causal "COVID" --limit 10

# Convert SQLite to .causal
dotcausal convert pipeline.db output.causal

# Export to JSON
dotcausal export knowledge.causal -o output.json

# Validate file integrity
dotcausal validate knowledge.causal

The 3-Pass Inference Engine

The .causal format includes a deterministic inference engine that derives new facts from explicit ones:

Pass Method Example
1 Exact keyword matching A→activates→B + B→activates→C = A→activates→C
2 Semantic direction positive×positive = positive chain
3 Jaro-Winkler fuzzy "COVID-19" ↔ "SARS-CoV-2" (similarity 0.82)

All inference is deterministic - same input always produces same output. Zero hallucination guaranteed.

File Format

[HEADER 64 bytes]  → Magic "CAUSAL01", Version, CRC
[OFFSET TABLE]     → Section offsets
[ENTITIES]         → Deduplicated dictionary
[TRIPLETS]         → Explicit facts with metadata
[RULES]            → Inference rules
[CLUSTERS]         → Semantic groupings
[GAPS]             → Knowledge gaps

Use Cases

  • RAG Enhancement: Ground LLM responses in verified causal chains
  • Scientific Discovery: Amplify weak signals through transitive inference
  • Knowledge Bases: Portable, compressed storage for triplet data
  • AI Safety: Zero-hallucination fact retrieval

Citation

If you use .causal in your research, please cite:

@software{foss2026dotcausal,
  author = {Foss, David Tom},
  title = {dotcausal: Binary Knowledge Graph Format with Embedded Inference},
  year = {2026},
  url = {https://github.com/dotcausal/dotcausal}
}

Links

License

MIT License - see LICENSE for details.

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

dotcausal-0.1.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dotcausal-0.1.0-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file dotcausal-0.1.0.tar.gz.

File metadata

  • Download URL: dotcausal-0.1.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dotcausal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d9531e6df9a0eb13a069fbbc5acef93c9bd0d3afc1aafcdf309d9b41dc21a59a
MD5 a9e39066ed6b00910f92672d5c50622e
BLAKE2b-256 667b3e56ce0837aff1d578b8a96e91dc1333cb6c1f329ed8e3b7a38874feb20d

See more details on using hashes here.

File details

Details for the file dotcausal-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dotcausal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dotcausal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 919b5bd42787ae08014ddad9856f33d4ccb764c5b4916ab7864e82a2a5a59bae
MD5 d16600e92d4e8dbfddaeec1efdec7fdc
BLAKE2b-256 1f0814ccc3e45b268a53ff4191c86851e4c217723b77ead90138490816a433c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page