A document set that updates weekly doesn't need the whole corpus re-embedded every time — most of it hasn't changed. Re-embedding everything anyway is the default in a lot of tutorials, and it's needlessly slow and costly at any real scale.
A practical incremental approach
- Hash each source document (or each chunk) and store the hash alongside its embedding.
- On an update run, compute new hashes and diff against stored ones — only re-embed documents whose hash changed.
- Delete embeddings for documents that were removed entirely, not just leave them stale in the index.
The trap to avoid
Chunk boundaries can shift even for a small edit near the start of a document, which changes every downstream chunk's hash. Chunk-level hashing catches real changes; document-level hashing is simpler but coarser — pick based on how often your documents change internally versus wholesale.
See metadata filtering in RAG pipelines for a related ingestion-time concern.
— Pranjul Rathour, GenAI Engineer from Kanpur, India. Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at any campus: pranjulrathour41@gmail.com.
