[Bug]: Bm25 splits Tamil, Hindi, Sinhala and other words on their combining marks
Maintainer thường phản hồi trong vòng 4 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
The issue identifies remove_non_alphanumeric and SimpleTokenizer as the two places that split combining marks, and links open PR #887 for this fix. Read those tokenizer paths and the proposed tests in the PR; verify Tamil and other listed scripts stay intact, while text without combining marks keeps its existing token ids.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happened?
Qdrant/bm25 breaks words that contain combining marks into fragments. That covers Tamil (a supported language), Hindi, Sinhala, Bengali, Thai and Arabic with diacritics.
Two places strip the marks before the stemmer ever sees the words:
remove_non_alphanumericuses[^\w\s];SimpleTokenizeruses[^\w].
Python's \w does not include combining marks (Unicode categories Mn and Mc). The vowel signs and the virama in "தமிழ்" (Tamil) are therefore treated as separators, and the word becomes ["தம", "ழ"].
The fragments are shared by unrelated words, which causes false matches. With language="tamil", a query for "தமிழ்" (Tamil) also matches a document that only contains "தம்" (own) and "மழை" (rain):
from fastembed import SparseTextEmbedding
m = SparseTextEmbedding("Qdrant/bm25", language="tamil")
print(m.model.tokenizer.tokenize("தமிழ் மொழி அழகானது"))
# ['தம', 'ழ', 'ம', 'ழ', 'அழக', 'னத'] expected ['தமிழ்', 'மொழி', 'அழகானது']
tamil, rain = m.embed(["தமிழ் மொழி", "தம் ஊரில் மழை"])
query = next(m.query_embed("தமிழ்"))
print(set(query.indices) & set(rain.indices)) # not empty: the "rain" document matches
Other scripts, with disable_stemmer=True:
| Input | Tokens now | Expected |
|---|---|---|
| हिन्दी भाषा (Hindi) | ह न द भ ष |
हिन्दी भाषा |
| ශ්රී ලංකාව (Sinhala) | ශ ර ල ක ව |
ශ්රී ලංකාව |
| كَتَبَ الطالب (Arabic, voweled) | ك ت ب الطالب |
كَتَبَ الطالب |
The Snowball Tamil stemmer never receives a whole word, so language="tamil" cannot work as intended.
What is the expected behaviour?
Combining marks (and the zero-width joiner and non-joiner used in Indic and Sinhala conjuncts) should stay inside the word, as nltk.wordpunct_tokenize and LangChain's BM25 preprocessing already do.
A minimal reproducible example
See above.
What Python version are you on? e.g. python --version
Python 3.12
FastEmbed version
v0.8.1 (also on main)
What os are you seeing the problem on?
MacOS
Relevant stack traces and/or logs
No response
I have a fix with tests ready and can open a PR. It would change token ids only for text that contains combining marks, so Latin-script English and other text without them hashes exactly as before.
- Ngôn ngữ chính
- Python
- Star
- 3.3k
- Fork
- 314
- Merge trung bình
- 5 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của qdrant/fastembed
-
miniCOIL clean_words mutates input and loses counts when normalized words collideCó thể đã có người làm @pear1-pea đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 1/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: Revision-pinned HF downloads can falsely report intact files as corruptedCó thể đã có người làm @N7766 đã nhận 24 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: URL-backed custom models with the same basename reuse the wrong cached modelCó thể đã có người làm @rtmalikian đã nhận 24 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: rerank_pairs raises TypeError when pairs are passed as a tuple of pairsCó thể đã có người làm @michaelkillgta đã nhận 54 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Feature]: Support huggingface-hub 2.0Có thể làm lại được @joein đã nhận 64 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
qdrant/fastembed#742 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của qdrant/fastembed
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TigreGotico/orthography2ipa#2950 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Unstructured-IO/unstructured#4876 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
openfoodfacts/openfoodfacts-python#579 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
fairagro/m4.2_sql_to_arc#388 ·
Maintainer thường phản hồi trong vòng 1 ngày