Using VikingDB Vector Store in LangChain
Posted: Nov 17, 2024.
VikingDB is a powerful vector database designed to store, index and manage large-scale embedding vectors generated by neural networks and machine learning models. In this guide, we'll explore how to use VikingDB as a vector store in LangChain.
What is VikingDB?
VikingDB is a specialized database focused on handling vector embeddings efficiently. It provides features for:
- Storing and indexing high-dimensional vectors
- Fast similarity search
- Collection management for organizing different vector sets
- Asynchronous operations support
- Flexible search options including MMR (Maximum Marginal Relevance)
Reference
Here are the key methods available in the VikingDB class:
Method | Description |
---|---|
from_texts() | Creates a new collection and adds text documents with their embeddings |
from_documents() | Creates a new collection from Document objects |
add_texts() | Adds new text documents to an existing collection |
similarity_search() | Performs similarity search for a query string |
similarity_search_with_score() | Similar to similarity_search but also returns relevance scores |
max_marginal_relevance_search() | Performs MMR search to get diverse results |
delete() | Deletes documents by their IDs |
How to Use VikingDB
Initial Setup
First, you'll need to install the required packages:
Connecting to VikingDB
To use VikingDB, you need to provide connection configuration:
Creating a Collection and Adding Documents
You can create a new collection and add documents in one go:
Performing Similarity Search
You can perform different types of searches:
Using Multiple Collections
VikingDB allows you to organize your vectors into different collections:
Async Operations
VikingDB supports async operations for better performance:
The VikingDB vector store provides a robust solution for managing and searching vector embeddings in LangChain applications. Its collection-based organization and support for async operations make it suitable for both small and large-scale applications.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.
LangChain DocsJoin 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.