Using the Volatile (In-Memory) connector (Preview)

Warning

The C# VolatileVectorStore is obsolete and has been replaced with a new package. See InMemory Connector

Warning

The Semantic Kernel Vector Store functionality is in preview, and improvements that require breaking changes may still occur in limited circumstances before release.

Warning

The Semantic Kernel Vector Store functionality is in preview, and improvements that require breaking changes may still occur in limited circumstances before release.

Overview

The Volatile Vector Store connector is a Vector Store implementation provided by Semantic Kernel that uses no external database and stores data in memory. This Vector Store is useful for prototyping scenarios or where high-speed in-memory operations are required.

The connector has the following characteristics.

Feature Area Support
Collection maps to In-memory dictionary
Supported key property types Any type that can be compared
Supported data property types Any type
Supported vector property types ReadOnlyMemory<float>
Supported index types N/A
Supported distance functions N/A
Supports multiple vectors in a record Yes
IsFilterable supported? Yes
IsFullTextSearchable supported? Yes
StoragePropertyName supported? No, since storage is volatile and data reuse is therefore not possible, custom naming is not useful and not supported.

Getting started

Add the Semantic Kernel Core nuget package to your project.

dotnet add package Microsoft.SemanticKernel.Core

You can add the vector store to the dependency injection container available on the KernelBuilder or to the IServiceCollection dependency injection container using extension methods provided by Semantic Kernel.

using Microsoft.SemanticKernel;

// Using Kernel Builder.
var kernelBuilder = Kernel
    .CreateBuilder()
    .AddVolatileVectorStore();
using Microsoft.SemanticKernel;

// Using IServiceCollection with ASP.NET Core.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddVolatileVectorStore();

You can construct a Volatile Vector Store instance directly.

using Microsoft.SemanticKernel.Data;

var vectorStore = new VolatileVectorStore();

It is possible to construct a direct reference to a named collection.

using Microsoft.SemanticKernel.Data;

var collection = new VolatileVectorStoreRecordCollection<string, Hotel>("skhotels");

Getting started

Install semantic kernel.

pip install semantic-kernel

You can then create a vector store instance using the VolatileStore class.


from semantic_kernel.connectors.memory.volatile import VolatileStore

vector_store = VolatileStore()

You can also create a collection directly.

from semantic_kernel.connectors.memory.volatile import VolatileCollection

collection = VolatileCollection(collection_name="skhotels", data_model_type=Hotel)

Serialization

Since the Volatile connector has a simple dict as the internal storage mechanism it can store any data model that can be serialized to a dict.

For more details on this concept see the serialization documentation.

Getting started

Include the latest version of the Semantic Kernel API in your Maven project, add the following dependency to your pom.xml:

<dependency>
    <groupId>com.microsoft.semantic-kernel</groupId>
    <artifactId>semantickernel-api</artifactId>
    <version>[LATEST]</version>
</dependency>

You can then create a vector store instance using the VolatileVectorStore class.

import com.microsoft.semantickernel.data.VolatileVectorStore;
import com.microsoft.semantickernel.data.VolatileVectorStoreRecordCollection;
import com.microsoft.semantickernel.data.VolatileVectorStoreRecordCollectionOptions;

public class Main {
    public static void main(String[] args) {
        // Build an Azure AI Search Vector Store
        var vectorStore = new VolatileVectorStore();
    }
}

You can also create a collection directly.

var collection = new VolatileVectorStoreRecordCollection<>("skhotels",
        VolatileVectorStoreRecordCollectionOptions.<Hotel>builder()
                .withRecordClass(Hotel.class)
                .build());