Knowledge Freshness and Temporal Updates › Visualizing Staleness Over Time

Michael BrenndoerferDecember 1, 20263 min read
Language AI HandbookAll chapters
Part 45 of 67Knowledge, Memory, Editing, and Unlearning
Chapter 348Knowledge Freshness and Temporal Updates › Visualizing Staleness Over Time
Reading section 9 of 12 · Visualizing Staleness Over Time · 3 minSection 9 of 12 · 3 min

Section 9 of 12 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

The simulation gives 40 fast-changing and 40 slow-changing facts independent daily chances of changing. Each change produces a new value. On a refresh day, the index synchronizes after that day's changes, so the stale fraction resets to zero.

PythonIn [24]
CollapseExpand
import numpy as np


def simulate_staleness(
    n_days=180, refresh_every=14, n_fast=40, n_slow=40, seed=1
):
    """Average fraction of facts that are stale on each day.

    The mean wait for a change is 20 days for fast facts and 400 for slow facts.
    index fixed-refresh every 'refresh_every' days.
    """
    r = np.random.default_rng(seed)
    # Per-fact change probability per day.
    p_fast = 1.0 / 20.0
    p_slow = 1.0 / 400.0
    stale_fast = np.zeros(n_days)
    stale_slow = np.zeros(n_days)
    for f in range(n_fast):
        last_sync_value = 0
        true_value = 0
        for d in range(n_days):
            if r.random() < p_fast:
                true_value += 1
            if d % refresh_every == 0:
                last_sync_value = true_value
            stale_fast[d] += true_value != last_sync_value
    for f in range(n_slow):
        last_sync_value = 0
        true_value = 0
        for d in range(n_days):
            if r.random() < p_slow:
                true_value += 1
            if d % refresh_every == 0:
                last_sync_value = true_value
            stale_slow[d] += true_value != last_sync_value
    return stale_fast / n_fast, stale_slow / n_slow


fast_stale, slow_stale = simulate_staleness()
days = np.arange(len(fast_stale))
VisualizationOut [25]
CollapseExpand
Both lines reset to zero on refresh days. The fast group generally rises above the slow group between refreshes.
Daily stale fraction over 180 simulated days. The fast group changes more often between 14-day refreshes. Both groups synchronize on refresh days.

After ss independent daily opportunities for change since a refresh, a fact is stale with probability 1−(1−p)s1-(1-p)^s, where pp is its daily change probability. At day 13 this is about 49% for p=0.05p=0.05 and 3% for p=0.0025p=0.0025. Those are expectations under the illustrative model. Daily sample proportions vary. Choose cadences against measured change rates and acceptable staleness.

The calculation follows from the complement event. At age zero the index already includes the current value, so staleness is zero. With s elapsed daily change opportunities, all s must pass without an update for the cached value to remain current in this nonreverting model. Multiply their unchanged probabilities, then subtract from one. The maximum age within a full 14-day cycle is 13 days because the next refresh resets the age. A process that returns to an earlier value, queues updates, or has dependent changes needs a different probability model.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy