pgvector / pgvector

Open-source vector similarity search for Postgres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow double precision in Avg

sean-idea9 opened this issue · comments

Hi, pgvector is incredible!

Is it possible to have double precision when averaging vectors instead of only float8?

For reference here is where averages are hardcoded to float8.

float8 *statevalues;

Hi @sean-idea9, float8 is double precision, but since avg returns a vector, the final result will be single precision. I don't think it makes sense to change this.

Hi @ankane, thanks for your quick response! But that's a loss of precision right? I don't understand why the loss of precision would be a good thing. Maybe there's something I need to learn about.

vector uses single precision to save space and memory, and avg uses double precision for the (intermediate) sum for better accuracy.