From: JoeyLYZ666 (@JoeyLYZ666) <noreply+JoeyLYZ666@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #1043: bit Jaccard distance returns 1.0 for identical all-zero bit vectors
Date: Tue, 20 Oct 2026 03:24:04 +0000
Message-ID: <gh-pgvector-pgvector-1043@github.com> (raw)
## Summary
For `bit` values compared with pgvector’s Jaccard distance operator `<%>`, two identical all-zero bit vectors return distance `1.0`. Under the common set-distance convention `d(A, B) = 1 - |A ∩ B| / |A ∪ B|` with `d(∅, ∅) = 0`, the identical empty set should have distance `0` from itself. Hamming distance for the same pair returns `0`, so the anomaly is specific to Jaccard.
## Steps to reproduce
Run `reproduce.py` against PostgreSQL with pgvector enabled. It creates four `bit(8)` rows and queries with `00000000`:
```sql
SELECT id, b <%> '00000000'::bit(8) AS jaccard, b <~> '00000000'::bit(8) AS hamming
FROM codex_pgvector_bit_jaccard
ORDER BY b <%> '00000000'::bit(8), id;
```
[reproduce.py](https://github.com/user-attachments/files/33697916/reproduce.py)
## Expected behavior
The row with `b = '00000000'` is identical to the query. Its Jaccard distance should be `0.0` if empty-empty is treated as identical, matching the identity-of-indiscernibles MR.
## Actual behavior
The row with `b = '00000000'` returns Jaccard distance `1.0`, while Hamming distance is `0.0`.
## Metamorphic relation
Identity under self-query: for any stored vector `x`, querying with `x` should give the self row a distance of `0` for a distance operator, unless the operator explicitly rejects the input. This fails for the all-zero `bit` vector under Jaccard.
## Environment
Observed with pgvector in the local test environment used by `artifacts/codex-260925/independent10/probe_edge_semantics_batch2.py`.
## Notes on confidence
This is independent of the earlier pgvector dense/sparse cosine underflow/overflow artifacts. The remaining uncertainty is whether pgvector intentionally defines Jaccard distance for two empty bitsets as `1.0`; if that is intended, this should be treated as a documentation clarification request rather than a code bug.