partitech/doctrine-pgvector
最新稳定版本:v0.0.8
Composer 安装命令:
composer require partitech/doctrine-pgvector
包简介
Postgresql vector type with doctrine
README 文档
README
Tip
For more detailed information and comprehensive guides, please visit our official documentation
Partitech Doctrine PgVector is a Doctrine extension for integrating PostgreSQL vector types into your PHP projects using Doctrine ORM. This module simplifies using vectors in your database by providing calculation functions such as distance, inner product, and cosine similarity.
📦 Installation
You can install Partitech Doctrine PgVector via Composer:
composer require partitech/doctrine-pgvector
⚙️ Configuration
Add the types and functions to your Doctrine configuration:
doctrine: dbal: types: vector: Partitech\DoctrinePgVector\Type\VectorType orm: dql: string_functions: distance: Partitech\DoctrinePgVector\Query\Distance inner_product: Partitech\DoctrinePgVector\Query\InnerProduct cosine_similarity: Partitech\DoctrinePgVector\Query\CosineSimilarity
🛠️ Usage
Vector Types
Use vector types directly in your Doctrine entities:
/** @Column(type="vector") */ private $vector;
Available DQL Functions
distance(vector, vector)inner_product(vector, vector)cosine_similarity(vector, vector)
These functions can be directly used in your Doctrine queries.
📌 Examples
Example query using distance:
$query = $entityManager->createQuery( 'SELECT e FROM Entity e ORDER BY distance(e.vector, :inputVector) ASC' ); $query->setParameter('inputVector', [0.1, 0.2, 0.3]); $result = $query->getResult();
✅ Testing and Development
To run unit tests:
composer test
🤝 Contribution
Contributions are welcome! Check the issues page to start contributing or submit a Pull Request.
📄 License
This project is licensed under the MIT License. See LICENSE for more details.
统计信息
- 总下载量: 88.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-06