Using LangChain VDMS Client for Vector Storage

Posted: Feb 22, 2025.

Intel's Visual Data Management System (VDMS) is a powerful storage solution for efficiently accessing and searching visual data. In this guide, we'll explore how to use LangChain's VDMS client to connect to a VDMS server.

What is VDMS_Client?

The VDMS_Client class in LangChain provides a simple interface to connect to a VDMS server instance. VDMS is particularly useful for storing and querying vector embeddings for text, images, and video data. The client handles the connection details and allows you to interact with the VDMS server.

Reference

ParameterTypeDescription
hoststrIP address or hostname of the VDMS server (default: 'localhost')
portintPort number to connect to the VDMS server (default: 55555)

How to Use VDMS_Client

Basic Connection

The most basic usage is creating a connection to a VDMS server:

from langchain_community.vectorstores.vdms import VDMS_Client

# Connect to local VDMS server
client = VDMS_Client(host="localhost", port=55555)

# Connect to remote VDMS server
remote_client = VDMS_Client(
    host="vdms.example.com",
    port=55555
)

Using with Vector Store

The VDMS client is typically used in conjunction with LangChain's VDMS vector store implementation. Here's an example:

from langchain_community.vectorstores import VDMS
from langchain_huggingface import HuggingFaceEmbeddings

# Initialize the client
client = VDMS_Client(host="localhost", port=55555)

# Setup embedding function
embeddings = HuggingFaceEmbeddings(
    model_name="sentence-transformers/all-mpnet-base-v2"
)

# Create vector store with default settings (FaissFlat engine and L2 distance)
vector_store = VDMS.from_documents(
    documents,
    client=client,
    collection_name="my_collection",
    embedding=embeddings
)

Advanced Configuration

The client can be used with different VDMS indexing engines and distance metrics:

# Using FaissIVFFlat engine with Inner Product distance
vector_store = VDMS.from_documents(
    documents,
    client=client,
    collection_name="advanced_collection",
    embedding=embeddings,
    engine="FaissIVFFlat",
    distance_strategy="IP"
)

# Using FLINNG engine
vector_store = VDMS.from_documents(
    documents,
    client=client,
    collection_name="flinng_collection",
    embedding=embeddings,
    engine="Flinng"
)

# Using TileDBDense engine
vector_store = VDMS.from_documents(
    documents,
    client=client,
    collection_name="tiledb_collection",
    embedding=embeddings,
    engine="TileDBDense"
)

Working with Multiple Collections

You can create multiple vector stores with different collections using the same client:

# Create different collections for different types of data
text_collection = VDMS.from_documents(
    text_documents,
    client=client,
    collection_name="text_data"
)

image_collection = VDMS.from_documents(
    image_documents,
    client=client,
    collection_name="image_data"
)

The VDMS_Client provides the connection layer to interact with your VDMS server instance. While it's a relatively simple class, it's an essential component for using VDMS as a vector store in your LangChain applications.

Keep in mind that the VDMS server needs to be running and accessible at the specified host and port for the client to work properly. You can run VDMS using Docker or install it directly on your machine following the official installation instructions.

An alternative to LangSmith

Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.

LangChain Docs

Join 10,000+ subscribers

Every 2 weeks, latest model releases and industry news.

An alternative to LangSmith

Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.

LangChain Docs