Skip to main content

Memory Vector Index

The memory vector index is a simple implementation of the VectorIndex interface that stores all vectors in memory. It is helpful for development and prototyping or when you only have a small number of entries and want to avoid setting up a database, e.g., for conversational memory that does not need to be persisted.


API | Examples

Create a Vector Index

import { MemoryVectorIndex, zodSchema } from "modelfusion";

const vectorIndex = new MemoryVectorIndex<TextChunk>();


const serializedData = vectorIndex.serialize();


Deserialization can optionally take a Zod schema for type validation:

const deserializedIndex = await MemoryVectorIndex.deserialize({
schema: zodSchema(z.object({ text: z.string() })),