Skip to main content

LlamaIndex VectorStore for MySQL 9's native VECTOR type — works with ShannonBase, self-hosted MySQL, and MySQL HeatWave.

Project description

llama-index-vector-stores-shannonbase

A LlamaIndex VectorStore backed by MySQL 9's native VECTOR type. If your data already lives in MySQL, you can do retrieval without standing up a separate vector database.

It works against the three things that share the same VECTOR / STRING_TO_VECTOR / DISTANCE surface: ShannonBase (open-source "MySQL for AI"), self-hosted MySQL 9, and MySQL HeatWave.

This is the LlamaIndex sibling of langchain-shannonbase. Same storage engine underneath, wired to LlamaIndex's node and query model so it drops into a LlamaIndex pipeline instead of a LangChain one.

Install

pip install "llama-index-vector-stores-shannonbase[mysql]"

Leave off [mysql] if you only want the offline in-memory backend for tests.

Usage

from llama_index.core import VectorStoreIndex, StorageContext
from llama_index.core.schema import TextNode
from llama_index.vector_stores.shannonbase import ShannonBaseVectorStore

store = ShannonBaseVectorStore(
    table="documents",
    host="127.0.0.1", port=3306, user="root", password="", database="rag",
)

# with an index and your embed model of choice
storage = StorageContext.from_defaults(vector_store=store)
index = VectorStoreIndex.from_documents(documents, storage_context=storage)
retriever = index.as_retriever(similarity_top_k=3)
retriever.retrieve("what's the return policy?")

The table is created on the first write, with an embedding VECTOR(n) column sized to your embedding model, and a FULLTEXT index on the text column for hybrid search.

What's supported

  • add, delete(ref_doc_id), and query
  • Query modes: DEFAULT (vector), MMR (diverse results), and HYBRID (vector + MySQL FULLTEXT keyword matching, fused by reciprocal rank)
  • Metadata filters: EQ, NE, GT, GTE, LT, LTE, IN, NIN (combined with AND; OR and nested filters aren't supported yet)
  • cosine (default), dot, and euclidean metrics via metric=...

For very large tables there's the same approximate IVF index as the LangChain package, reachable through the underlying store (store.client).

Notes on scale

By default search is an exact DISTANCE scan (100% recall), which is fine into the low millions of vectors. On MySQL HeatWave you get its automatic HNSW vector index for free on these queries. On ShannonBase or self-hosted MySQL, build the app-side IVF index for approximate search at scale.

Backend is shared with langchain-shannonbase

The _sql, _store, _filter, and _ivf modules are copied verbatim from langchain-shannonbase so both packages behave identically at the storage layer. scripts/check_backend_sync.py fails if they drift.

License

MIT

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

llama_index_vector_stores_shannonbase-0.1.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_vector_stores_shannonbase-0.1.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_vector_stores_shannonbase-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cbb1c9e42a9dc8dd03275c525b96d9de4b6330ad66dba3307da3d90eb4fa3d9b
MD5 52e66d44bfafa2212abb763667bc5da5
BLAKE2b-256 a7cf96eb5e14b878283d7d27b30ae3459be8798a85abe3209d57ea1284a094e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for llama_index_vector_stores_shannonbase-0.1.0.tar.gz:

Publisher: publish.yml on apoorva-01/llama-index-vector-stores-shannonbase

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llama_index_vector_stores_shannonbase-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_vector_stores_shannonbase-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3acbbd0e38057076ccc9d6337d21008cf0fd5858a9d6a45df62415231640c5e4
MD5 da30aadb15dfc2e315819f64c1ca9502
BLAKE2b-256 2762eedb1dd166d65ab503a55c3e229455f67a4ab10fe20360c2612c07299a74

See more details on using hashes here.

Provenance

The following attestation bundles were made for llama_index_vector_stores_shannonbase-0.1.0-py3-none-any.whl:

Publisher: publish.yml on apoorva-01/llama-index-vector-stores-shannonbase

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page