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.1.tar.gz (14.1 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.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_vector_stores_shannonbase-0.1.1.tar.gz
Algorithm Hash digest
SHA256 644b3803ce1f561a1f925bd3300c925b1f67ebc5d7841f5946c7988295b15467
MD5 612b316aa534bee1ecd2bbca537cc28e
BLAKE2b-256 0009e724bdd4441702158c7aef7e4f438ecf6c12a4626dc4d9e13e942aafcb21

See more details on using hashes here.

Provenance

The following attestation bundles were made for llama_index_vector_stores_shannonbase-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_vector_stores_shannonbase-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f7f96b3f34e10c6e4eea0458fb4c7fb90e8ca8972178f3e8c5bea8724b828dc
MD5 a6e2e46df2fd925988b25f2f973cc6dc
BLAKE2b-256 45e57ff2decae8f2383529d508834a849d7a51586fea32f0cc44047010609322

See more details on using hashes here.

Provenance

The following attestation bundles were made for llama_index_vector_stores_shannonbase-0.1.1-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