Most RAG (Retrieval-Augmented Generation) systems work fine for static knowledge basesโbut the moment your documents start changing (new policies, updated financials, revised product specs), they quickly go stale.
We solved that with a dynamic RAG pipeline that keeps embeddings and context fresh without doing heavy full rebuilds. Hereโs how it works:
๐งฉ High-Level Flow
1๏ธโฃ ๐๐๐ญ๐๐ก๐๐ซ (๐
๐ข๐ฅ๐/๐3 ๐๐ก๐๐ง๐ ๐๐ฌ)
โช Continuously listens for file changes (local folder or S3 bucket).
โช Detects when a document is new, updated, or deleted.
2๏ธโฃ๐๐ฆ๐๐๐๐๐ข๐ง๐ (๐จ๐ง๐ฅ๐ฒ ๐ฎ๐ฉ๐๐๐ญ๐๐ฌ)
โช Instead of re-embedding everything, it re-embeds only the changed chunks.
โช Saves time and compute costs while keeping the knowledge base fresh.
3๏ธโฃ ๐๐๐๐ญ๐จ๐ซ ๐๐ (๐๐ก๐ซ๐จ๐ฆ๐)
โช Stores embeddings with metadata like updated_at.
โช When conflicts arise (e.g., same document with old + new facts), retrieval logic can guide the LLM to trust the freshest snippet.
4๏ธโฃ ๐๐๐ (๐๐ฅ๐ฅ๐๐ฆ๐/๐๐ฉ๐๐ง๐๐)
โช Takes the top-k retrieved chunks and augments the query.
โช Produces a contextualized answer with citations.
5๏ธโฃ ๐๐ญ๐ซ๐๐๐ฆ๐ฅ๐ข๐ญ ๐๐
โช Users simply ask questions.
โช The UI calls the FastAPI backend, retrieves from Chroma, and passes to the LLM.
โชResponses include answers + sources, so users know why the model said what it did.
๐ง The Challenge (Simple Example)
One file said:
โก๏ธ โAll banks must maintain capital reserves of 10%.โ
Later, an update stated:
โก๏ธ โAll banks must maintain capital reserves of 12%.โ
When I asked: โWhat is the required capital reserve?โ
Static RAG: โI donโt know.โ (confused by conflicting facts)
Dynamic RAG: โ12%โ (trusts the most recent doc)
๐๐ก๐ ๐๐จ๐ฅ๐ฎ๐ญ๐ข๐จ๐ง โ ๐๐ฒ๐ง๐๐ฆ๐ข๐ ๐๐ฆ๐๐๐๐๐ข๐ง๐ ๐ฌ
๐ Watches for new/updated docs in real time
โก Re-embeds only what changes (no full rebuilds)
๐ท๏ธ Tracks updated_at so the LLM knows the freshest fact
๐ง Guides the model to resolve conflicts by trusting the most recent snippet
Now, when a file is updated, the system re-embeds instantly and gives the right answer.
For the full working codebase, check my GitHub repo
https://github.com/rajeevchandra/dynamic_embeddings
At the end of the day, AI systems are only as useful as the freshness of the knowledge they rely on. Building dynamic pipelines isnโt just about better tech โ itโs about building assistants that can actually keep up with how fast the world changes.
Top comments (0)