llama-index vector-stores oceanbase integration
Project description
LlamaIndex Vector-Stores Integration: Oceanbase
OceanBase Database is a distributed relational database. It is developed entirely by Ant Group. The OceanBase Database is built on a common server cluster. Based on the Paxos protocol and its distributed structure, the OceanBase Database provides high availability and linear scalability.
OceanBase currently has the ability to store vectors. Users can easily perform the following operations with SQL:
- Create a table containing vector type fields;
- Create a vector index table based on the HNSW algorithm;
- Perform vector approximate nearest neighbor queries;
- ...
Limitations
The vector storage capability of OceanBase is still being enhanced, and currently has the following limitations:
- Cosine vector distance support depends on the OceanBase version. If cosine is not supported, use inner product or Euclidean distance instead (Euclidean is the default).
- It should be noted that
OceanBasecurrently only supports post-filtering (i.e., filtering based on metadata after performing an approximate nearest neighbor search).
Install dependencies
We use pyobvector to integrate OceanBase vector store into LlamaIndex.
So it is necessary to install it with pip install pyobvector before starting.
Setup OceanBase
We recommend using Docker to deploy OceanBase:
docker run --name=ob433 -e MODE=slim -p 2881:2881 -d oceanbase/oceanbase-ce:4.3.3.0-100000142024101215
Usage
%pip install llama-index-vector-stores-oceanbase
%pip install llama-index
# choose dashscope as embedding and llm model, your can also use default openai or other model to test
%pip install llama-index-embeddings-dashscope
%pip install llama-index-llms-dashscope
from llama_index.vector_stores.oceanbase import OceanBaseVectorStore
from pyobvector import ObVecClient
client = ObVecClient()
client.perform_raw_text_sql(
"ALTER SYSTEM ob_vector_memory_limit_percentage = 30"
)
# Initialize OceanBaseVectorStore
oceanbase = OceanBaseVectorStore(
client=client,
dim=1536,
drop_old=True,
normalize=True,
include_sparse=False,
include_fulltext=False,
)
Sparse / Fulltext / Hybrid Search
Enable sparse and fulltext support at initialization:
oceanbase = OceanBaseVectorStore(
client=client,
dim=1536,
drop_old=True,
normalize=True,
include_sparse=True,
include_fulltext=True,
)
Use VectorStoreQueryMode for sparse, fulltext, or hybrid search. Sparse and fulltext
queries are passed via keyword arguments:
from llama_index.core.vector_stores.types import (
VectorStoreQuery,
VectorStoreQueryMode,
)
# sparse search
q = VectorStoreQuery(mode=VectorStoreQueryMode.SPARSE, similarity_top_k=5)
result = oceanbase.query(q, sparse_query={0: 1.0, 10: 0.5})
# fulltext search
q = VectorStoreQuery(
mode=VectorStoreQueryMode.TEXT_SEARCH, query_str="oceanbase"
)
result = oceanbase.query(q)
# hybrid search
q = VectorStoreQuery(
mode=VectorStoreQueryMode.HYBRID,
query_embedding=[...],
query_str="oceanbase",
similarity_top_k=5,
)
result = oceanbase.query(q, sparse_query={0: 1.0})
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_vector_stores_oceanbase-0.4.0.tar.gz.
File metadata
- Download URL: llama_index_vector_stores_oceanbase-0.4.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81be16046c26a3c19cb4f8d13030298e391565cc10e153dd7dca1dc6c2cc2b1
|
|
| MD5 |
aa4f2ac5c97ba0f3f273e1f0c4eb2de2
|
|
| BLAKE2b-256 |
3b3aa667692b3a5d13e64425ab34702778c39168a8263478c3ecf6e945b3e8dd
|
File details
Details for the file llama_index_vector_stores_oceanbase-0.4.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_vector_stores_oceanbase-0.4.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f82b36d371f5f36ecbc8d42de22aa3fc28692ac2f8913b91e94d85862061eaf0
|
|
| MD5 |
f229d93f2edcc0eb0a68be42b9f03d2c
|
|
| BLAKE2b-256 |
43d88462b3062f818a7bb7c20730c6b9ff6f645f10d58d531f9ce8546460458a
|