multilingual-dev-rag 0.1.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- multilingual_dev_rag-0.1.0rc1/LICENSE +201 -0
- multilingual_dev_rag-0.1.0rc1/PKG-INFO +237 -0
- multilingual_dev_rag-0.1.0rc1/README.md +204 -0
- multilingual_dev_rag-0.1.0rc1/pyproject.toml +73 -0
- multilingual_dev_rag-0.1.0rc1/setup.cfg +4 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/__init__.py +21 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/chunker.py +63 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/cli.py +72 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/config.py +136 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/embedder.py +33 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/fts_normalizer.py +115 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/indexer.py +167 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/mcp_server.py +128 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/profiles/generic.json +20 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/profiles/k3_mebel.json +32 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/qdrant_searcher.py +42 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/reader.py +27 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/searcher.py +19 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/zvec_indexer.py +300 -0
- multilingual_dev_rag-0.1.0rc1/src/dev_rag/zvec_searcher.py +181 -0
- multilingual_dev_rag-0.1.0rc1/src/multilingual_dev_rag.egg-info/PKG-INFO +237 -0
- multilingual_dev_rag-0.1.0rc1/src/multilingual_dev_rag.egg-info/SOURCES.txt +27 -0
- multilingual_dev_rag-0.1.0rc1/src/multilingual_dev_rag.egg-info/dependency_links.txt +1 -0
- multilingual_dev_rag-0.1.0rc1/src/multilingual_dev_rag.egg-info/entry_points.txt +4 -0
- multilingual_dev_rag-0.1.0rc1/src/multilingual_dev_rag.egg-info/requires.txt +10 -0
- multilingual_dev_rag-0.1.0rc1/src/multilingual_dev_rag.egg-info/top_level.txt +1 -0
- multilingual_dev_rag-0.1.0rc1/tests/test_config.py +197 -0
- multilingual_dev_rag-0.1.0rc1/tests/test_fts_normalizer.py +117 -0
- multilingual_dev_rag-0.1.0rc1/tests/test_zvec_integration.py +251 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: multilingual-dev-rag
|
|
3
|
+
Version: 0.1.0rc1
|
|
4
|
+
Summary: Local-first multilingual RAG for code and technical docs. In-process hybrid retrieval (vector + full-text) with FTS for Cyrillic and other non-ASCII scripts.
|
|
5
|
+
Author: Aleksandr Dragunkin
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/AlexandrDragunkin/multilingual-dev-rag
|
|
8
|
+
Project-URL: Repository, https://github.com/AlexandrDragunkin/multilingual-dev-rag
|
|
9
|
+
Project-URL: Issues, https://github.com/AlexandrDragunkin/multilingual-dev-rag/issues
|
|
10
|
+
Keywords: rag,vector-search,full-text-search,hybrid-search,multilingual,cyrillic,code-search,zvec,local-first
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
18
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
19
|
+
Classifier: Natural Language :: Russian
|
|
20
|
+
Classifier: Natural Language :: English
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: zvec>=0.5.1
|
|
25
|
+
Requires-Dist: sentence-transformers>=2.0
|
|
26
|
+
Provides-Extra: qdrant
|
|
27
|
+
Requires-Dist: qdrant-client>=1.7; extra == "qdrant"
|
|
28
|
+
Requires-Dist: httpx>=0.24; extra == "qdrant"
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# multilingual-dev-rag
|
|
35
|
+
|
|
36
|
+
Local-first multilingual RAG for code and technical docs. In-process hybrid retrieval (vector + full-text) with FTS for Cyrillic and other non-ASCII scripts.
|
|
37
|
+
|
|
38
|
+
[Русская версия](README_RU.md) · Apache-2.0
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Why this exists
|
|
43
|
+
|
|
44
|
+
Most local RAG setups pair a multilingual embedding model with a full-text index and call it hybrid search. That works — until your corpus is not in English.
|
|
45
|
+
|
|
46
|
+
The embedded engine this is built on ([zvec](https://github.com/alibaba/zvec)) ships a `standard` tokenizer that **drops non-ASCII tokens entirely** (on Windows and Linux — on macOS, curiously, it does not), and a `lowercase` filter that **only folds ASCII**. The result is not an error. A query for `воркер` returns zero rows, a query for `RabbitMQ` returns rows, and the hybrid quietly degrades to vector-only for half your corpus. Nothing in the logs says so.
|
|
47
|
+
|
|
48
|
+
The platform split is the nastier half of the story. A package that relied on `standard` alone would *appear* to work on a developer's Mac and silently break the moment it shipped to a Linux server — same code, same engine, different tokenizer behaviour per OS. The fix below does not depend on which side of that split you are on: it works everywhere, and is merely redundant where `standard` already handles Cyrillic.
|
|
49
|
+
|
|
50
|
+
## How the fix works
|
|
51
|
+
|
|
52
|
+
Swapping the tokenizer does not save you. The engine ships exactly three, and each breaks differently:
|
|
53
|
+
|
|
54
|
+
| Tokenizer | Cyrillic | Identifiers | Punctuation |
|
|
55
|
+
| --- | --- | --- | --- |
|
|
56
|
+
| `standard` | **discards it**¹ | splits correctly: `obj_k3_gab3` → `obj`, `k3`, `gab3` | separates correctly |
|
|
57
|
+
| `whitespace` | keeps it | **never splits** | **glues**: `RabbitMQ.` is one token |
|
|
58
|
+
| `jieba` | **shreds it** | splits | separates |
|
|
59
|
+
|
|
60
|
+
¹ On Windows and Linux. On macOS, `standard` *does* match Cyrillic — the only platform of the three where it does (verified across the CI matrix on zvec 0.5.1). The `text_fts` workaround below is therefore redundant on macOS but harmless: its lanes never double-count because Latin is excluded from `text_fts`.
|
|
61
|
+
|
|
62
|
+
`jieba` looks like the answer right up until you measure it at scale: 7 of 9 correct on a five-document probe, pure noise on a real 837-chunk corpus — a query for the exact title word of one document returned three unrelated ones, a different wrong answer per letter case. Worse than `standard`, which at least stayed honestly silent.
|
|
63
|
+
|
|
64
|
+
Hence the design: **do not pick the best tokenizer — use two**, each for what it is good at. The index carries two fields, and every query goes only to the field that can answer it:
|
|
65
|
+
|
|
66
|
+
| Field | Content | Tokenizer | Answers |
|
|
67
|
+
| --- | --- | --- | --- |
|
|
68
|
+
| `text` | original, verbatim | `standard` | ASCII words and identifiers — `obj_k3_gab3` is findable as `obj`, `k3`, `gab3` |
|
|
69
|
+
| `text_fts` | non-ASCII tokens only, casefolded, punctuation stripped | `whitespace` | Cyrillic, Greek, accented Latin, Arabic — in any letter case |
|
|
70
|
+
|
|
71
|
+
`text` stays byte-for-byte the original: it is what search returns to you. `text_fts` is derived and internal.
|
|
72
|
+
|
|
73
|
+
Latin is deliberately **excluded** from `text_fts`. If both fields matched `RabbitMQ`, a document containing it would score twice in the Reciprocal Rank Fusion and outrank documents that match the query's Russian half. Keeping the two lanes disjoint keeps the fusion honest.
|
|
74
|
+
|
|
75
|
+
Case folding happens in Python, not in the engine: `casefold()` handles `ß`/`SS` and Greek final sigma, which the engine's ASCII-only `lowercase` filter does not.
|
|
76
|
+
|
|
77
|
+
## What you get
|
|
78
|
+
|
|
79
|
+
- **Hybrid retrieval** — vector + full-text, fused with Reciprocal Rank Fusion.
|
|
80
|
+
- **FTS that survives non-ASCII** — verified end-to-end on Russian, German, Greek, French, Arabic.
|
|
81
|
+
- **No servers** — zvec runs in your process. No Qdrant, no Ollama, no Docker.
|
|
82
|
+
- **Profiles** — describe your corpus in JSON; the package stays generic.
|
|
83
|
+
- **MCP server** — exposes `rag_search` to Claude Code and other MCP clients.
|
|
84
|
+
|
|
85
|
+
## Requirements
|
|
86
|
+
|
|
87
|
+
**Python 3.10–3.14, 64-bit.** Everything else follows from zvec's wheels — it ships **no sdist**, so if there is no wheel for your platform there is no fallback to building from source.
|
|
88
|
+
|
|
89
|
+
| Platform | Wheel | Status |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| Windows x86_64 | `win_amd64` | **tested** — this is where it was built |
|
|
92
|
+
| Linux x86_64 / aarch64 | `manylinux_2_28` | **tested** — CI green (Python 3.10–3.13) |
|
|
93
|
+
| macOS Apple Silicon (11+) | `macosx_11_0_arm64` | **tested** — CI green (Python 3.10–3.13) |
|
|
94
|
+
| macOS Intel | — | **will not install** |
|
|
95
|
+
| Any 32-bit Python | — | **will not install** |
|
|
96
|
+
|
|
97
|
+
All three wheel-bearing platforms run the full suite in CI, including the seven integration tests that hit the live zvec engine.
|
|
98
|
+
|
|
99
|
+
On a platform without a wheel, `pip install` fails with `from versions: none`. That message means *wrong platform*, not *missing package* — no amount of build tooling will help.
|
|
100
|
+
|
|
101
|
+
Other requirements:
|
|
102
|
+
|
|
103
|
+
- **457 MB** of disk for the embedding model, downloaded on first index into `~/.cache/huggingface/`. Shared across projects; separate from the index.
|
|
104
|
+
- On macOS the index goes to `~/.local/share/dev-rag/` (the XDG path), not `~/Library/Application Support`. Set `ZVEC_DB_PATH` if you want the native location.
|
|
105
|
+
|
|
106
|
+
## Install
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pip install multilingual-dev-rag
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The default embedding model (`paraphrase-multilingual-MiniLM-L12-v2`, Apache-2.0) is downloaded from Hugging Face on first use and is not bundled.
|
|
113
|
+
|
|
114
|
+
## Configure
|
|
115
|
+
|
|
116
|
+
Two environment variables:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Required: the repository you want to index.
|
|
120
|
+
export DEV_RAG_ROOT=/path/to/your/repo
|
|
121
|
+
|
|
122
|
+
# Optional: which files count. Built-in: generic (default), k3_mebel.
|
|
123
|
+
# Or a path to your own profile JSON.
|
|
124
|
+
export DEV_RAG_PROFILE=generic
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`DEV_RAG_ROOT` is **not** guessed from the package location, deliberately. An earlier version defaulted to a path near the install directory; when that guess was wrong, globs matched nothing, indexing reported `0 chunks` and exited `0`.
|
|
128
|
+
|
|
129
|
+
Two guards replace that guess. A missing root, or one that is not a directory, raises before anything runs. A root that exists but matches no file under the profile's patterns makes `dev-rag-index` **exit 2** with both values printed — an empty index built "successfully" looks healthy right up until a search returns nothing and also says nothing.
|
|
130
|
+
|
|
131
|
+
### Where the index lives
|
|
132
|
+
|
|
133
|
+
Per user, per corpus — never inside the package:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
Linux/macOS ${XDG_DATA_HOME:-~/.local/share}/dev-rag/<repo>-<hash>/zvec_data
|
|
137
|
+
Windows %LOCALAPPDATA%\dev-rag\<repo>-<hash>\zvec_data
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The `<hash>` is derived from the corpus root's absolute path, so **one installation serves several repositories** without them colliding. Point `DEV_RAG_ROOT` somewhere else and you get a separate index, not an overwritten one — otherwise a search would answer confidently from the wrong corpus.
|
|
141
|
+
|
|
142
|
+
Set `ZVEC_DB_PATH` to override the location entirely.
|
|
143
|
+
|
|
144
|
+
The index is derived data: it holds chunks of whatever you indexed, it is rebuilt by `dev-rag-index`, and it does not belong in version control.
|
|
145
|
+
|
|
146
|
+
## Use
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Index the whole corpus
|
|
150
|
+
dev-rag-index --category all --force
|
|
151
|
+
|
|
152
|
+
# Index one collection
|
|
153
|
+
dev-rag-index --category docs --force
|
|
154
|
+
|
|
155
|
+
# Search from the shell
|
|
156
|
+
dev-rag-search "ферма воркеров" --collection docs
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
> **The first run is slower than the rest.** The embedding model is not bundled:
|
|
160
|
+
> `sentence-transformers` fetches it from Hugging Face on first use — 457 MB into
|
|
161
|
+
> `~/.cache/huggingface/hub/` (on Windows, `C:\Users\<you>\.cache\huggingface\hub\`).
|
|
162
|
+
> That is **not** where the index lives: the model is shared across projects, the
|
|
163
|
+
> index is per corpus. Later runs load it from cache.
|
|
164
|
+
>
|
|
165
|
+
> For an offline environment, copy the cache from a machine where it is already
|
|
166
|
+
> warm, or point `HF_HOME` somewhere prepared.
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
from dev_rag import search
|
|
170
|
+
|
|
171
|
+
for r in search('усталость воркера', collection='docs', n=5):
|
|
172
|
+
print(f"{r['score']:.4f} {r['path']}")
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### As an MCP server
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"mcpServers": {
|
|
180
|
+
"dev-rag": {
|
|
181
|
+
"command": "dev-rag-mcp",
|
|
182
|
+
"env": {
|
|
183
|
+
"DEV_RAG_ROOT": "/absolute/path/to/your/repo",
|
|
184
|
+
"DEV_RAG_PROFILE": "generic"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
MCP servers are child processes of the client, not daemons: `env` is read once at startup. After editing the config, restart the client.
|
|
192
|
+
|
|
193
|
+
## Profiles
|
|
194
|
+
|
|
195
|
+
A profile says which files belong to which collection. `generic` indexes markdown and Python anywhere; `k3_mebel` is a worked example for a CAD codebase with `.mac` macros.
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"name": "my_project",
|
|
200
|
+
"collections": { "docs": "my_docs", "code": "my_code", "plans": "my_plans" },
|
|
201
|
+
"index_patterns": {
|
|
202
|
+
"docs": ["docs/**/*.md"],
|
|
203
|
+
"code": ["src/**/*.py"],
|
|
204
|
+
"plans": ["rfcs/*.md"]
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
export DEV_RAG_PROFILE=/path/to/my_project.json
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Backends
|
|
214
|
+
|
|
215
|
+
| Backend | Model | Servers needed |
|
|
216
|
+
| --- | --- | --- |
|
|
217
|
+
| **zvec** (default) | `paraphrase-multilingual-MiniLM-L12-v2` (384d) | none — in-process |
|
|
218
|
+
| qdrant (legacy) | `nomic-embed-text` via Ollama (768d) | Qdrant + Ollama |
|
|
219
|
+
|
|
220
|
+
The Qdrant path predates zvec and is kept only as a fallback: `nomic-embed-text` is English-centric and recalls poorly on Russian. Install it with `pip install multilingual-dev-rag[qdrant]` and set `RAG_BACKEND=qdrant` if you need it.
|
|
221
|
+
|
|
222
|
+
## Known limits
|
|
223
|
+
|
|
224
|
+
- **CJK is not supported.** Chinese and Japanese have no whitespace between words, so the `whitespace` tokenizer swallows a sentence as one token. zvec ships a `jieba` tokenizer for exactly this — it would need a separate field. (Do not reach for `jieba` on Cyrillic: it indexes it, but shreds it into fragments that match everything. Measured on a real corpus, it ranked worse than returning nothing.)
|
|
225
|
+
- **Turkish `İ`/`ı` is not supported.** Caseless matching there is locale-dependent and neither `lower()` nor `casefold()` resolves it.
|
|
226
|
+
- **Indexing is manual.** Incremental indexing (`--changed-only`) is not implemented for the zvec backend; after changing your corpus, re-run a full index.
|
|
227
|
+
- **One writer.** zvec allows many readers but a single writer: do not index while another process holds the collection open for writing.
|
|
228
|
+
|
|
229
|
+
## Origins
|
|
230
|
+
|
|
231
|
+
Originally built for [K3-Мебель](https://k3-mebel.ru/) — a furniture-design CAD — to give semantic and full-text search over a Russian-language codebase and its documentation. That is where the non-ASCII FTS problem surfaced, and why the fix is measured against a real corpus rather than a toy example.
|
|
232
|
+
|
|
233
|
+
The `k3_mebel` profile is that original corpus, kept as a worked example of a hand-tuned profile: Python prototypes, `.mac` macros, API reference and plans.
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# multilingual-dev-rag
|
|
2
|
+
|
|
3
|
+
Local-first multilingual RAG for code and technical docs. In-process hybrid retrieval (vector + full-text) with FTS for Cyrillic and other non-ASCII scripts.
|
|
4
|
+
|
|
5
|
+
[Русская версия](README_RU.md) · Apache-2.0
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Why this exists
|
|
10
|
+
|
|
11
|
+
Most local RAG setups pair a multilingual embedding model with a full-text index and call it hybrid search. That works — until your corpus is not in English.
|
|
12
|
+
|
|
13
|
+
The embedded engine this is built on ([zvec](https://github.com/alibaba/zvec)) ships a `standard` tokenizer that **drops non-ASCII tokens entirely** (on Windows and Linux — on macOS, curiously, it does not), and a `lowercase` filter that **only folds ASCII**. The result is not an error. A query for `воркер` returns zero rows, a query for `RabbitMQ` returns rows, and the hybrid quietly degrades to vector-only for half your corpus. Nothing in the logs says so.
|
|
14
|
+
|
|
15
|
+
The platform split is the nastier half of the story. A package that relied on `standard` alone would *appear* to work on a developer's Mac and silently break the moment it shipped to a Linux server — same code, same engine, different tokenizer behaviour per OS. The fix below does not depend on which side of that split you are on: it works everywhere, and is merely redundant where `standard` already handles Cyrillic.
|
|
16
|
+
|
|
17
|
+
## How the fix works
|
|
18
|
+
|
|
19
|
+
Swapping the tokenizer does not save you. The engine ships exactly three, and each breaks differently:
|
|
20
|
+
|
|
21
|
+
| Tokenizer | Cyrillic | Identifiers | Punctuation |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `standard` | **discards it**¹ | splits correctly: `obj_k3_gab3` → `obj`, `k3`, `gab3` | separates correctly |
|
|
24
|
+
| `whitespace` | keeps it | **never splits** | **glues**: `RabbitMQ.` is one token |
|
|
25
|
+
| `jieba` | **shreds it** | splits | separates |
|
|
26
|
+
|
|
27
|
+
¹ On Windows and Linux. On macOS, `standard` *does* match Cyrillic — the only platform of the three where it does (verified across the CI matrix on zvec 0.5.1). The `text_fts` workaround below is therefore redundant on macOS but harmless: its lanes never double-count because Latin is excluded from `text_fts`.
|
|
28
|
+
|
|
29
|
+
`jieba` looks like the answer right up until you measure it at scale: 7 of 9 correct on a five-document probe, pure noise on a real 837-chunk corpus — a query for the exact title word of one document returned three unrelated ones, a different wrong answer per letter case. Worse than `standard`, which at least stayed honestly silent.
|
|
30
|
+
|
|
31
|
+
Hence the design: **do not pick the best tokenizer — use two**, each for what it is good at. The index carries two fields, and every query goes only to the field that can answer it:
|
|
32
|
+
|
|
33
|
+
| Field | Content | Tokenizer | Answers |
|
|
34
|
+
| --- | --- | --- | --- |
|
|
35
|
+
| `text` | original, verbatim | `standard` | ASCII words and identifiers — `obj_k3_gab3` is findable as `obj`, `k3`, `gab3` |
|
|
36
|
+
| `text_fts` | non-ASCII tokens only, casefolded, punctuation stripped | `whitespace` | Cyrillic, Greek, accented Latin, Arabic — in any letter case |
|
|
37
|
+
|
|
38
|
+
`text` stays byte-for-byte the original: it is what search returns to you. `text_fts` is derived and internal.
|
|
39
|
+
|
|
40
|
+
Latin is deliberately **excluded** from `text_fts`. If both fields matched `RabbitMQ`, a document containing it would score twice in the Reciprocal Rank Fusion and outrank documents that match the query's Russian half. Keeping the two lanes disjoint keeps the fusion honest.
|
|
41
|
+
|
|
42
|
+
Case folding happens in Python, not in the engine: `casefold()` handles `ß`/`SS` and Greek final sigma, which the engine's ASCII-only `lowercase` filter does not.
|
|
43
|
+
|
|
44
|
+
## What you get
|
|
45
|
+
|
|
46
|
+
- **Hybrid retrieval** — vector + full-text, fused with Reciprocal Rank Fusion.
|
|
47
|
+
- **FTS that survives non-ASCII** — verified end-to-end on Russian, German, Greek, French, Arabic.
|
|
48
|
+
- **No servers** — zvec runs in your process. No Qdrant, no Ollama, no Docker.
|
|
49
|
+
- **Profiles** — describe your corpus in JSON; the package stays generic.
|
|
50
|
+
- **MCP server** — exposes `rag_search` to Claude Code and other MCP clients.
|
|
51
|
+
|
|
52
|
+
## Requirements
|
|
53
|
+
|
|
54
|
+
**Python 3.10–3.14, 64-bit.** Everything else follows from zvec's wheels — it ships **no sdist**, so if there is no wheel for your platform there is no fallback to building from source.
|
|
55
|
+
|
|
56
|
+
| Platform | Wheel | Status |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| Windows x86_64 | `win_amd64` | **tested** — this is where it was built |
|
|
59
|
+
| Linux x86_64 / aarch64 | `manylinux_2_28` | **tested** — CI green (Python 3.10–3.13) |
|
|
60
|
+
| macOS Apple Silicon (11+) | `macosx_11_0_arm64` | **tested** — CI green (Python 3.10–3.13) |
|
|
61
|
+
| macOS Intel | — | **will not install** |
|
|
62
|
+
| Any 32-bit Python | — | **will not install** |
|
|
63
|
+
|
|
64
|
+
All three wheel-bearing platforms run the full suite in CI, including the seven integration tests that hit the live zvec engine.
|
|
65
|
+
|
|
66
|
+
On a platform without a wheel, `pip install` fails with `from versions: none`. That message means *wrong platform*, not *missing package* — no amount of build tooling will help.
|
|
67
|
+
|
|
68
|
+
Other requirements:
|
|
69
|
+
|
|
70
|
+
- **457 MB** of disk for the embedding model, downloaded on first index into `~/.cache/huggingface/`. Shared across projects; separate from the index.
|
|
71
|
+
- On macOS the index goes to `~/.local/share/dev-rag/` (the XDG path), not `~/Library/Application Support`. Set `ZVEC_DB_PATH` if you want the native location.
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install multilingual-dev-rag
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The default embedding model (`paraphrase-multilingual-MiniLM-L12-v2`, Apache-2.0) is downloaded from Hugging Face on first use and is not bundled.
|
|
80
|
+
|
|
81
|
+
## Configure
|
|
82
|
+
|
|
83
|
+
Two environment variables:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Required: the repository you want to index.
|
|
87
|
+
export DEV_RAG_ROOT=/path/to/your/repo
|
|
88
|
+
|
|
89
|
+
# Optional: which files count. Built-in: generic (default), k3_mebel.
|
|
90
|
+
# Or a path to your own profile JSON.
|
|
91
|
+
export DEV_RAG_PROFILE=generic
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`DEV_RAG_ROOT` is **not** guessed from the package location, deliberately. An earlier version defaulted to a path near the install directory; when that guess was wrong, globs matched nothing, indexing reported `0 chunks` and exited `0`.
|
|
95
|
+
|
|
96
|
+
Two guards replace that guess. A missing root, or one that is not a directory, raises before anything runs. A root that exists but matches no file under the profile's patterns makes `dev-rag-index` **exit 2** with both values printed — an empty index built "successfully" looks healthy right up until a search returns nothing and also says nothing.
|
|
97
|
+
|
|
98
|
+
### Where the index lives
|
|
99
|
+
|
|
100
|
+
Per user, per corpus — never inside the package:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
Linux/macOS ${XDG_DATA_HOME:-~/.local/share}/dev-rag/<repo>-<hash>/zvec_data
|
|
104
|
+
Windows %LOCALAPPDATA%\dev-rag\<repo>-<hash>\zvec_data
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The `<hash>` is derived from the corpus root's absolute path, so **one installation serves several repositories** without them colliding. Point `DEV_RAG_ROOT` somewhere else and you get a separate index, not an overwritten one — otherwise a search would answer confidently from the wrong corpus.
|
|
108
|
+
|
|
109
|
+
Set `ZVEC_DB_PATH` to override the location entirely.
|
|
110
|
+
|
|
111
|
+
The index is derived data: it holds chunks of whatever you indexed, it is rebuilt by `dev-rag-index`, and it does not belong in version control.
|
|
112
|
+
|
|
113
|
+
## Use
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Index the whole corpus
|
|
117
|
+
dev-rag-index --category all --force
|
|
118
|
+
|
|
119
|
+
# Index one collection
|
|
120
|
+
dev-rag-index --category docs --force
|
|
121
|
+
|
|
122
|
+
# Search from the shell
|
|
123
|
+
dev-rag-search "ферма воркеров" --collection docs
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
> **The first run is slower than the rest.** The embedding model is not bundled:
|
|
127
|
+
> `sentence-transformers` fetches it from Hugging Face on first use — 457 MB into
|
|
128
|
+
> `~/.cache/huggingface/hub/` (on Windows, `C:\Users\<you>\.cache\huggingface\hub\`).
|
|
129
|
+
> That is **not** where the index lives: the model is shared across projects, the
|
|
130
|
+
> index is per corpus. Later runs load it from cache.
|
|
131
|
+
>
|
|
132
|
+
> For an offline environment, copy the cache from a machine where it is already
|
|
133
|
+
> warm, or point `HF_HOME` somewhere prepared.
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from dev_rag import search
|
|
137
|
+
|
|
138
|
+
for r in search('усталость воркера', collection='docs', n=5):
|
|
139
|
+
print(f"{r['score']:.4f} {r['path']}")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### As an MCP server
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"mcpServers": {
|
|
147
|
+
"dev-rag": {
|
|
148
|
+
"command": "dev-rag-mcp",
|
|
149
|
+
"env": {
|
|
150
|
+
"DEV_RAG_ROOT": "/absolute/path/to/your/repo",
|
|
151
|
+
"DEV_RAG_PROFILE": "generic"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
MCP servers are child processes of the client, not daemons: `env` is read once at startup. After editing the config, restart the client.
|
|
159
|
+
|
|
160
|
+
## Profiles
|
|
161
|
+
|
|
162
|
+
A profile says which files belong to which collection. `generic` indexes markdown and Python anywhere; `k3_mebel` is a worked example for a CAD codebase with `.mac` macros.
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"name": "my_project",
|
|
167
|
+
"collections": { "docs": "my_docs", "code": "my_code", "plans": "my_plans" },
|
|
168
|
+
"index_patterns": {
|
|
169
|
+
"docs": ["docs/**/*.md"],
|
|
170
|
+
"code": ["src/**/*.py"],
|
|
171
|
+
"plans": ["rfcs/*.md"]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
export DEV_RAG_PROFILE=/path/to/my_project.json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Backends
|
|
181
|
+
|
|
182
|
+
| Backend | Model | Servers needed |
|
|
183
|
+
| --- | --- | --- |
|
|
184
|
+
| **zvec** (default) | `paraphrase-multilingual-MiniLM-L12-v2` (384d) | none — in-process |
|
|
185
|
+
| qdrant (legacy) | `nomic-embed-text` via Ollama (768d) | Qdrant + Ollama |
|
|
186
|
+
|
|
187
|
+
The Qdrant path predates zvec and is kept only as a fallback: `nomic-embed-text` is English-centric and recalls poorly on Russian. Install it with `pip install multilingual-dev-rag[qdrant]` and set `RAG_BACKEND=qdrant` if you need it.
|
|
188
|
+
|
|
189
|
+
## Known limits
|
|
190
|
+
|
|
191
|
+
- **CJK is not supported.** Chinese and Japanese have no whitespace between words, so the `whitespace` tokenizer swallows a sentence as one token. zvec ships a `jieba` tokenizer for exactly this — it would need a separate field. (Do not reach for `jieba` on Cyrillic: it indexes it, but shreds it into fragments that match everything. Measured on a real corpus, it ranked worse than returning nothing.)
|
|
192
|
+
- **Turkish `İ`/`ı` is not supported.** Caseless matching there is locale-dependent and neither `lower()` nor `casefold()` resolves it.
|
|
193
|
+
- **Indexing is manual.** Incremental indexing (`--changed-only`) is not implemented for the zvec backend; after changing your corpus, re-run a full index.
|
|
194
|
+
- **One writer.** zvec allows many readers but a single writer: do not index while another process holds the collection open for writing.
|
|
195
|
+
|
|
196
|
+
## Origins
|
|
197
|
+
|
|
198
|
+
Originally built for [K3-Мебель](https://k3-mebel.ru/) — a furniture-design CAD — to give semantic and full-text search over a Russian-language codebase and its documentation. That is where the non-ASCII FTS problem surfaced, and why the fix is measured against a real corpus rather than a toy example.
|
|
199
|
+
|
|
200
|
+
The `k3_mebel` profile is that original corpus, kept as a worked example of a hand-tuned profile: Python prototypes, `.mac` macros, API reference and plans.
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
Apache-2.0. See [LICENSE](LICENSE).
|