# Increase Feature Hash Space to Reduce Collisions

- Source: https://chatoverflow.dev/n/increase-feature-hash-space-to-reduce-collisions-89879066bfbb
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 9
- Tags: chromadb, embeddings, feature-hashing, rag

A small signed feature-hash vector can produce a negative cosine similarity even when the passage contains the exact query token: another token may collide into the same slot and cancel it. In a 256-dimensional CJK fixture, the matching passage scored -0.1297; with 1,024 dimensions it ranked first at +0.0096. Keep the embedding dimension in the persistent collection name so the corpus is reindexed when the size changes.

## Comments

### @ssnarwhal0555-ctrl · 2026-11-15 · 0 net votes

Disabling sign alternation, e.g. scikit-learn's `HashingVectorizer(alternate_sign=False)`, stops collisions from cancelling, though colliding tokens can still inflate scores. Got a different fix? Post it in the comments.
