[PR #226] feat: support for Halfvec and Sparsevec vector types #251

Open
opened 2026-02-16 05:17:06 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langchain-postgres/pull/226
Author: @nazarpechka
Created: 6/26/2025
Status: 🔄 Open

Base: mainHead: support_halfvec_sparsevec


📝 Commits (4)

  • b70add0 feat: support for HALFVEC and SPARSEVEC vector types
  • b2d91f5 revert uv.lock change
  • d77b076 check if vector type is SPARSEVEC in IVFFlatIndex
  • 81a2fb8 formatting

📊 Changes

6 files changed (+160 additions, -14 deletions)

View changed files

📝 langchain_postgres/v2/async_vectorstore.py (+2 -2)
📝 langchain_postgres/v2/engine.py (+15 -1)
📝 langchain_postgres/v2/indexes.py (+34 -6)
📝 tests/unit_tests/v2/test_async_pg_vectorstore_index.py (+29 -2)
📝 tests/unit_tests/v2/test_engine.py (+39 -0)
📝 tests/unit_tests/v2/test_indexes.py (+41 -3)

📄 Description

This PR adds full support for pgvector’s Halfvec and Sparsevec vector types in both table and index creation.
This adresses the 2 000-dimension limit of the standard vector type, not enough for models like text-embedding-3-large.

  • halfvec stores embeddings as INT8 quantized values and supports indexing up to 16 000 dimensions.
  • sparsevec stores sparse embeddings and also supports up to 16 000 dimensions.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langchain-postgres/pull/226 **Author:** [@nazarpechka](https://github.com/nazarpechka) **Created:** 6/26/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `support_halfvec_sparsevec` --- ### 📝 Commits (4) - [`b70add0`](https://github.com/langchain-ai/langchain-postgres/commit/b70add0f26e45070d0a39a51c7b00e9d6566bf39) feat: support for HALFVEC and SPARSEVEC vector types - [`b2d91f5`](https://github.com/langchain-ai/langchain-postgres/commit/b2d91f586a022aac3938f93f06c6dd3e1fd9a9d7) revert uv.lock change - [`d77b076`](https://github.com/langchain-ai/langchain-postgres/commit/d77b0765c4dde2faa4f03123d6c79131abe753f3) check if vector type is SPARSEVEC in IVFFlatIndex - [`81a2fb8`](https://github.com/langchain-ai/langchain-postgres/commit/81a2fb88762095fa75c72103ea0850fedd2f07c9) formatting ### 📊 Changes **6 files changed** (+160 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `langchain_postgres/v2/async_vectorstore.py` (+2 -2) 📝 `langchain_postgres/v2/engine.py` (+15 -1) 📝 `langchain_postgres/v2/indexes.py` (+34 -6) 📝 `tests/unit_tests/v2/test_async_pg_vectorstore_index.py` (+29 -2) 📝 `tests/unit_tests/v2/test_engine.py` (+39 -0) 📝 `tests/unit_tests/v2/test_indexes.py` (+41 -3) </details> ### 📄 Description This PR adds full support for pgvector’s [Halfvec](https://github.com/pgvector/pgvector#halfvec-type) and [Sparsevec](https://github.com/pgvector/pgvector#sparsevec-type) vector types in both table and index creation. This adresses the 2 000-dimension limit of the standard vector type, not enough for models like text-embedding-3-large. - `halfvec` stores embeddings as INT8 quantized values and supports indexing up to 16 000 dimensions. - `sparsevec` stores sparse embeddings and also supports up to 16 000 dimensions. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 05:17:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#251