Support for the sparse embeddings #22

Open
opened 2026-02-16 05:16:07 -05:00 by yindo · 3 comments
Owner

Originally created by @magaton on GitHub (Jun 11, 2024).

The latest pgvector version supports sparsevec.
However, langchain's PGVector supports only one embeddings column in langchain_pg_embedding table.
It would be great to have a sparse_embedding column and sparse_embedding field in PGVector.

I have considered the alternative and that is to have 2 PGVector stores, 1 for dense and 1 for sparse vectors. However there are 2 problems with that:

  • PGVector has hardcoded table names for collection and embeddings
  • I would like to leverage excellent langchain indexer with SQL manager.
Originally created by @magaton on GitHub (Jun 11, 2024). The latest pgvector version supports `sparsevec`. However, langchain's PGVector supports only one embeddings column in `langchain_pg_embedding` table. It would be great to have a `sparse_embedding` column and `sparse_embedding` field in PGVector. I have considered the alternative and that is to have 2 PGVector stores, 1 for dense and 1 for sparse vectors. However there are 2 problems with that: - PGVector has hardcoded table names for collection and embeddings - I would like to leverage excellent langchain indexer with SQL manager.
yindo added the enhancementhelp wanted labels 2026-02-16 05:16:07 -05:00
Author
Owner

@gecBurton commented on GitHub (Jun 19, 2024):

hi @magaton I would be interested in collaborating on this, I would also like some kind of full-text/dense feature https://github.com/langchain-ai/langchain-postgres/issues/61

@gecBurton commented on GitHub (Jun 19, 2024): hi @magaton I would be interested in collaborating on this, I would also like some kind of full-text/dense feature https://github.com/langchain-ai/langchain-postgres/issues/61
Author
Owner

@Freezaa9 commented on GitHub (Oct 23, 2024):

Hello, would be interested also.

But I think each vector DB should be separated.
So for a hybrid search it would be

And then rerank by using EnsembleRetriever (for example: https://python.langchain.com/docs/how_to/ensemble_retriever/ )

To achieve this we should also bump the pgvector python version: #82

@Freezaa9 commented on GitHub (Oct 23, 2024): Hello, would be interested also. But I think each vector DB should be separated. So for a hybrid search it would be - One Dense embedding vector DB (using the current feature) - One Sparse Vector DB (using https://github.com/pgvector/pgvector-python/blob/master/examples/hybrid_search/cross_encoder.py) And then rerank by using EnsembleRetriever (for example: https://python.langchain.com/docs/how_to/ensemble_retriever/ ) To achieve this we should also bump the pgvector python version: #82
Author
Owner

@gecBurton commented on GitHub (Apr 27, 2025):

hi, I could really do with this feature. I have made a very crude PR that suggests how this might be done, I would appreciate some help as I do not know this codebase well :) https://github.com/langchain-ai/langchain-postgres/pull/204

@gecBurton commented on GitHub (Apr 27, 2025): hi, I could really do with this feature. I have made a very crude PR that suggests how this might be done, I would appreciate some help as I do not know this codebase well :) https://github.com/langchain-ai/langchain-postgres/pull/204
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#22