Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tensor math expressions in indexing language #27822

Open
sviatoslavp opened this issue Jul 19, 2023 · 1 comment
Open

Support tensor math expressions in indexing language #27822

sviatoslavp opened this issue Jul 19, 2023 · 1 comment
Assignees
Milestone

Comments

@sviatoslavp
Copy link

Hey!
I need to derive a weighted average tensor from several tensors (calculated from fields with onnx model) at indexing time e.g.

field emb1 type tensor<float>(x[512]) {
      indexing: summary
 }
field emb2 type tensor<float>(x[512]) {
       indexing: summary
  }
field emb3 type tensor<float>(x[512]) {
      indexing: summary
 }
field emb_v1 type tensor<float>(x[512]) {
      indexing: (input emb1 * 0.10) + (input emb2 * 0.20) + (input emb3 * 0.7) | attribute | summary | index
...

But tensor arithmetic is not supported now for indexing language.

It would be great to have the following operations supported

  1. Tensor and scalar multiplication e.g. input emb1 * 0.10
  2. Sum of tensors e.g. input emb1 + input emb2
  3. Linear combination e.g. (input emb1 * 0.10) + (input emb2 * 0.20)

I don't have usecases for the concatenation, but it may be useful to have it as well e.g. input emb1 . input emb2

This is not a show-stopper as I can calculate the linear combination outside Vespa and feed it, but this would make a solution more elegant

@andreer
Copy link
Member

andreer commented Feb 20, 2024

Another use case for this is dimensionality reduction such as slicing (for MRL embeddings) or random projection which can be expressed in tensor math

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants