mysql_vss is a plugin designed for storing and searching vector embeddings using approximate nearest neighbor search, leveraging the Annoy library for fast lookups in high-dimensional spaces.
๐ง Experimental Stage: The plugin is experimental and not recommended for production use yet.
gcc and g++.git clone https://github.com/stephenc222/mysql_vss
cd mysql_vss
git submodule update --init --recursive --progress
mysql-server. This plugin requires a mysql-server build from source to link against:cd src/vendor/mysql-server
mkdir build
cd build
cmake ..
make
*NOTE: mysql_vss uses mysql-server version 8.0, and this is pegged in the mysql-server git submodule. There will be additional packages you'll need to install, such as a modern version of bison and others. CMake's output is pretty helpful in determining what you need
mysql-vss plugin source:cmake .
make
The compiled output is a shared library named something like libmysql_vss_v0.0.1_AmazonLinux2023_x86_64.so, tailored to your operating system.
CREATE FUNCTION vss_search RETURNS STRING SONAME 'libmysql_vss.so';
CREATE FUNCTION vss_version RETURNS STRING SONAME 'libmysql_vss.so';
Verify installation by checking the plugin version:
SELECT CAST(vss_version() AS CHAR);
Set up the embeddings table as per the required schema (currently a manual process):
CREATE TABLE IF NOT EXISTS embeddings (
ID INT PRIMARY KEY,
vector JSON NOT NULL,
original_text TEXT NOT NULL,
annoy_index INT
);
Use vss_search for querying similar embeddings:
SELECT e.original_text
FROM embeddings AS e
WHERE FIND_IN_SET(e.ID, CAST(vss_search('[0.01,0.02,0.03,...]') AS CHAR)) > 0
ORDER BY FIELD(e.ID, CAST(vss_search('[0.01,0.02,0.03,...]') AS CHAR)) DESC;
mysql_vss was developed using the embedding model, gte-base, a top performing embedding model that is runnable on a wide variety of consumer hardware.To enhance mysql_vss for larger data scales, some possible future development considerations include:
Additionally, configurations that you can take as well:
innodb_buffer_pool_size).Check out examples/app.py and the provided Dockerfile in the repository for demonstration and containerized deployment of mysql_vss.
21 commits
C++
47.4%
CMake
16.7%
Python
14.6%
Shell
11.0%
Dockerfile
6.9%
C
3.5%
mysql_vss is a plugin designed for storing and searching vector embeddings using approximate nearest neighbor search, leveraging the Annoy library for fast lookups in high-dimensional spaces.
๐ง Experimental Stage: The plugin is experimental and not recommended for production use yet.
gcc and g++.git clone https://github.com/stephenc222/mysql_vss
cd mysql_vss
git submodule update --init --recursive --progress
mysql-server. This plugin requires a mysql-server build from source to link against:cd src/vendor/mysql-server
mkdir build
cd build
cmake ..
make
*NOTE: mysql_vss uses mysql-server version 8.0, and this is pegged in the mysql-server git submodule. There will be additional packages you'll need to install, such as a modern version of bison and others. CMake's output is pretty helpful in determining what you need
mysql-vss plugin source:cmake .
make
The compiled output is a shared library named something like libmysql_vss_v0.0.1_AmazonLinux2023_x86_64.so, tailored to your operating system.
CREATE FUNCTION vss_search RETURNS STRING SONAME 'libmysql_vss.so';
CREATE FUNCTION vss_version RETURNS STRING SONAME 'libmysql_vss.so';
Verify installation by checking the plugin version:
SELECT CAST(vss_version() AS CHAR);
Set up the embeddings table as per the required schema (currently a manual process):
CREATE TABLE IF NOT EXISTS embeddings (
ID INT PRIMARY KEY,
vector JSON NOT NULL,
original_text TEXT NOT NULL,
annoy_index INT
);
Use vss_search for querying similar embeddings:
SELECT e.original_text
FROM embeddings AS e
WHERE FIND_IN_SET(e.ID, CAST(vss_search('[0.01,0.02,0.03,...]') AS CHAR)) > 0
ORDER BY FIELD(e.ID, CAST(vss_search('[0.01,0.02,0.03,...]') AS CHAR)) DESC;
mysql_vss was developed using the embedding model, gte-base, a top performing embedding model that is runnable on a wide variety of consumer hardware.To enhance mysql_vss for larger data scales, some possible future development considerations include:
Additionally, configurations that you can take as well:
innodb_buffer_pool_size).Check out examples/app.py and the provided Dockerfile in the repository for demonstration and containerized deployment of mysql_vss.
21 commits
C++
47.4%
CMake
16.7%
Python
14.6%
Shell
11.0%
Dockerfile
6.9%
C
3.5%