miniCOIL clean_words mutates input and loses counts when normalized words collide

Open
#877 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

@pear1-pea is already working on this.

Since Nov 11, 2026.

  • #878 by @pear1-pea — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
1/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python

Research direction

The issue identifies SparseVectorConverter.clean_words() and provides two offline regression cases, with examples for input mutation and lost counts when normalized words collide. Start by reading that method and inspect the linked pull request #878, which is already open. Done means the cleaned result combines counts while retaining the known word's vocabulary ID and embedding, and the caller's input remains unchanged.

Written by the indexing model from the issue text.

Description

SparseVectorConverter.clean_words() changes the caller's WordEmbedding when an unknown word normalizes to a known word. It also loses the unknown word's count if the known word occurs later in the input mapping.

Reproduced on current main, without downloading a model:

from py_rust_stemmers import SnowballStemmer
from fastembed.sparse.utils.sparse_vectors_converter import SparseVectorConverter, WordEmbedding

converter = SparseVectorConverter(set(), SnowballStemmer("english"))
known = WordEmbedding("cat", ["cat"], 1, 1, [1.0, 0.0])
unknown = WordEmbedding("cat!", ["cat!"], 2, -1, [1.0])
sentence = {"cat": known, "cat!": unknown}
converter.clean_words(sentence)
print(known.count)  # 3: caller's original count was 1
print(converter.clean_words(sentence)["cat"].count)  # 5 instead of 3

With fresh inputs in the reverse order, the cleaned count is 1 instead of 3. The known word should retain its vocabulary ID and embedding while combining both counts, without changing the input. Two parameterized offline regression cases fail on main (one for input mutation, one for the lost count).

AI assistance: Codex inspected the source and ran the reproductions and tests.

Dominant language
Python
Stars
3.3k
Forks
314
Avg merge
5d 7h
Merged PRs (30d)
23

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from qdrant/fastembed

All issues in qdrant/fastembed

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.