Selective re-embed index
com.tnsai.intelligence.rag.vector.SelectiveReembedIndex is a local vector index that re-embeds only chunks whose content hash changed. It is @since 0.14.0 in TnsAI 0.14.0 (TnsAI@1291fe9e, TAN-3660 / PR #150). It ships in Maven Central 0.14.1.
This is the laptop / default ingest path. Qdrant and pgvector stay the
production com.tnsai.memory.advanced.VectorIndex backends. This type
does not implement VectorIndex, and nothing in Role RAG opens it
from an env URL or @VectorMemory.provider.
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.
What it does
SelectiveReembedIndex index = new SelectiveReembedIndex(embeddings);
ReindexStats first = index.syncSource("a.md", List.of("alpha", "shared"));
ReindexStats again = index.syncSource("a.md", List.of("alpha changed", "shared"));
List<ScoredChunk> hits = index.search("alpha", 3);syncSource(sourceId, chunks) replaces one source's ordered chunk
texts. Each chunk is keyed by SHA-256 of its UTF-8 bytes:
- a hash that already has a vector is reused
- a new hash calls
EmbeddingFunction.embedonce and stores that vector - a hash dropped from this source is removed only when no other source still owns it
- consecutive chunks on the same source become neighbors
ReindexStats reports considered, reused, embedded, and
removed. Duplicate payloads across sources share one stored
embedding. size() is the unique-hash count. uniqueEmbeddingRatio()
is unique / naive; 1.0 means no sharing.
search(query, topK) embeds the query and ranks unique stored
vectors by cosine similarity. Hits are ScoredChunk records
(contentHash, sourceId, text, score). Dimension is pinned on
the first embed; a later mismatched length fails loud.
Not this page
- Qdrant and pgvector — production
VectorIndexadapters - Knowledge Base —
InMemoryKnowledgeBaseis a different store - Server FILE incremental skip — SHA-256 of whole files on the indexer path, not this type
Related
- Pipeline — FILE ingest and Server
FileIndexer - Embeddings — process-wide
EmbeddingFunction
Smart document segmentation
com.tnsai.intelligence.rag.segment.SmartDocumentSegmenter splits a long paper on headings and returns com.tnsai.intelligence.rag.segment.DocumentSegment records. Both are @since 0.14.0 in TnsAI 0.14.0 (TnsAI@609a661d, TAN-3651). They ship in Maven Central 0.14.1.
Ordered knowledge-unit consumption
@Sequential, SequentialConfig, and SequentialUnitReader are @since 0.15.0. They first landed on framework main at TnsAI@933756d1 (PR #222 / TAN-5880). They ship in 0.15.0 and later — see Installation for the coordinates.