Class SelectiveReembedIndex
java.lang.Object
com.tnsai.intelligence.rag.vector.SelectiveReembedIndex
Local vector index that re-embeds only chunks whose content hash changed.
Unique SHA-256 payloads share one stored embedding. A source is a
cheap graph of those hashes (consecutive chunks are neighbors). Qdrant
and pgvector remain the production VectorIndex
backends; this is the laptop/default ingest path.
Storage vs a naive full reindex is the unique-hash set, not a marketing 97%. Recompute cost on a one-file edit is that file's new hashes, not the whole corpus.
- Since:
- 0.14.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordCounts from onesyncSource(String, List)call.static final recordOne search hit. -
Constructor Summary
ConstructorsConstructorDescriptionSelectiveReembedIndex(com.tnsai.memory.advanced.EmbeddingFunction embeddings) -
Method Summary
Modifier and TypeMethodDescriptionNeighbor hashes for one content hash (same-source adjacency).Cosine search over unique stored embeddings.intsize()Unique stored embeddings.syncSource(String sourceId, List<String> chunks) Replaces one source's chunks.doubleUnique embeddings divided by the naive per-chunk count.
-
Constructor Details
-
SelectiveReembedIndex
public SelectiveReembedIndex(com.tnsai.memory.advanced.EmbeddingFunction embeddings)
-
-
Method Details
-
syncSource
Replaces one source's chunks. Unchanged hashes keep their vector.- Parameters:
sourceId- stable source identity (file path, document id)chunks- ordered chunk texts- Returns:
- reuse / embed / remove counts
-
search
Cosine search over unique stored embeddings.- Parameters:
query- query texttopK- maximum hits- Returns:
- highest-first hits
-
size
public int size()Unique stored embeddings. -
neighbors
Neighbor hashes for one content hash (same-source adjacency). -
uniqueEmbeddingRatio
public double uniqueEmbeddingRatio()Unique embeddings divided by the naive per-chunk count. Lower is better; 1.0 means no sharing.
-