simlar 1.0.0__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.
Files changed (43) hide show
  1. simlar-1.0.0/LICENSE +182 -0
  2. simlar-1.0.0/NOTICE +21 -0
  3. simlar-1.0.0/PKG-INFO +241 -0
  4. simlar-1.0.0/README.md +210 -0
  5. simlar-1.0.0/pyproject.toml +110 -0
  6. simlar-1.0.0/setup.cfg +4 -0
  7. simlar-1.0.0/src/simlar/__init__.py +24 -0
  8. simlar-1.0.0/src/simlar/contracts.py +181 -0
  9. simlar-1.0.0/src/simlar/fusion/__init__.py +3 -0
  10. simlar-1.0.0/src/simlar/fusion/_rrf.pyi +7 -0
  11. simlar-1.0.0/src/simlar/fusion/rrf.py +3 -0
  12. simlar-1.0.0/src/simlar/indexes/__init__.py +7 -0
  13. simlar-1.0.0/src/simlar/indexes/_helix.pyi +82 -0
  14. simlar-1.0.0/src/simlar/indexes/_relevance.pyi +46 -0
  15. simlar-1.0.0/src/simlar/indexes/_simlar.pyi +54 -0
  16. simlar-1.0.0/src/simlar/indexes/_streaming.pyi +59 -0
  17. simlar-1.0.0/src/simlar/indexes/helix_index.py +126 -0
  18. simlar-1.0.0/src/simlar/indexes/lookup_index.py +78 -0
  19. simlar-1.0.0/src/simlar/indexes/registry.py +55 -0
  20. simlar-1.0.0/src/simlar/indexes/relevance_index.py +88 -0
  21. simlar-1.0.0/src/simlar/indexes/simlar_engine.py +113 -0
  22. simlar-1.0.0/src/simlar/indexes/streaming_index.py +91 -0
  23. simlar-1.0.0/src/simlar/integrations/__init__.py +0 -0
  24. simlar-1.0.0/src/simlar/integrations/haystack/simlar_document_store.py +401 -0
  25. simlar-1.0.0/src/simlar/integrations/haystack/simlar_retriever.py +64 -0
  26. simlar-1.0.0/src/simlar/integrations/langchain/langchain_retriever.py +49 -0
  27. simlar-1.0.0/src/simlar/integrations/langchain/simlar_vector_store.py +268 -0
  28. simlar-1.0.0/src/simlar/integrations/llama_index/simlar_retriever.py +186 -0
  29. simlar-1.0.0/src/simlar/integrations/llama_index/simlar_vector_store.py +248 -0
  30. simlar-1.0.0/src/simlar/persistence.py +5 -0
  31. simlar-1.0.0/src/simlar/py.typed +0 -0
  32. simlar-1.0.0/src/simlar.egg-info/PKG-INFO +241 -0
  33. simlar-1.0.0/src/simlar.egg-info/SOURCES.txt +41 -0
  34. simlar-1.0.0/src/simlar.egg-info/dependency_links.txt +1 -0
  35. simlar-1.0.0/src/simlar.egg-info/requires.txt +16 -0
  36. simlar-1.0.0/src/simlar.egg-info/top_level.txt +1 -0
  37. simlar-1.0.0/tests/test_contracts.py +23 -0
  38. simlar-1.0.0/tests/test_helix_index.py +71 -0
  39. simlar-1.0.0/tests/test_lookup_index.py +76 -0
  40. simlar-1.0.0/tests/test_persistence.py +43 -0
  41. simlar-1.0.0/tests/test_registry.py +76 -0
  42. simlar-1.0.0/tests/test_relevance_index.py +78 -0
  43. simlar-1.0.0/tests/test_simlar_engine.py +101 -0
