Skip to main content

Time-aware uncertainty for RAG — temporal decay of evidence confidence using Subjective Logic

Project description

xrag-temporal

Time-aware uncertainty for RAG — temporal decay of evidence confidence using Subjective Logic.

Your RAG system treats every retrieved document as equally valid — whether it was written yesterday or three years ago. xrag-temporal fixes this by applying subjective logic temporal decay: as evidence ages, belief migrates into uncertainty.

Install

pip install xrag-temporal

Quick Start

from xrag_temporal import opinion, decay, decay_series, should_abstain

# Create an opinion from evidence
ev = opinion(belief=0.8, disbelief=0.1)  # strong evidence

# Decay it: 30 days old, 7-day half-life
stale = decay(ev, elapsed_days=30, half_life_days=7)
print(stale)
# → Opinion(b=0.0442, d=0.0055, u=0.9503)  — almost all uncertainty!

# Should the system abstain?
print(should_abstain(stale))  # True — uncertainty > 0.7

The Problem

Standard RAG pipelines retrieve documents and feed them to an LLM without considering when the evidence was created. A 3-year-old article about "the CEO of Twitter" will confidently produce the wrong answer.

The Solution

xrag-temporal decays belief and disbelief into uncertainty as evidence ages:

  • Fresh evidence (age ≈ 0): original confidence preserved
  • Aging evidence: belief/disbelief shrink, uncertainty grows
  • Stale evidence: nearly all mass is uncertainty → system knows it doesn't know

Three decay functions:

  • Exponential (default): smooth, never fully zero — λ = 2^(-t/τ)
  • Linear: reaches zero at 2× half-life — λ = max(0, 1 - t/2τ)
  • Step: binary fresh/stale — λ = 1 if t < τ else 0

License

MIT

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

xrag_temporal-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

xrag_temporal-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xrag_temporal-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for xrag_temporal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 017a4a8d5aa073fc788d2e3a3b5c3fed612ac12ac9bf656e31bf4bd5fce4a557
MD5 1ae9137871809ab30a034301d90ba142
BLAKE2b-256 9a7371c59162454ec1bcddacb47d68eef770b165e90e9a6dd91e69f0b50c2e2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xrag_temporal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for xrag_temporal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 849889a6b07b6d08929c625e5b6a2c457d40bdc577b0002dfa3aa380dbad321b
MD5 8a351334a3bd02850c6b5ac37269029c
BLAKE2b-256 62ff9622030cec1329fd9ae53490eccdeae67137d3722be215ca1863bc0ab71f

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