Class InMemoryEmbeddingStore

java.lang.Object
org.episteme.natural.computing.ai.generative.rag.InMemoryEmbeddingStore

public class InMemoryEmbeddingStore extends Object
A simple in-memory Embedding Store for RAG (Retrieval Augmented Generation).

Stores document embeddings and retrieves nearest neighbors using Cosine Similarity.

Since:
2.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • InMemoryEmbeddingStore

      public InMemoryEmbeddingStore()
  • Method Details

    • add

      public void add(String id, String content, float[] embedding)
      Adds a document with its embedding vector to the store.
      Parameters:
      id - unique identifier.
      content - text content.
      embedding - float array representing the embedding.
    • search

      public List<String> search(float[] queryEmbedding, int k)
      Searches for the k nearest documents to the query vector.
      Parameters:
      queryEmbedding - the query vector.
      k - number of results to return.
      Returns:
      list of matching document contents.