simlar-1.0.0/LICENSE ADDED
@@ -0,0 +1,182 @@
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 made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and incorporated
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any Contribution
81
+ incorporated within the Work constitutes direct or contributory patent
82
+ infringement, then any patent licenses granted to You under this License
83
+ for that Work shall terminate as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative Works
91
+ a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works that
97
+ You distribute, all copyright, patent, trademark, and attribution
98
+ notices from the Source form of the Work, excluding those notices
99
+ that do not pertain to any part of the Derivative Works; and
100
+
101
+ (d) If the Work includes a "NOTICE" text file, You must include a
102
+ readable copy of the attribution notices contained within such
103
+ NOTICE file, in at least one of the following places: within a
104
+ NOTICE text file distributed as part of the Derivative Works;
105
+ within the Source form or documentation, if provided along with
106
+ the Derivative Works; or, within a display generated by the
107
+ Derivative Works, if and wherever such third-party notices
108
+ normally appear. The contents of the NOTICE file are for
109
+ informational purposes only and do not modify the License. You
110
+ may add Your own attribution notices within Derivative Works that
111
+ You distribute, alongside or as an addendum to the NOTICE text
112
+ from the Work, provided that such additional attribution notices
113
+ cannot be construed as modifying the License.
114
+
115
+ You may add Your own license statement for Your modifications and
116
+ may provide additional grant of rights to use, copy, modify, merge,
117
+ publish, distribute, sublicense, and/or sell copies of the
118
+ Contribution, either on an original basis or as part of Derivative
119
+ Works, and to sublicense such rights to third parties under the terms
120
+ of this License.
121
+
122
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
123
+ any Contribution intentionally submitted for inclusion in the Work
124
+ by You to the Licensor shall be under the terms and conditions of
125
+ this License, without any additional terms or conditions. Notwithstanding
126
+ the above, nothing herein shall supersede or modify the terms of any
127
+ separate license agreement you may have executed with Licensor regarding
128
+ such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade
131
+ names, trademarks, service marks, or product names of the Licensor,
132
+ except as required for reasonable and customary use in describing the
133
+ origin of the Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or
136
+ agreed to in writing, Licensor provides the Work (and each
137
+ Contributor provides its Contributions) on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
139
+ implied, including, without limitation, any warranties or conditions
140
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
141
+ PARTICULAR PURPOSE. You are solely responsible for determining the
142
+ appropriateness of using or redistributing the Work and assume any
143
+ risks associated with Your exercise of permissions under this License.
144
+
145
+ 8. Limitation of Liability. In no event and under no legal theory,
146
+ whether in tort (including negligence), contract, or otherwise,
147
+ unless required by applicable law (such as deliberate and grossly
148
+ negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special,
150
+ incidental, or exemplary damages of any character arising as a
151
+ result of this License or out of the use or inability to use the
152
+ Work (including but not limited to damages for loss of goodwill,
153
+ work stoppage, computer failure or malfunction, or all other
154
+ commercial damages or losses), even if such Contributor has been
155
+ advised of the possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Additional Liability. While redistributing
158
+ the Work or Derivative Works thereof, You may choose to offer,
159
+ and charge a fee for, acceptance of support, warranty, indemnity,
160
+ or other liability obligations and/or rights consistent with this
161
+ License. However, in accepting such obligations, You may act only
162
+ on Your own behalf and on Your sole responsibility, not on behalf
163
+ of any other Contributor, and only if You agree to indemnify,
164
+ defend, and hold each Contributor harmless for any liability
165
+ incurred by, or claims asserted against, such Contributor by reason
166
+ of your accepting any such warranty or additional liability.
167
+
168
+ END OF TERMS AND CONDITIONS
169
+
170
+ Copyright 2026 TekDatum
171
+
172
+ Licensed under the Apache License, Version 2.0 (the "License");
173
+ you may not use this file except in compliance with the License.
174
+ You may obtain a copy of the License at
175
+
176
+ http://www.apache.org/licenses/LICENSE-2.0
177
+
178
+ Unless required by applicable law or agreed to in writing, software
179
+ distributed under the License is distributed on an "AS IS" BASIS,
180
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
181
+ See the License for the specific language governing permissions and
182
+ limitations under the License.
simlar-1.0.0/NOTICE ADDED
@@ -0,0 +1,21 @@
1
+ sim_LAR — Open Wrapper and SDK
2
+ Copyright 2024-2026 TekDatum
3
+
4
+ This product includes software developed by TekDatum and its contributors.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
+ use this file except in compliance with the License. You may obtain a copy of
8
+ the License at:
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ ----------------------------------------------------------------------
13
+ Third-party components
14
+ ----------------------------------------------------------------------
15
+
16
+ This software depends on or redistributes the following third-party
17
+ components, each under its own license. Dependencies that pip installs
18
+ separately generally do not require listing here; bundled or vendored
19
+ code does. Verify with a license scan before each release.
20
+
21
+ - NumPy (BSD-3-Clause) — https://numpy.org
simlar-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.4
2
+ Name: simlar
3
+ Version: 1.0.0
4
+ Summary: High-performance similarity search — open-source Python wrapper
5
+ Author-email: TekDatum <hello@tekdatum.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://tekdatum.com/products/
8
+ Project-URL: Source, https://github.com/tekdatum/simlar
9
+ Project-URL: Documentation, https://github.com/tekdatum/simlar/blob/main/docs/index.md
10
+ Project-URL: Issue Tracker, https://github.com/tekdatum/simlar/issues
11
+ Project-URL: Changelog, https://github.com/tekdatum/simlar/blob/main/CHANGELOG.md
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Development Status :: 4 - Beta
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ License-File: NOTICE
18
+ Requires-Dist: numpy<2.5,>=1.24
19
+ Provides-Extra: langchain
20
+ Requires-Dist: langchain-core>=0.2; extra == "langchain"
21
+ Provides-Extra: haystack
22
+ Requires-Dist: haystack-ai>=2.0; extra == "haystack"
23
+ Provides-Extra: llama-index
24
+ Requires-Dist: llama-index-core>=0.10; extra == "llama-index"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: numpy<2.5,>=1.24; extra == "dev"
28
+ Requires-Dist: ruff>=0.4; extra == "dev"
29
+ Requires-Dist: mypy>=1.10; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # sim_LAR
33
+
34
+ Python search library combining keyword, semantic, and hybrid search into a single ranked result list — with first-class LangChain, LlamaIndex, and Haystack support.
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ The open wrapper and the engine is on public PyPI:
40
+
41
+ ```bash
42
+ pip install simlar
43
+ ```
44
+
45
+
46
+ ```bash
47
+ pip install simlar-engine
48
+ ```
49
+
50
+ ## Quick start
51
+
52
+ ### Keyword search
53
+
54
+ No embeddings required. Index your text and search.
55
+
56
+ ```python
57
+ from simlar import RelevanceIndex
58
+
59
+ corpus = [
60
+ "cancer treatment with immunotherapy",
61
+ "machine learning transformers",
62
+ "climate change renewable energy",
63
+ ]
64
+ ids = [f"doc_{i}" for i in range(len(corpus))]
65
+
66
+ idx = RelevanceIndex()
67
+ idx.add(ids=ids, texts=corpus)
68
+
69
+ results = idx.search("immunotherapy clinical trial", k=1)
70
+ for r in results:
71
+ print(r.rank, r.id, f"{r.score:.4f}")
72
+ ```
73
+
74
+ ### Semantic search
75
+
76
+ Provide pre-computed embedding vectors alongside your document IDs.
77
+
78
+ ```python
79
+ import numpy as np
80
+ from simlar import SimlarEngine
81
+
82
+ # vectors: (n_docs, dim) float32, ideally L2-normalised
83
+ vectors = np.load("corpus_embeddings.npy")
84
+ ids = [f"doc_{i}" for i in range(len(vectors))]
85
+
86
+ idx = SimlarEngine()
87
+ idx.add(ids=ids, vectors=vectors)
88
+
89
+ query_vec = np.load("query_embedding.npy") # shape (1, dim)
90
+ results = idx.search(query_vec, k=5)
91
+ for r in results:
92
+ print(r.rank, r.id, f"{r.score:.4f}")
93
+ ```
94
+
95
+ ### Hybrid search
96
+
97
+ Combine keyword relevance and semantic similarity into one ranked list.
98
+
99
+ ```python
100
+ import numpy as np
101
+ from simlar import HelixIndex, RelevanceIndex, SimlarEngine, ReciprocalRankFusion
102
+
103
+ corpus = ["cancer treatment with immunotherapy", "machine learning transformers", ...]
104
+ ids = [f"doc_{i}" for i in range(len(corpus))]
105
+ vectors = np.load("corpus_embeddings.npy") # shape (n, dim)
106
+
107
+ index = HelixIndex(
108
+ text_index=RelevanceIndex(),
109
+ vector_index=SimlarEngine(),
110
+ fusion=ReciprocalRankFusion(),
111
+ top_k=20,
112
+ )
113
+ index.add(ids=ids, texts=corpus, vectors=vectors)
114
+
115
+ query_vec = np.load("query_embedding.npy")
116
+ results = index.search(
117
+ query_text="immunotherapy clinical trial",
118
+ query_vector=query_vec,
119
+ k=10,
120
+ )
121
+ for r in results:
122
+ print(r.rank, r.id, f"{r.score:.4f}")
123
+ ```
124
+
125
+ ## Framework integrations
126
+
127
+ sim_LAR works as a drop-in component in:
128
+
129
+ - **LangChain** — [docs/examples/04_langchain_integration.ipynb](docs/examples/04_langchain_integration.ipynb)
130
+ - **LlamaIndex** — [docs/examples/06_llamaindex_integration.ipynb](docs/examples/06_llamaindex_integration.ipynb)
131
+ - **Haystack** — [docs/examples/05_haystack_integration.ipynb](docs/examples/05_haystack_integration.ipynb)
132
+
133
+ ## Index types at a glance
134
+
135
+ | Index | Best for |
136
+ |-------|----------|
137
+ | `RelevanceIndex` | Keyword search over text — no embeddings required |
138
+ | `SimlarEngine` | Semantic search over pre-computed embedding vectors |
139
+ | `HelixIndex` | Both signals combined; corpus fits in memory |
140
+ | `StreamingHybridIndex` | Both signals; very large corpora added in batches |
141
+
142
+ ## Producing embeddings
143
+
144
+ sim_LAR is model-agnostic — it accepts any `(n, dim)` float32 NumPy array. Use whichever embedding library fits your project. Example with [sentence-transformers](https://sbert.net/):
145
+
146
+ ```bash
147
+ pip install sentence-transformers
148
+ ```
149
+
150
+ ```python
151
+ from sentence_transformers import SentenceTransformer
152
+
153
+ model = SentenceTransformer("WhereIsAI/UAE-Large-V1")
154
+
155
+ corpus_vectors = model.encode(corpus, normalize_embeddings=True) # (n, dim) float32
156
+ query_vec = model.encode(["my search query"], normalize_embeddings=True) # (1, dim)
157
+ ```
158
+
159
+ ## Saving and loading indexes
160
+
161
+ Every index type shares the same save/load interface.
162
+
163
+ ```python
164
+ # Save
165
+ index.save("/path/to/dir")
166
+
167
+ # Load (type is detected automatically)
168
+ from simlar import load_from_directory
169
+ index = load_from_directory("/path/to/dir")
170
+ ```
171
+
172
+ ## Extending sim_LAR
173
+
174
+ Register a custom index class to make it compatible with `load_from_directory()` and the rest of the library:
175
+
176
+ ```python
177
+ from simlar import VectorIndex, register
178
+
179
+ @register("my_index")
180
+ class MyIndex(VectorIndex):
181
+ ...
182
+ ```
183
+
184
+ ## Contributing
185
+
186
+ Contributions to simlar are welcome. Because this is a dual-licensed open-core project, we require all contributors to agree to a [Contributor License Agreement (CLA)](./CONTRIBUTING.md) before we can merge. This lets us keep the open-core model viable and continue offering simlar under Apache 2.0. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
187
+
188
+ We do not accept contributions to the proprietary engine.
189
+
190
+ ## Trademarks
191
+
192
+ "sim_LAR", "TekDatum", and associated logos are trademarks of TekDatum. The Apache 2.0 license for the open code does **not** grant rights to use these marks. You may build on and redistribute the open code, but you may not use our names or logos in a way that implies endorsement or that misrepresents the origin of a fork. See [TRADEMARKS.md](./TRADEMARKS.md).
193
+
194
+ ## Documentation
195
+
196
+ | Document | Description |
197
+ |----------|-------------|
198
+ | [Concepts](docs/concepts.md) | Architecture and design decisions |
199
+ | [API Reference](docs/concepts.md) | Full public API |
200
+ | [Examples](docs/examples/) | Runnable scripts |
201
+
202
+ ## License
203
+
204
+ - The contents of this repository are licensed under the **Apache License, Version 2.0** — see [LICENSE](./LICENSE).
205
+ - The proprietary `simlar-engine` binary is licensed under a **Commercial EULA** — see [EULA.md](./EULA.md).
206
+ - Third-party components and their licenses are listed in [NOTICE](./NOTICE).
207
+
208
+ ## License Boundary
209
+
210
+ This project uses an **open-core** model. It has two layers with **different licenses**:
211
+
212
+ | Layer | Package | License | Where it lives |
213
+ |---|---|---|---|
214
+ | **Open wrapper + SDK** | `simlar` | Apache License 2.0 | This repo · public PyPI |
215
+ | **Proprietary engine** | `simlar-engine` | Commercial EULA (closed binary) | public PyPI |
216
+
217
+ **What this means in practice:**
218
+
219
+ - The code **in this repository** is free and open under Apache 2.0. You can read it, fork it, modify it, and build on it, including commercially, subject to the Apache 2.0 terms.
220
+ - The wrapper depends on a **separate, proprietary binary package** (`simlar-engine`) that contains TekDatum's core IP. That binary is **not** open source. Installing and using it requires accepting the [Commercial EULA](./EULA.md) and, for production use, a license from TekDatum.
221
+ - Calling the proprietary engine through this open SDK does **not** make your own code subject to the EULA — your application code is yours. The EULA governs only the proprietary binary itself.
222
+
223
+ If you only want to read or contribute to the open layer, you never need a license. If you want to **run** the full product, you need the engine.
224
+
225
+ ## What's open and what's not
226
+
227
+ **Open (Apache 2.0, in this repo):**
228
+ - The SDK and public API surface (`RelevanceIndex`, `HelixIndex`, `StreamingHybridIndex`, `ReciprocalRankFusion`)
229
+ - Framework adapters (LangChain / LlamaIndex / Haystack)
230
+ - The `load_from_directory()` loader and `@register` extension API
231
+ - Configuration schema, type stubs, examples, and docs
232
+
233
+ **Proprietary (Commercial EULA, separate binary):**
234
+ - The core `SimlarEngine` vector search implementation
235
+ - Compiled ranking and retrieval algorithms
236
+
237
+ We keep this boundary deliberate and documented so you always know which terms apply to which code.
238
+
239
+ ---
240
+
241
+ © 2026 TekDatum.
simlar-1.0.0/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # sim_LAR
2
+
3
+ Python search library combining keyword, semantic, and hybrid search into a single ranked result list — with first-class LangChain, LlamaIndex, and Haystack support.
4
+ ---
5
+
6
+ ## Installation
7
+
8
+ The open wrapper and the engine is on public PyPI:
9
+
10
+ ```bash
11
+ pip install simlar
12
+ ```
13
+
14
+
15
+ ```bash
16
+ pip install simlar-engine
17
+ ```
18
+
19
+ ## Quick start
20
+
21
+ ### Keyword search
22
+
23
+ No embeddings required. Index your text and search.
24
+
25
+ ```python
26
+ from simlar import RelevanceIndex
27
+
28
+ corpus = [
29
+ "cancer treatment with immunotherapy",
30
+ "machine learning transformers",
31
+ "climate change renewable energy",
32
+ ]
33
+ ids = [f"doc_{i}" for i in range(len(corpus))]
34
+
35
+ idx = RelevanceIndex()
36
+ idx.add(ids=ids, texts=corpus)
37
+
38
+ results = idx.search("immunotherapy clinical trial", k=1)
39
+ for r in results:
40
+ print(r.rank, r.id, f"{r.score:.4f}")
41
+ ```
42
+
43
+ ### Semantic search
44
+
45
+ Provide pre-computed embedding vectors alongside your document IDs.
46
+
47
+ ```python
48
+ import numpy as np
49
+ from simlar import SimlarEngine
50
+
51
+ # vectors: (n_docs, dim) float32, ideally L2-normalised
52
+ vectors = np.load("corpus_embeddings.npy")
53
+ ids = [f"doc_{i}" for i in range(len(vectors))]
54
+
55
+ idx = SimlarEngine()
56
+ idx.add(ids=ids, vectors=vectors)
57
+
58
+ query_vec = np.load("query_embedding.npy") # shape (1, dim)
59
+ results = idx.search(query_vec, k=5)
60
+ for r in results:
61
+ print(r.rank, r.id, f"{r.score:.4f}")
62
+ ```
63
+
64
+ ### Hybrid search
65
+
66
+ Combine keyword relevance and semantic similarity into one ranked list.
67
+
68
+ ```python
69
+ import numpy as np
70
+ from simlar import HelixIndex, RelevanceIndex, SimlarEngine, ReciprocalRankFusion
71
+
72
+ corpus = ["cancer treatment with immunotherapy", "machine learning transformers", ...]
73
+ ids = [f"doc_{i}" for i in range(len(corpus))]
74
+ vectors = np.load("corpus_embeddings.npy") # shape (n, dim)
75
+
76
+ index = HelixIndex(
77
+ text_index=RelevanceIndex(),
78
+ vector_index=SimlarEngine(),
79
+ fusion=ReciprocalRankFusion(),
80
+ top_k=20,
81
+ )
82
+ index.add(ids=ids, texts=corpus, vectors=vectors)
83
+
84
+ query_vec = np.load("query_embedding.npy")
85
+ results = index.search(
86
+ query_text="immunotherapy clinical trial",
87
+ query_vector=query_vec,
88
+ k=10,
89
+ )
90
+ for r in results:
91
+ print(r.rank, r.id, f"{r.score:.4f}")
92
+ ```
93
+
94
+ ## Framework integrations
95
+
96
+ sim_LAR works as a drop-in component in:
97
+
98
+ - **LangChain** — [docs/examples/04_langchain_integration.ipynb](docs/examples/04_langchain_integration.ipynb)
99
+ - **LlamaIndex** — [docs/examples/06_llamaindex_integration.ipynb](docs/examples/06_llamaindex_integration.ipynb)
100
+ - **Haystack** — [docs/examples/05_haystack_integration.ipynb](docs/examples/05_haystack_integration.ipynb)
101
+
102
+ ## Index types at a glance
103
+
104
+ | Index | Best for |
105
+ |-------|----------|
106
+ | `RelevanceIndex` | Keyword search over text — no embeddings required |
107
+ | `SimlarEngine` | Semantic search over pre-computed embedding vectors |
108
+ | `HelixIndex` | Both signals combined; corpus fits in memory |
109
+ | `StreamingHybridIndex` | Both signals; very large corpora added in batches |
110
+
111
+ ## Producing embeddings
112
+
113
+ sim_LAR is model-agnostic — it accepts any `(n, dim)` float32 NumPy array. Use whichever embedding library fits your project. Example with [sentence-transformers](https://sbert.net/):
114
+
115
+ ```bash
116
+ pip install sentence-transformers
117
+ ```
118
+
119
+ ```python
120
+ from sentence_transformers import SentenceTransformer
121
+
122
+ model = SentenceTransformer("WhereIsAI/UAE-Large-V1")
123
+
124
+ corpus_vectors = model.encode(corpus, normalize_embeddings=True) # (n, dim) float32
125
+ query_vec = model.encode(["my search query"], normalize_embeddings=True) # (1, dim)
126
+ ```
127
+
128
+ ## Saving and loading indexes
129
+
130
+ Every index type shares the same save/load interface.
131
+
132
+ ```python
133
+ # Save
134
+ index.save("/path/to/dir")
135
+
136
+ # Load (type is detected automatically)
137
+ from simlar import load_from_directory
138
+ index = load_from_directory("/path/to/dir")
139
+ ```
140
+
141
+ ## Extending sim_LAR
142
+
143
+ Register a custom index class to make it compatible with `load_from_directory()` and the rest of the library:
144
+
145
+ ```python
146
+ from simlar import VectorIndex, register
147
+
148
+ @register("my_index")
149
+ class MyIndex(VectorIndex):
150
+ ...
151
+ ```
152
+
153
+ ## Contributing
154
+
155
+ Contributions to simlar are welcome. Because this is a dual-licensed open-core project, we require all contributors to agree to a [Contributor License Agreement (CLA)](./CONTRIBUTING.md) before we can merge. This lets us keep the open-core model viable and continue offering simlar under Apache 2.0. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
156
+
157
+ We do not accept contributions to the proprietary engine.
158
+
159
+ ## Trademarks
160
+
161
+ "sim_LAR", "TekDatum", and associated logos are trademarks of TekDatum. The Apache 2.0 license for the open code does **not** grant rights to use these marks. You may build on and redistribute the open code, but you may not use our names or logos in a way that implies endorsement or that misrepresents the origin of a fork. See [TRADEMARKS.md](./TRADEMARKS.md).
162
+
163
+ ## Documentation
164
+
165
+ | Document | Description |
166
+ |----------|-------------|
167
+ | [Concepts](docs/concepts.md) | Architecture and design decisions |
168
+ | [API Reference](docs/concepts.md) | Full public API |
169
+ | [Examples](docs/examples/) | Runnable scripts |
170
+
171
+ ## License
172
+
173
+ - The contents of this repository are licensed under the **Apache License, Version 2.0** — see [LICENSE](./LICENSE).
174
+ - The proprietary `simlar-engine` binary is licensed under a **Commercial EULA** — see [EULA.md](./EULA.md).
175
+ - Third-party components and their licenses are listed in [NOTICE](./NOTICE).
176
+
177
+ ## License Boundary
178
+
179
+ This project uses an **open-core** model. It has two layers with **different licenses**:
180
+
181
+ | Layer | Package | License | Where it lives |
182
+ |---|---|---|---|
183
+ | **Open wrapper + SDK** | `simlar` | Apache License 2.0 | This repo · public PyPI |
184
+ | **Proprietary engine** | `simlar-engine` | Commercial EULA (closed binary) | public PyPI |
185
+
186
+ **What this means in practice:**
187
+
188
+ - The code **in this repository** is free and open under Apache 2.0. You can read it, fork it, modify it, and build on it, including commercially, subject to the Apache 2.0 terms.
189
+ - The wrapper depends on a **separate, proprietary binary package** (`simlar-engine`) that contains TekDatum's core IP. That binary is **not** open source. Installing and using it requires accepting the [Commercial EULA](./EULA.md) and, for production use, a license from TekDatum.
190
+ - Calling the proprietary engine through this open SDK does **not** make your own code subject to the EULA — your application code is yours. The EULA governs only the proprietary binary itself.
191
+
192
+ If you only want to read or contribute to the open layer, you never need a license. If you want to **run** the full product, you need the engine.
193
+
194
+ ## What's open and what's not
195
+
196
+ **Open (Apache 2.0, in this repo):**
197
+ - The SDK and public API surface (`RelevanceIndex`, `HelixIndex`, `StreamingHybridIndex`, `ReciprocalRankFusion`)
198
+ - Framework adapters (LangChain / LlamaIndex / Haystack)
199
+ - The `load_from_directory()` loader and `@register` extension API
200
+ - Configuration schema, type stubs, examples, and docs
201
+
202
+ **Proprietary (Commercial EULA, separate binary):**
203
+ - The core `SimlarEngine` vector search implementation
204
+ - Compiled ranking and retrieval algorithms
205
+
206
+ We keep this boundary deliberate and documented so you always know which terms apply to which code.
207
+
208
+ ---
209
+
210
+ © 2026 TekDatum.