Knowledge Freshness and Temporal Updates › Versioning the Index and the Model

Michael BrenndoerferDecember 1, 20264 min read
Language AI HandbookAll chapters
Part 45 of 67Knowledge, Memory, Editing, and Unlearning
Chapter 348Knowledge Freshness and Temporal Updates › Versioning the Index and the Model
Reading section 7 of 12 · Versioning the Index and the Model · 4 minSection 7 of 12 · 4 min

Section 7 of 12 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Version the inputs to an answer. Besides the snapshot, retrieval-augmented answers can depend on the embedding and reranking implementations, prompt template, model checkpoint, and decoding configuration.

The practical pattern is immutable index snapshots with mutable pointers:

  • Never mutate a live index in place for a release.
  • Build the new index (or apply an update batch) into a new, sealed snapshot with a monotonic snapshot_id and a sealed_at timestamp.
  • Atomically flip the serving pointer from the old snapshot to the new one.
  • Keep old snapshots addressable for a defined retention window.

The recorded snapshot ID identifies the evidence pool used by a request. If an older snapshot is retained and its dependencies are compatible, a pointer change can restore that retrieval version.

The toy uses frozen documents, immutable tuples, and a single in-memory pointer. Each snapshot pairs source text with the adjudicated intervals the store recorded when it sealed the snapshot. The document ID identifies the text. The validity source and recording date identify the assertion that supplied its interval. The September snapshot uses Bob's corrected filing. The earlier Bob filing remains in the June snapshot and in the raw pool above. A deployed system needs atomic publication of the serving configuration, including any coupled components.

PythonIn [17]
CollapseExpand
@dataclass(frozen=True)
class Snapshot:
    snapshot_id: int
    docs: tuple[Doc, ...]
    sealed_at: datetime


class IndexStore:
    def __init__(self):
        self.snapshots: dict[int, Snapshot] = {}
        self.next_id = 0
        self.serving_id: Optional[int] = None

    def build_snapshot(self, docs, *, sealed_at) -> Snapshot:
        snapshot = Snapshot(self.next_id, tuple(docs), sealed_at)
        self.snapshots[snapshot.snapshot_id] = snapshot
        self.next_id += 1
        return snapshot

    def promote(self, snapshot_id: int):
        if snapshot_id not in self.snapshots:
            raise ValueError("Unknown snapshot")
        self.serving_id = snapshot_id

    def rollback(self, to_id: int):
        self.promote(to_id)

    def serving(self) -> Snapshot:
        if self.serving_id is None:
            raise RuntimeError("No snapshot promoted")
        return self.snapshots[self.serving_id]
PythonIn [18]
CollapseExpand
from dataclasses import replace

store = IndexStore()
doc_by_assertion = {
    ("Alice", alice_start): docs[0],
    ("Bob", initial_bob_start): docs[1],
    ("Bob", corrected_bob_start): docs[2],
}


def snapshot_documents(knowledge_base, sealed_at):
    selected = []
    for row in knowledge_base.as_of_belief(sealed_at):
        if (row.subject, row.predicate) != (ACME, "CEO"):
            continue
        source = doc_by_assertion[(row.obj, row.valid_start)]
        if source.indexed_at <= sealed_at:
            selected.append(
                replace(
                    source,
                    valid_from=row.valid_start,
                    valid_to=row.valid_end,
                    validity_source=row.source,
                    validity_recorded_at=row.trans_start,
                )
            )
    return tuple(selected)


s0, s1, s2 = (
    store.build_snapshot(snapshot_documents(kb, sealed_at), sealed_at=sealed_at)
    for sealed_at in (utc(2024, 1, 1), utc(2024, 6, 15), utc(2024, 9, 1))
)
store.promote(s0.snapshot_id)
store.promote(s1.snapshot_id)

fixed_target = utc(2024, 10, 1)
snapshot_results = [
    (sid, as_of_retrieve(query, snap.docs, 1, fixed_target))
    for sid, snap in store.snapshots.items()
]
history_results = [
    (
        snap.sealed_at.date(),
        world.date(),
        as_of_retrieve(query, snap.docs, len(snap.docs), world, mode="valid"),
    )
    for snap, world in (
        (s0, utc(2024, 5, 1)),
        (s1, corrected_bob_start),
        (s2, corrected_bob_start),
    )
]
earlier_tenure = as_of_retrieve(
    query, s2.docs, len(s2.docs), utc(2022, 6, 1), mode="valid"
)
ConsoleOut [19]
CollapseExpand
Serving before validation: 1
snapshot v0: top-1 = alice-2014
snapshot v1: top-1 = alice-2014
snapshot v2: top-1 = alice-2014
snapshot sealed 2024-01-01, valid on 2024-05-01: ['alice-2014']
snapshot sealed 2024-06-15, valid on 2023-02-01: ['alice-2014']
snapshot sealed 2024-09-01, valid on 2023-02-01: ['bob-fix-2024']
September snapshot, June 2022: payload alice-2014, validity from corrected-filing recorded 2024-09-01

The top-1 comparison holds the query, transaction filter, target date, and scorer fixed. The January snapshot admits Alice for May. At the February boundary, the June snapshot admits Alice and the September snapshot admits Bob's corrected filing. For June 2022, the September snapshot still retrieves the original Alice text, with its validity interval recorded from the corrected filing. Snapshot 2 waits for validation before promotion.

To compare a rollout and a replay, hold the query, time filter, and ranking configuration fixed. Identify the snapshot each request used before interpreting any accuracy change. If a snapshot was replaced during a long-running request, acquire the version once and pass it to later reads. Repeatedly looking up a mutable serving pointer can make one request combine evidence from multiple releases. The in-memory example has no simultaneous request threads.

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