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

  • ~60-80% smaller than equivalent SQLite/JSON storage
  • 50-100%+ fact amplification through 3-pass inference (depends on graph density)
  • Zero hallucination - pure deterministic logic, full provenance tracking
  • Single-file portable - like SQLite, but optimized for knowledge graphs
  • Embedded inference - pre-computed transitive chains, zero query-time cost

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.1.tar.gz (21.4 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.1-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dotcausal-0.1.1.tar.gz
  • Upload date:
  • Size: 21.4 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.1.tar.gz
Algorithm Hash digest
SHA256 a0eb68961c43ec3c5013553fca5396850b210fa60b95220888455ae5ebd16511
MD5 3ee0975f3a5b076a04475eacb6e17b69
BLAKE2b-256 683790f7b83fcc1216eddf75ae335b585fec9b0c251b08118465078d7c7857fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dotcausal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed88a7d6118a27f2a48aafa219eee356d10dcb43edcb0a0f75426a6ccfe4cd07
MD5 66be05064cb802e8e8cb85406621aacc
BLAKE2b-256 b5c89b70abc38a557a77edb673f23487d20376296d2617269d91391299b4fbbb

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