pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress
7+ messages / 4 participants
[nested] [flat]

* [pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress
@ 2025-01-21 12:17 "clemensvonmuu (@clemensvonmuu)" <noreply+clemensvonmuu@github.com>
  0 siblings, 0 replies; 7+ messages in thread

From: clemensvonmuu (@clemensvonmuu) @ 2025-01-21 12:17 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

I have the following problem with pgvector and postgress: I want to check if a vector is normalized. The calculation fails because the squares calculated for it are negative and no root can be calculated from negative numbers. To check this, I now have the squares calculated without a root. Result: the squares are negative.

Postgress and PGVectors are removed and installed from scratch. Vector is created over postgress shell so that all effects from other software can be excluded.

I would be grateful for any advice!

As this problem is happening directly within postgress/ pgvector without additionalsoftware parts I don't know which system information might be relevant. Here the most import ones: System:
-	 mac Mini, M1, macOS Sonoma 14.6.1.
-	PostgreSQL 14.15 (Homebrew) on aarch64-apple-darwin23.6.0, compiled by Apple clang version 16.0.0 (clang-1600.0.26.4), 64-bit
-	(1 row)
-	pgvector: stable 0.8.0 (bottled)

<img width="648" alt="Image" src="https://github.com/user-attachments/assets/7a2f3b98-8fba-41b9-ba86-c5cfe922ed7b"; />

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress
@ 2025-01-21 13:23 ` "VoVAllen (@VoVAllen)" <noreply+VoVAllen@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: VoVAllen (@VoVAllen) @ 2025-01-21 13:23 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

<#> is inner product. <-> is squared value

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress
@ 2025-01-21 14:18 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: jkatz (@jkatz) @ 2025-01-21 14:18 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

You can use the `vector_norm` function to make a comparison, though because it's floating point math, you'll want to check if the distance is within some epsilon, e.g.

```sql
SELECT id, vector_norm(vector) BETWEEN 0.99999 AND 1.00001 AS is_normalized
```


^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress
@ 2025-01-21 14:34 ` "clemensvonmuu (@clemensvonmuu)" <noreply+clemensvonmuu@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: clemensvonmuu (@clemensvonmuu) @ 2025-01-21 14:34 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> You can use the `vector_norm` function to make a comparison, though because it's floating point math, you'll want to check if the distance is within some epsilon, e.g.
> 
> SELECT id, vector_norm(vector) BETWEEN 0.99999 AND 1.00001 AS is_normalized

Hello: thank you very much! The problem is: the error I described above is only the smallest reproducible error, so to speak. I am building a RAG scenario and it is about vector similarity searches. They always go wrong because the similarities cannot be calculated. The reproducible reason is that this problem occurs with the negative squares. So I would not only need a small solution for the problem described. I would need to understand what the reason for the error is - and how to fix ist. It is said everywhere that Postgres/pgvector works perfectly. The question is: why not on my end?

Translated with DeepL.com (free version)

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress
@ 2025-01-21 17:53 ` "ankane (@ankane)" <noreply+ankane@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: ankane (@ankane) @ 2025-01-21 17:53 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress
@ 2025-01-21 17:53 ` "ankane (@ankane)" <noreply+ankane@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: ankane (@ankane) @ 2025-01-21 17:53 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @clemensvonmuu, `<#>` returns the negative inner product, which is why the result is negative. Please use other resources for additional help.

^ permalink  raw  [nested|flat] 7+ messages in thread

* Re: [pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress
@ 2025-01-21 18:00 ` "clemensvonmuu (@clemensvonmuu)" <noreply+clemensvonmuu@github.com>
  5 siblings, 0 replies; 7+ messages in thread

From: clemensvonmuu (@clemensvonmuu) @ 2025-01-21 18:00 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

This is unfortunately not the problem. However I found a fix. If are not willing to let people support: why are you giving the opportunity to open issues?

Von: Andrew Kane ***@***.***>
Datum: Dienstag, 21. Januar 2025 um 18:54
An: pgvector/pgvector ***@***.***>
Cc: Clemens Voll ***@***.***>, Mention ***@***.***>
Betreff: Re: [pgvector/pgvector] Negative values for the square prevent vector calculations in pgvector/postgress (Issue #762)

Hi @clemensvonmuu<https://github.com/clemensvonmuu;, <#> returns the negative inner product, which is why the result is negative. Please use other resources for additional help.

—
Reply to this email directly, view it on GitHub<https://github.com/pgvector/pgvector/issues/762#issuecomment-2605390831;, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AOZH2OTK6V3UKDPEC4G6BQ32L2CVLAVCNFSM6AAAAABVSMDWD2...;.
You are receiving this because you were mentioned.Message ID: ***@***.***>


^ permalink  raw  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2025-01-21 18:00 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-01-21 12:17 [pgvector/pgvector] issue #762: Negative values for the square prevent vector calculations in pgvector/postgress "clemensvonmuu (@clemensvonmuu)" <noreply+clemensvonmuu@github.com>
2025-01-21 13:23 ` "VoVAllen (@VoVAllen)" <noreply+VoVAllen@github.com>
2025-01-21 14:18 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2025-01-21 14:34 ` "clemensvonmuu (@clemensvonmuu)" <noreply+clemensvonmuu@github.com>
2025-01-21 17:53 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-01-21 17:53 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-01-21 18:00 ` "clemensvonmuu (@clemensvonmuu)" <noreply+clemensvonmuu@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox