Skip to main content

Agentic knowledge verification using Subjective Logic confidence algebra

Project description

🔍 trustandverify

PyPI Python License: MIT Tests

Agentic knowledge verification using Subjective Logic confidence algebra.

trustandverify decomposes research questions into verifiable claims, gathers evidence from multiple search backends, scores confidence using formal Subjective Logic mathematics (Jøsang 2016), and produces provenance-rich reports with per-claim uncertainty quantification.


The Problem

Every major AI system treats confidence as a single scalar — or ignores it entirely. A confidence = 0.5 is meaningless: it could mean "strong evidence that the probability is 50%", or "we have literally no evidence and are guessing." These require fundamentally different downstream decisions.

trustandverify uses Subjective Logic opinion tuples (belief, disbelief, uncertainty, base_rate) so you always know not just what the AI thinks, but how much evidence it has.


Quick Start

pip install trustandverify[tavily,gemini]
import asyncio
from trustandverify import verify

report = asyncio.run(verify("Is remote work more productive than office work?"))
print(report.summary)
for claim in report.claims:
    op = claim.opinion
    print(f"  [{claim.verdict}] {claim.text}")
    print(f"    P={op.projected_probability():.3f}  b={op.belief:.3f} d={op.disbelief:.3f} u={op.uncertainty:.3f}")

Configured Usage

from trustandverify import TrustAgent, TrustConfig
from trustandverify.search import TavilySearch
from trustandverify.llm import GeminiBackend
from trustandverify.storage import SQLiteStorage
from trustandverify.export import JsonLdExporter, MarkdownExporter

config = TrustConfig(num_claims=5, max_sources_per_claim=3)

agent = TrustAgent(
    config=config,
    search=TavilySearch(),
    llm=GeminiBackend(),
    storage=SQLiteStorage("reports.db"),
)

report = await agent.verify("Is nuclear energy safer than solar?")

JsonLdExporter().render_to_file(report, "report.jsonld")
MarkdownExporter().render_to_file(report, "report.md")

CLI

trustandverify "Is coffee healthy?"
trustandverify "Is coffee healthy?" --claims 5 --llm gemini --format markdown
trustandverify ui   # Launch Streamlit dashboard

Why Subjective Logic?

Scenario Scalar Confidence trustandverify Opinion
Strong evidence it's 50/50 0.5 b=0.45, d=0.45, u=0.10
No evidence at all 0.5 b=0.00, d=0.00, u=1.00
Sources violently disagree 0.5 b=0.40, d=0.40, u=0.20

Confidence algebra (from jsonld-ex):

  • Cumulative fusion — more independent agreeing sources → lower uncertainty
  • Trust discount.gov/.edu sources weighted higher than Reddit
  • Pairwise conflict detection — surfaces where sources disagree, quantified

Install Options

pip install trustandverify                              # core only
pip install trustandverify[tavily,gemini]               # minimal working setup
pip install trustandverify[tavily,brave,openai,sqlite]  # typical setup
pip install trustandverify[all]                         # everything

Architecture

trustandverify/
├── core/        — TrustAgent, pipeline, models, config
├── scoring/     — Subjective Logic algebra (wraps jsonld-ex)
├── search/      — SearchBackend protocol + Tavily, Brave, Bing, SerpAPI
├── llm/         — LLMBackend protocol + Gemini, OpenAI, Anthropic, Ollama
├── storage/     — StorageBackend protocol + memory, SQLite, Postgres, Neo4j
├── cache/       — CacheBackend protocol + file cache, Redis
├── export/      — ExportBackend protocol + JSON-LD, Markdown, HTML, PDF
├── cli/         — Typer CLI
└── ui/          — Streamlit dashboard

References

  • Jøsang, A. (2016). Subjective Logic: A Formalism for Reasoning Under Uncertainty. Springer.
  • jsonld-ex — JSON-LD 1.2 extensions with Subjective Logic confidence algebra
  • W3C PROV-O — Provenance Ontology

License

MIT — see LICENSE.

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

trustandverify-0.1.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

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

trustandverify-0.1.0-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trustandverify-0.1.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.2 Windows/11

File hashes

Hashes for trustandverify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60fa119bf10b5ff9dd7ff6135ccbec246659c3bdc1559e71185ad0dc8a138859
MD5 18224a6813f50f0cb971da8b4712f53f
BLAKE2b-256 98a2c243bf0c1a4f090f1501fd5f3dcbc37badcdd11a8e01e7c8208f70f1cf50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trustandverify-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.2 Windows/11

File hashes

Hashes for trustandverify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e52c7ffafafcd0fb5eb6479508bd906b77252f8eda356bf3378f78f63fa14959
MD5 45a2897f89f24b56cf670b3564d88a64
BLAKE2b-256 3ace6c9abf0c92a52bbf509411098435259561910141caddf7f385aeaf94dca0

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