Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save prasad-kumkar/17ac7c265eb80aea80557d25bef5ff76 to your computer and use it in GitHub Desktop.

Select an option

Save prasad-kumkar/17ac7c265eb80aea80557d25bef5ff76 to your computer and use it in GitHub Desktop.
Continuous Knowledge Update Mechanisms for RAG

Continuous Knowledge Update Mechanisms for RAG

A lot of RAG systems fail quietly after launch. The retrieval layer still returns relevant-looking text, but the corpus drifts away from the real world. Policies change, product docs move, records get corrected, and operational state turns over faster than the index. The result is a system that sounds grounded while relying on stale evidence.

Keeping RAG current is not a matter of running a nightly reindex job. You need an update mechanism that decides what changed, what needs to be invalidated, what needs to be re-embedded, and what should stay untouched so relevance does not bounce around every day.

1. Start with source-specific ingestion cadence, not one global schedule

Different source classes change at different rates, and they matter differently to the user.

  • product docs may justify hourly or event-driven updates during active releases
  • policy manuals may only need daily or approval-triggered refreshes
  • static reference documents may only need reprocessing when a checksum changes

If everything runs on the same cadence, you either overspend on slow-moving content or under-update the sources that actually determine whether the answer is still correct.

A better model is to assign an ingestion policy per source family:

{
  "source_family": "product_docs",
  "change_detection": "webhook_or_cdc",
  "target_ingestion_sla_minutes": 15,
  "freshness_budget_minutes": 60,
  "reembedding_policy": "only_changed_segments",
  "fallback_when_stale": "prefer_live_api_or_lower_confidence"
}

That policy becomes part of retrieval behavior, not just pipeline configuration.

2. Freshness should be a retrieval policy, not only an ingestion metric

Many teams track freshness as "when was this file last indexed?" That is incomplete. Retrieval needs to know whether the evidence is still fit for the task.

Freshness policy should consider:

  • source update frequency
  • business criticality of the answer
  • whether the content is durable knowledge or volatile state
  • whether the query is exploratory, advisory, or decision-support

For example, a system can probably answer "how does our SSO flow work?" from a document updated three days ago. It should not answer "is this vendor currently approved?" from a three-day-old chunk if the real answer lives in a changing system of record.

The clean design is to attach freshness metadata to every retrieval artifact:

  • source timestamp
  • ingestion timestamp
  • source version or revision id
  • freshness budget for that source class
  • task risk class for the current query

That lets the retriever do something more intelligent than top-k ranking. It can down-rank stale evidence, require corroboration, or route the query to a live source when the freshness budget is exceeded.

3. Invalidation must happen at the right level of granularity

The worst update pipelines reprocess the full corpus when one paragraph changes. The second-worst miss changes because they only watch file-level timestamps.

Good invalidation has levels:

  • document-level invalidation when the whole source changed materially
  • segment-level invalidation when only a subsection changed
  • metadata-level invalidation when tags, access controls, or entity associations changed
  • query-cache invalidation when previously cached retrieval results are now stale

Segment-level invalidation is especially important for RAG because it keeps update cost low and reduces unnecessary embedding churn. If one section of a long handbook changes, the system should invalidate the affected chunk group and its dependent search metadata, not the rest of the document.

You also want invalidation triggers beyond content diffs:

  • permission changes
  • source deletion or archival
  • schema changes in structured connectors
  • entity merges or splits
  • parser upgrades that change extraction quality

If you only invalidate on text deltas, retrieval can remain wrong even when the source meaning changed elsewhere in the system.

4. Re-embedding should be selective and versioned

Not every update needs a new embedding. This is where teams burn compute and destabilize ranking.

Re-embed when:

  • the semantic content of a segment changed
  • chunk boundaries changed
  • extraction quality improved enough to alter meaning
  • you intentionally migrate to a new embedding model or tokenizer regime

Do not re-embed just because:

  • display metadata changed
  • a timestamp updated but the underlying text did not
  • unrelated sections of the same document changed

The easiest way to control this is to keep both a content hash and an embedding version per segment. If the normalized segment text hash is unchanged, keep the vector. If the segment is structurally re-cut, assign a new chunk lineage and re-embed only the affected region.

Versioning matters here. A stable retrieval stack should distinguish:

  • source version
  • chunking policy version
  • embedding model version
  • extraction pipeline version

Without those boundaries, teams cannot explain why relevance shifted after an update.

5. Partial refreshes need stable chunk lineage

Partial refresh keeps a continuously updated RAG system affordable. But it only works if chunk identity is stable enough across revisions.

If minor edits cause the entire chunk map to reshuffle, you lose several things:

  • historical retrieval judgments stop being comparable
  • citation references become unstable
  • evaluation noise increases because chunk ids no longer mean the same thing

The fix is to maintain lineage between old and new segments wherever possible. A practical pattern is:

  1. Parse the updated source into structural units.
  2. Match new units against prior units using structural path plus text similarity.
  3. Preserve segment ids for unchanged or lightly edited units.
  4. Fork ids only for genuinely new, split, or merged segments.
  5. Re-embed and rewrite only the changed segment set.

That gives you partial refresh with stable observability. You can still tell whether retrieval got better because the knowledge improved or because segmentation churned.

6. Keep retrieval current without destabilizing relevance

The trap in continuous updates is thinking "fresher" automatically means "better." Frequent updates can make ranking less stable if the system is constantly replacing vectors or changing chunk boundaries.

To avoid that, treat updates like a controlled release:

  • build updated segments in a staging index first
  • run shadow retrieval or sampled evaluation against real queries
  • compare relevance, citation quality, and freshness-sensitive tasks
  • promote updates in batches instead of mutating the serving index blindly
  • keep rollback paths for bad parses or low-quality source pushes

You also want query-level safeguards. If a new update introduces low-confidence extractions, the system should not let those fragments dominate just because they are recent. Freshness should be one ranking factor, not a free pass over quality.

In practice, the best ranking behavior usually comes from combining:

  • semantic relevance
  • source authority
  • freshness score
  • contradiction risk

That combination keeps the corpus current while resisting noisy change.

7. Agentic retrieval should know when not to trust the index alone

This is where agentic RAG has a real advantage. A planner can inspect the freshness requirements of the query and decide whether static knowledge is sufficient.

For example:

  • if the query asks for current status, call a live API or system of record
  • if retrieved evidence exceeds its freshness budget, trigger a refresh or downgrade confidence
  • if two recently updated sources disagree, send the task through verification instead of synthesis
  • if the corpus is mid-refresh, prefer stable segments plus live checks for high-risk fields

That means continuous knowledge update is part of the orchestration logic that decides what the retriever is allowed to trust.

8. Measure update quality directly

If you only measure ingestion throughput, you will miss the real failure modes.

Track:

  • freshness budget violations by source family
  • percentage of updates handled as partial refresh versus full rebuild
  • re-embedding rate by source class
  • retrieval relevance deltas before and after refresh batches
  • stale-citation incidence
  • rollback rate for bad ingestions
  • time from source change to searchable availability
  • percentage of high-risk queries routed to live state instead of stale index content

Those metrics tell you whether the update mechanism is helping the RAG system stay current or just making the pipeline busier.

The core principle is simple: continuous knowledge update should improve recency without turning the index into a moving target. Source-specific cadence, explicit freshness policy, granular invalidation, selective re-embedding, stable partial refresh, and controlled rollout are what make that possible. If those mechanisms are implicit, relevance usually drifts before anyone notices.

Further Reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment