pgvecto.rs icon indicating copy to clipboard operation
pgvecto.rs copied to clipboard

Feature Request: Add Sum Aggregation and Column-Wise Multiplication for Sparse Vectors

Open Barabanga opened this issue 1 year ago • 4 comments
trafficstars

Starting off, we'd like to express our appreciacion for the project.

Integrating the following operations for sparse vectors would be of great use to our use case:

  • An aggregate sum operation for sparse vectors, similar to the one already implemented for dense vectors.
  • Element-wise multiplication.

By incorporating these functionalities, we can streamline computations directly within the database, sparing us the overhead of loading them into our application.

Thank you for considering this request.

Barabanga avatar May 10 '24 13:05 Barabanga

Thanks for your interest! May I ask what's your scenario to do the aggregate sum for sparse vectors? What's the query looks like?

VoVAllen avatar May 10 '24 23:05 VoVAllen

And what's Column-Wise Multiplication? Do you mean dot product between sparse vectors?

VoVAllen avatar May 10 '24 23:05 VoVAllen

Thanks for your interest! May I ask what's your scenario to do the aggregate sum for sparse vectors? What's the query looks like?

We utilize a sparse vector as a bag-of-words representation for a set of documents. In this representation, each dimension in the sparse vector denotes a term, while the value indicates its frequency within a given document. By using the sum aggregation, we would be able to easily compute some statistics about the collection. For example select sum(term_frequencies) from documents; would result in the total term frequencies for each term.

And what's Column-Wise Multiplication? Do you mean dot product between sparse vectors?

My bad, I meant element-wise multiplication, not column-wise. For example [1, 2, 3] * [1, 2, 3] = [1, 4, 9] (for both dense and sparse vectors)

Barabanga avatar May 13 '24 14:05 Barabanga

Understand! PRs on the way

VoVAllen avatar May 14 '24 07:05 VoVAllen