Download the PHP package allanpichardo/mysql-vector without Composer

On this page you can find all versions of the php package allanpichardo/mysql-vector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mysql-vector

A Library for MySQL Vector Operations and Text Embeddings

Overview

The VectorTable class is a PHP implementation designed to facilitate the storage, retrieval, and comparison of high-dimensional vectors in a MySQL database. This class utilizes MySQL JSON data types and a custom cosine similarity function (COSIM) to perform vector comparisons efficiently.

Search Performance

Vectors are binary quantized upon insertion into the database to optimize search speed and reranked to improve accuracy. However, this library is only suitable for small datasets (less than 1,000,000 vectors). For large datasets, it is recommended that you use a dedicated vector database such as Qdrant.

Search Benchmarks (384-dimensional vectors): Vectors Time (seconds)
100 0.02
1000 0.02
10000 0.03
100000 0.06
1000000 0.48

Features

Requirements

Installation

  1. Ensure that PHP and MySQL are installed and properly configured on your system.
  2. Install the library using Composer.

Usage

Initializing the Vector Table

Import the VectorTable class and create a new instance using the MySQLi connection, table name, and vector dimension.

Setting Up the Vector Table in MySQL

The initialize method will create the vector table in MySQL if it does not already exist. This method will also create the COSIM function in MySQL if it does not already exist.

Inserting and Managing Vectors

Calculating Cosine Similarity

Searching for Similar Vectors

Perform a search for vectors similar to a given vector using the cosine similarity criteria. The topN parameter specifies the maximum number of similar vectors to return.

Text Embeddings

The Embedder class calculates 384-dimensional text embeddings using the BGE embedding model. The first time you instanciate the Embedder class, the ONNX runtime will be installed automatically. The maximum length of the input text is 512 characters. The Embedder class will automatically truncate the input text to 512 characters if it is longer than 512 characters.

Contributions

Contributions to this project are welcome. Please ensure that your code adheres to the existing coding standards and includes appropriate tests.

License

MIT License


All versions of mysql-vector with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-mysqli Version *
bdelespierre/php-kmeans Version ^2.2
ext-mbstring Version *
ext-intl Version *
symfony/polyfill-intl-normalizer Version ^1.28
symfony/polyfill-mbstring Version ^1.28
ext-ctype Version *
symfony/polyfill-ctype Version ^1.28
ext-iconv Version *
symfony/polyfill-iconv Version ^1.28
ankane/onnxruntime Version ^0.2.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package allanpichardo/mysql-vector contains the following files

Loading the files please wait ....