Understand Natural Language Search caching and incremental updates
mainTo minimize costs and processing time, the system uses incremental updates and caching for embeddings and titles.
1. Embedding Cache (image_embedding)
Embeddings are stored in the image_embedding table keyed by image_id. An image is skipped during updates if it has the same model, same text_hash, and an existing vec is present.
Re-vectorization logic:
text_hash = sha256(f"{normalize_version}:{prompt_text}")
prompt_text: Extracted and optionally normalized text.normalize_version: A code-derived fingerprint of the normalization rules used.
To force a rebuild: Pass force=true to build_iib_output_embeddings or force_embed=true to cluster_iib_output_job_start.
2. Title Cache (topic_title_cache)
Titles and keywords are stored in the topic_title_cache table keyed by cluster_hash.
Cache Hit Rule:
When use_title_cache=true and force_title=false, titles are reused. The cluster_hash includes:
- Member image IDs (sorted)
- Embedding
model,threshold,min_cluster_size title_model, outputlang- Normalization fingerprint (
normalize_version) and mode
To force regeneration: Pass force_title=true.