Vectors

Models generates text; Vectors stores and retrieves embeddings. Applications can compose them through framework-standard adapters or use the lower-level models-embedding bridge directly. Neither project requires the other for its core runtime.

Framework Composition

For LangChain4j, vectors-langchain4j implements EmbeddingStore<TextSegment> while models-langchain4j implements the chat model. See LangChain4j RAG with Vectors.

For Spring Boot, vectors-spring-boot-starter contributes a Spring AI VectorStore and models-spring-boot-starter contributes the named local ChatModel. See Spring Boot with Vectors.

Direct Embedding Storage

models-embedding adapts a Models EmbeddingBackend to Vectors storage and semantic caching:

dependencies {
    implementation("com.integrallis:models-embedding:0.5.20")
}

See Embeddings for producing the EmbeddingBackend these examples take as a parameter.

The backend and collection must use the same vector dimension. The sink owns and closes the embedding backend; the application retains ownership of the collection. Batch documents, commit once, and embed the query through the same backend:

import com.integrallis.models.api.EmbeddingBackend;
import com.integrallis.models.embedding.VectorCollectionEmbeddingSink;
import com.integrallis.vectors.db.SearchRequest;
import com.integrallis.vectors.db.VectorCollection;
import java.util.List;

static void indexAndSearch(
        EmbeddingBackend embeddings,
        VectorCollection documents) {
    try (var sink = new VectorCollectionEmbeddingSink(embeddings, documents)) {
        sink.putAll(
            List.of("policy-17", "shipping-4"),
            List.of(
                "Orders can be cancelled before shipment.",
                "Standard shipping takes three business days."));
        documents.commit();

        float[] query = sink.backend().embed("When can I cancel an order?");
        var results = documents.search(
            SearchRequest.builder(query, 5).build());
        results.hits().forEach(hit -> System.out.println(hit.id()));
    }
}

VectorCollectionEmbeddingSink validates every vector before mutating the collection. A wrong batch size, null row, or mismatched dimension is reported as an embedding-backend contract violation rather than a later index error.

Vector search determines which context is retrieved. It does not validate that a generated answer is supported by that context. The optional RAG Validation policy provides that separate application layer.