endee-llamaindex 0.1.3__tar.gz → 0.1.5__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.
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/PKG-INFO +173 -50
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/README.md +167 -48
- endee_llamaindex-0.1.5/endee_llamaindex/base.py +764 -0
- endee_llamaindex-0.1.5/endee_llamaindex/constants.py +70 -0
- endee_llamaindex-0.1.5/endee_llamaindex/utils.py +160 -0
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/endee_llamaindex.egg-info/PKG-INFO +173 -50
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/endee_llamaindex.egg-info/SOURCES.txt +1 -0
- endee_llamaindex-0.1.5/endee_llamaindex.egg-info/requires.txt +6 -0
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/setup.py +10 -3
- endee_llamaindex-0.1.3/endee_llamaindex/base.py +0 -809
- endee_llamaindex-0.1.3/endee_llamaindex/utils.py +0 -740
- endee_llamaindex-0.1.3/endee_llamaindex.egg-info/requires.txt +0 -2
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/endee_llamaindex/__init__.py +0 -0
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/endee_llamaindex.egg-info/dependency_links.txt +0 -0
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/endee_llamaindex.egg-info/top_level.txt +0 -0
- {endee_llamaindex-0.1.3 → endee_llamaindex-0.1.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: endee-llamaindex
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Vector Database for Fast ANN Searches
|
|
5
5
|
Home-page: https://endee.io
|
|
6
6
|
Author: Endee Labs
|
|
@@ -11,13 +11,17 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
Requires-Dist: llama-index>=0.12.34
|
|
14
|
-
Requires-Dist: endee
|
|
14
|
+
Requires-Dist: endee==0.1.9
|
|
15
|
+
Requires-Dist: fastembed>=0.3.0
|
|
16
|
+
Provides-Extra: gpu
|
|
17
|
+
Requires-Dist: fastembed-gpu>=0.3.0; extra == "gpu"
|
|
15
18
|
Dynamic: author
|
|
16
19
|
Dynamic: author-email
|
|
17
20
|
Dynamic: classifier
|
|
18
21
|
Dynamic: description
|
|
19
22
|
Dynamic: description-content-type
|
|
20
23
|
Dynamic: home-page
|
|
24
|
+
Dynamic: provides-extra
|
|
21
25
|
Dynamic: requires-dist
|
|
22
26
|
Dynamic: requires-python
|
|
23
27
|
Dynamic: summary
|
|
@@ -31,18 +35,19 @@ Build powerful RAG applications with Endee vector database and LlamaIndex.
|
|
|
31
35
|
## Table of Contents
|
|
32
36
|
|
|
33
37
|
1. [Installation](#1-installation)
|
|
34
|
-
2. [
|
|
35
|
-
3. [
|
|
36
|
-
4. [
|
|
37
|
-
5. [
|
|
38
|
-
6. [
|
|
39
|
-
7. [
|
|
40
|
-
8. [
|
|
41
|
-
9. [
|
|
42
|
-
10. [Custom Retriever
|
|
43
|
-
11. [
|
|
44
|
-
12. [
|
|
45
|
-
13. [
|
|
38
|
+
2. [Testing locally](#testing-locally)
|
|
39
|
+
3. [Setting up Credentials](#2-setting-up-endee-and-openai-credentials)
|
|
40
|
+
4. [Creating Sample Documents](#3-creating-sample-documents)
|
|
41
|
+
5. [Setting up Endee with LlamaIndex](#4-setting-up-endee-with-llamaindex)
|
|
42
|
+
6. [Creating a Vector Index](#5-creating-a-vector-index-from-documents)
|
|
43
|
+
7. [Basic Retrieval](#6-basic-retrieval-with-query-engine)
|
|
44
|
+
8. [Using Metadata Filters](#7-using-metadata-filters)
|
|
45
|
+
9. [Advanced Filtering](#8-advanced-filtering-with-multiple-conditions)
|
|
46
|
+
10. [Custom Retriever Setup](#9-custom-retriever-setup)
|
|
47
|
+
11. [Custom Retriever with Query Engine](#10-using-a-custom-retriever-with-a-query-engine)
|
|
48
|
+
12. [Direct VectorStore Querying](#11-direct-vectorstore-querying)
|
|
49
|
+
13. [Saving and Loading Indexes](#12-saving-and-loading-indexes)
|
|
50
|
+
14. [Cleanup](#13-cleanup)
|
|
46
51
|
|
|
47
52
|
---
|
|
48
53
|
|
|
@@ -50,12 +55,66 @@ Build powerful RAG applications with Endee vector database and LlamaIndex.
|
|
|
50
55
|
|
|
51
56
|
Get started by installing the required package.
|
|
52
57
|
|
|
58
|
+
### Basic Installation (Dense-only search)
|
|
59
|
+
|
|
53
60
|
```bash
|
|
54
61
|
pip install endee-llamaindex
|
|
55
62
|
```
|
|
56
63
|
|
|
57
64
|
> **Note:** This will automatically install `endee` and `llama-index` as dependencies.
|
|
58
65
|
|
|
66
|
+
### Full Installation (with Hybrid Search support)
|
|
67
|
+
|
|
68
|
+
For hybrid search capabilities (dense + sparse vectors), install with the `hybrid` extra:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install endee-llamaindex[hybrid]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This includes FastEmbed for sparse vector encoding (SPLADE, BM25, etc.).
|
|
75
|
+
|
|
76
|
+
### GPU-Accelerated Hybrid Search
|
|
77
|
+
|
|
78
|
+
For GPU-accelerated sparse encoding:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install endee-llamaindex[hybrid-gpu]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### All Features
|
|
85
|
+
|
|
86
|
+
To install all optional dependencies:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install endee-llamaindex[all]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Installation Options Summary
|
|
93
|
+
|
|
94
|
+
| Installation | Use Case | Includes |
|
|
95
|
+
|--------------|----------|----------|
|
|
96
|
+
| `pip install endee-llamaindex` | Dense vector search only | Core dependencies |
|
|
97
|
+
| `pip install endee-llamaindex[hybrid]` | Dense + sparse hybrid search | + FastEmbed (CPU) |
|
|
98
|
+
| `pip install endee-llamaindex[hybrid-gpu]` | GPU-accelerated hybrid search | + FastEmbed (GPU) |
|
|
99
|
+
| `pip install endee-llamaindex[all]` | All features | All optional deps |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Testing locally
|
|
104
|
+
|
|
105
|
+
From the project root:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
python -m venv env && source env/bin/activate # optional
|
|
109
|
+
pip install -e .
|
|
110
|
+
pip install pytest sentence-transformers huggingface-hub
|
|
111
|
+
export ENDEE_API_TOKEN="your-endee-api-token" # or set in endee_llamaindex/test_cases/setup_class.py
|
|
112
|
+
|
|
113
|
+
cd endee_llamaindex/test_cases && PYTHONPATH=.. python -m pytest . -v
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
See [TESTING.md](TESTING.md) for more options and single-test runs.
|
|
117
|
+
|
|
59
118
|
---
|
|
60
119
|
|
|
61
120
|
## 2. Setting up Endee and OpenAI credentials
|
|
@@ -145,7 +204,7 @@ vector_store = EndeeVectorStore.from_params(
|
|
|
145
204
|
index_name=index_name,
|
|
146
205
|
dimension=dimension,
|
|
147
206
|
space_type="cosine", # Can be "cosine", "l2", or "ip"
|
|
148
|
-
precision="
|
|
207
|
+
precision="float16" # Options: "binary", "float16", "float32", "int16d", "int8d" (default: "float16")
|
|
149
208
|
)
|
|
150
209
|
|
|
151
210
|
# Create storage context with our vector store
|
|
@@ -160,9 +219,37 @@ print(f"Initialized Endee vector store with index: {index_name}")
|
|
|
160
219
|
|-----------|-------------|---------|
|
|
161
220
|
| `space_type` | Distance metric for similarity | `cosine`, `l2`, `ip` |
|
|
162
221
|
| `dimension` | Vector dimension | Must match embedding model |
|
|
163
|
-
| `precision` | Index precision setting | `"
|
|
164
|
-
| `key` | Encryption key for metadata | 256-bit hex key (64 hex characters) |
|
|
222
|
+
| `precision` | Index precision setting | `"binary"`, `"float16"` (default), `"float32"`, `"int16d"`, `"int8d"` |
|
|
165
223
|
| `batch_size` | Vectors per API call | Default: `100` |
|
|
224
|
+
| `hybrid` | Enable hybrid search (dense + sparse) | Default: `False` |
|
|
225
|
+
| `M` | Optional HNSW M parameter (bi-directional links) | Optional (backend default if not specified) |
|
|
226
|
+
| `ef_con` | Optional HNSW ef_construction parameter | Optional (backend default if not specified) |
|
|
227
|
+
|
|
228
|
+
### Hybrid Search and Sparse Models
|
|
229
|
+
|
|
230
|
+
When you enable hybrid search by providing a positive `sparse_dim` and a `model_name`, the vector store automatically computes sparse (bag-of-words‑style) vectors in addition to dense vectors.
|
|
231
|
+
|
|
232
|
+
- **Sparse dimension (`sparse_dim`)**:
|
|
233
|
+
- For the built-in SPLADE models, the recommended `sparse_dim` is **30522** (matching the model vocabulary size).
|
|
234
|
+
- For dense‑only search, omit `sparse_dim` (or set it to `0`).
|
|
235
|
+
- **Supported sparse models (`model_name`)**:
|
|
236
|
+
- `"splade_pp"` → `prithivida/Splade_PP_en_v1` (SPLADE++)
|
|
237
|
+
- `"splade_cocondenser"` → `naver/splade-cocondenser-ensembledistil`
|
|
238
|
+
|
|
239
|
+
Example hybrid configuration:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
vector_store = EndeeVectorStore.from_params(
|
|
243
|
+
api_token=endee_api_token,
|
|
244
|
+
index_name=index_name,
|
|
245
|
+
dimension=dimension, # dense dimension (e.g., 1536 for OpenAI)
|
|
246
|
+
space_type="cosine",
|
|
247
|
+
precision="float16",
|
|
248
|
+
hybrid=True,
|
|
249
|
+
sparse_dim=30522, # sparse dimension for SPLADE models
|
|
250
|
+
model_name="splade_pp", # or "splade_cocondenser"
|
|
251
|
+
)
|
|
252
|
+
```
|
|
166
253
|
|
|
167
254
|
---
|
|
168
255
|
|
|
@@ -239,16 +326,47 @@ print(response)
|
|
|
239
326
|
|
|
240
327
|
### Available Filter Operators
|
|
241
328
|
|
|
242
|
-
| Operator | Description |
|
|
243
|
-
|
|
244
|
-
| `FilterOperator.EQ` | Equal to |
|
|
245
|
-
| `FilterOperator.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
329
|
+
| Operator | Description | Backend Symbol | Example |
|
|
330
|
+
|----------|-------------|----------------|---------|
|
|
331
|
+
| `FilterOperator.EQ` | Equal to | `$eq` | `rating == 5` |
|
|
332
|
+
| `FilterOperator.IN` | In list | `$in` | `category in ["ai", "ml"]` |
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
> **Important Notes:**
|
|
336
|
+
> - Currently, the Endee LlamaIndex integration only supports **EQ** and **IN** metadata filters.
|
|
337
|
+
> - Range-style operators (LT, LTE, GT, GTE) are **not** supported in this adapter.
|
|
338
|
+
|
|
339
|
+
### Filter Examples
|
|
340
|
+
|
|
341
|
+
Here are practical examples showing how to use the supported filter operators:
|
|
342
|
+
|
|
343
|
+
```python
|
|
344
|
+
from llama_index.core.vector_stores.types import MetadataFilters, MetadataFilter, FilterOperator
|
|
345
|
+
|
|
346
|
+
# Example 1: Equal to (EQ)
|
|
347
|
+
# Find documents with rating equal to 5
|
|
348
|
+
rating_filter = MetadataFilter(key="rating", value=5, operator=FilterOperator.EQ)
|
|
349
|
+
filters = MetadataFilters(filters=[rating_filter])
|
|
350
|
+
# Backend: {"rating": {"$eq": 5}}
|
|
351
|
+
|
|
352
|
+
# Example 2: In list (IN)
|
|
353
|
+
# Find documents in AI or ML categories
|
|
354
|
+
category_filter = MetadataFilter(key="category", value=["ai", "ml"], operator=FilterOperator.IN)
|
|
355
|
+
filters = MetadataFilters(filters=[category_filter])
|
|
356
|
+
# Backend: {"category": {"$in": ["ai", "ml"]}}
|
|
357
|
+
|
|
358
|
+
# Example 3: Combined filters (AND logic)
|
|
359
|
+
# Find AI documents with rating equal to 5
|
|
360
|
+
filters = MetadataFilters(filters=[
|
|
361
|
+
MetadataFilter(key="category", value="ai", operator=FilterOperator.EQ),
|
|
362
|
+
MetadataFilter(key="rating", value=5, operator=FilterOperator.EQ)
|
|
363
|
+
])
|
|
364
|
+
# Backend: [{"category": {"$eq": "ai"}}, {"rating": {"$eq": 5}}]
|
|
365
|
+
|
|
366
|
+
# Create a query engine with filters
|
|
367
|
+
filtered_engine = index.as_query_engine(filters=filters)
|
|
368
|
+
response = filtered_engine.query("What is machine learning?")
|
|
369
|
+
```
|
|
252
370
|
|
|
253
371
|
---
|
|
254
372
|
|
|
@@ -439,10 +557,14 @@ Delete the index when you're done to free up resources.
|
|
|
439
557
|
| `api_token` | `str` | Your Endee API token | Required |
|
|
440
558
|
| `index_name` | `str` | Name of the index | Required |
|
|
441
559
|
| `dimension` | `int` | Vector dimension | Required |
|
|
442
|
-
| `space_type` | `str` | Distance metric | `"cosine"` |
|
|
443
|
-
| `precision` | `str` | Index precision
|
|
444
|
-
| `key` | `str` | Encryption key for metadata (256-bit hex) | `None` |
|
|
560
|
+
| `space_type` | `str` | Distance metric (`"cosine"`, `"l2"`, `"ip"`) | `"cosine"` |
|
|
561
|
+
| `precision` | `str` | Index precision (`"binary"`, `"float16"`, `"float32"`, `"int16d"`, `"int8d"`) | `"float16"` |
|
|
445
562
|
| `batch_size` | `int` | Vectors per API call | `100` |
|
|
563
|
+
| `hybrid` | `bool` | Enable hybrid search (dense + sparse vectors) | `False` |
|
|
564
|
+
| `sparse_dim` | `int` | Sparse dimension for hybrid index | `None` |
|
|
565
|
+
| `model_name` | `str` | Model name for sparse embeddings (e.g., `'splade_pp'`, `'bert_base'`) | `None` |
|
|
566
|
+
| `M` | `int` | Optional HNSW M parameter (bi-directional links per node) | `None` (backend default) |
|
|
567
|
+
| `ef_con` | `int` | Optional HNSW ef_construction parameter | `None` (backend default) |
|
|
446
568
|
|
|
447
569
|
### Distance Metrics
|
|
448
570
|
|
|
@@ -454,38 +576,39 @@ Delete the index when you're done to free up resources.
|
|
|
454
576
|
|
|
455
577
|
### Precision Settings
|
|
456
578
|
|
|
457
|
-
The `precision` parameter controls the
|
|
579
|
+
The `precision` parameter controls the vector storage format and affects memory usage and search performance:
|
|
458
580
|
|
|
459
581
|
| Precision | Description | Use Case |
|
|
460
582
|
|-----------|-------------|----------|
|
|
461
|
-
| `"
|
|
462
|
-
| `"
|
|
463
|
-
| `"
|
|
464
|
-
| `
|
|
583
|
+
| `"float32"` | Full precision floating point | Maximum accuracy, higher memory usage |
|
|
584
|
+
| `"float16"` | Half precision floating point | Balanced accuracy and memory (default) |
|
|
585
|
+
| `"binary"` | Binary vectors | Extremely compact, best for binary embeddings |
|
|
586
|
+
| `"int8d"` | 8-bit integer quantization | High compression, good accuracy |
|
|
587
|
+
| `"int16d"` | 16-bit integer quantization | Better accuracy than int8d, moderate compression |
|
|
465
588
|
|
|
466
|
-
###
|
|
589
|
+
### HNSW Parameters (Optional)
|
|
467
590
|
|
|
468
|
-
|
|
591
|
+
HNSW (Hierarchical Navigable Small World) parameters control index construction and search quality. These are **optional** - if not provided, the Endee backend uses optimized defaults.
|
|
469
592
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
593
|
+
| Parameter | Description | Impact |
|
|
594
|
+
|-----------|-------------|--------|
|
|
595
|
+
| `M` | Number of bi-directional links per node | Higher M = better recall, more memory |
|
|
596
|
+
| `ef_con` | Size of dynamic candidate list during construction | Higher ef_con = better quality, slower indexing |
|
|
597
|
+
|
|
598
|
+
**Example with custom HNSW parameters:**
|
|
474
599
|
|
|
475
|
-
|
|
600
|
+
```python
|
|
476
601
|
vector_store = EndeeVectorStore.from_params(
|
|
477
|
-
api_token=
|
|
478
|
-
index_name=
|
|
479
|
-
dimension=
|
|
602
|
+
api_token="your-token",
|
|
603
|
+
index_name="custom_index",
|
|
604
|
+
dimension=384,
|
|
480
605
|
space_type="cosine",
|
|
481
|
-
|
|
482
|
-
|
|
606
|
+
M=32, # Optional: custom M value
|
|
607
|
+
ef_con=256 # Optional: custom ef_construction
|
|
483
608
|
)
|
|
484
|
-
|
|
485
|
-
# Important: Store this key securely! You'll need it to access the index later.
|
|
486
609
|
```
|
|
487
610
|
|
|
488
|
-
|
|
611
|
+
**Note:** Only specify M and ef_con if you need to fine-tune performance. The backend defaults work well for most use cases.
|
|
489
612
|
|
|
490
613
|
---
|
|
491
614
|
|
|
@@ -7,18 +7,19 @@ Build powerful RAG applications with Endee vector database and LlamaIndex.
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
9
9
|
1. [Installation](#1-installation)
|
|
10
|
-
2. [
|
|
11
|
-
3. [
|
|
12
|
-
4. [
|
|
13
|
-
5. [
|
|
14
|
-
6. [
|
|
15
|
-
7. [
|
|
16
|
-
8. [
|
|
17
|
-
9. [
|
|
18
|
-
10. [Custom Retriever
|
|
19
|
-
11. [
|
|
20
|
-
12. [
|
|
21
|
-
13. [
|
|
10
|
+
2. [Testing locally](#testing-locally)
|
|
11
|
+
3. [Setting up Credentials](#2-setting-up-endee-and-openai-credentials)
|
|
12
|
+
4. [Creating Sample Documents](#3-creating-sample-documents)
|
|
13
|
+
5. [Setting up Endee with LlamaIndex](#4-setting-up-endee-with-llamaindex)
|
|
14
|
+
6. [Creating a Vector Index](#5-creating-a-vector-index-from-documents)
|
|
15
|
+
7. [Basic Retrieval](#6-basic-retrieval-with-query-engine)
|
|
16
|
+
8. [Using Metadata Filters](#7-using-metadata-filters)
|
|
17
|
+
9. [Advanced Filtering](#8-advanced-filtering-with-multiple-conditions)
|
|
18
|
+
10. [Custom Retriever Setup](#9-custom-retriever-setup)
|
|
19
|
+
11. [Custom Retriever with Query Engine](#10-using-a-custom-retriever-with-a-query-engine)
|
|
20
|
+
12. [Direct VectorStore Querying](#11-direct-vectorstore-querying)
|
|
21
|
+
13. [Saving and Loading Indexes](#12-saving-and-loading-indexes)
|
|
22
|
+
14. [Cleanup](#13-cleanup)
|
|
22
23
|
|
|
23
24
|
---
|
|
24
25
|
|
|
@@ -26,12 +27,66 @@ Build powerful RAG applications with Endee vector database and LlamaIndex.
|
|
|
26
27
|
|
|
27
28
|
Get started by installing the required package.
|
|
28
29
|
|
|
30
|
+
### Basic Installation (Dense-only search)
|
|
31
|
+
|
|
29
32
|
```bash
|
|
30
33
|
pip install endee-llamaindex
|
|
31
34
|
```
|
|
32
35
|
|
|
33
36
|
> **Note:** This will automatically install `endee` and `llama-index` as dependencies.
|
|
34
37
|
|
|
38
|
+
### Full Installation (with Hybrid Search support)
|
|
39
|
+
|
|
40
|
+
For hybrid search capabilities (dense + sparse vectors), install with the `hybrid` extra:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install endee-llamaindex[hybrid]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This includes FastEmbed for sparse vector encoding (SPLADE, BM25, etc.).
|
|
47
|
+
|
|
48
|
+
### GPU-Accelerated Hybrid Search
|
|
49
|
+
|
|
50
|
+
For GPU-accelerated sparse encoding:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install endee-llamaindex[hybrid-gpu]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### All Features
|
|
57
|
+
|
|
58
|
+
To install all optional dependencies:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install endee-llamaindex[all]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Installation Options Summary
|
|
65
|
+
|
|
66
|
+
| Installation | Use Case | Includes |
|
|
67
|
+
|--------------|----------|----------|
|
|
68
|
+
| `pip install endee-llamaindex` | Dense vector search only | Core dependencies |
|
|
69
|
+
| `pip install endee-llamaindex[hybrid]` | Dense + sparse hybrid search | + FastEmbed (CPU) |
|
|
70
|
+
| `pip install endee-llamaindex[hybrid-gpu]` | GPU-accelerated hybrid search | + FastEmbed (GPU) |
|
|
71
|
+
| `pip install endee-llamaindex[all]` | All features | All optional deps |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Testing locally
|
|
76
|
+
|
|
77
|
+
From the project root:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python -m venv env && source env/bin/activate # optional
|
|
81
|
+
pip install -e .
|
|
82
|
+
pip install pytest sentence-transformers huggingface-hub
|
|
83
|
+
export ENDEE_API_TOKEN="your-endee-api-token" # or set in endee_llamaindex/test_cases/setup_class.py
|
|
84
|
+
|
|
85
|
+
cd endee_llamaindex/test_cases && PYTHONPATH=.. python -m pytest . -v
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
See [TESTING.md](TESTING.md) for more options and single-test runs.
|
|
89
|
+
|
|
35
90
|
---
|
|
36
91
|
|
|
37
92
|
## 2. Setting up Endee and OpenAI credentials
|
|
@@ -121,7 +176,7 @@ vector_store = EndeeVectorStore.from_params(
|
|
|
121
176
|
index_name=index_name,
|
|
122
177
|
dimension=dimension,
|
|
123
178
|
space_type="cosine", # Can be "cosine", "l2", or "ip"
|
|
124
|
-
precision="
|
|
179
|
+
precision="float16" # Options: "binary", "float16", "float32", "int16d", "int8d" (default: "float16")
|
|
125
180
|
)
|
|
126
181
|
|
|
127
182
|
# Create storage context with our vector store
|
|
@@ -136,9 +191,37 @@ print(f"Initialized Endee vector store with index: {index_name}")
|
|
|
136
191
|
|-----------|-------------|---------|
|
|
137
192
|
| `space_type` | Distance metric for similarity | `cosine`, `l2`, `ip` |
|
|
138
193
|
| `dimension` | Vector dimension | Must match embedding model |
|
|
139
|
-
| `precision` | Index precision setting | `"
|
|
140
|
-
| `key` | Encryption key for metadata | 256-bit hex key (64 hex characters) |
|
|
194
|
+
| `precision` | Index precision setting | `"binary"`, `"float16"` (default), `"float32"`, `"int16d"`, `"int8d"` |
|
|
141
195
|
| `batch_size` | Vectors per API call | Default: `100` |
|
|
196
|
+
| `hybrid` | Enable hybrid search (dense + sparse) | Default: `False` |
|
|
197
|
+
| `M` | Optional HNSW M parameter (bi-directional links) | Optional (backend default if not specified) |
|
|
198
|
+
| `ef_con` | Optional HNSW ef_construction parameter | Optional (backend default if not specified) |
|
|
199
|
+
|
|
200
|
+
### Hybrid Search and Sparse Models
|
|
201
|
+
|
|
202
|
+
When you enable hybrid search by providing a positive `sparse_dim` and a `model_name`, the vector store automatically computes sparse (bag-of-words‑style) vectors in addition to dense vectors.
|
|
203
|
+
|
|
204
|
+
- **Sparse dimension (`sparse_dim`)**:
|
|
205
|
+
- For the built-in SPLADE models, the recommended `sparse_dim` is **30522** (matching the model vocabulary size).
|
|
206
|
+
- For dense‑only search, omit `sparse_dim` (or set it to `0`).
|
|
207
|
+
- **Supported sparse models (`model_name`)**:
|
|
208
|
+
- `"splade_pp"` → `prithivida/Splade_PP_en_v1` (SPLADE++)
|
|
209
|
+
- `"splade_cocondenser"` → `naver/splade-cocondenser-ensembledistil`
|
|
210
|
+
|
|
211
|
+
Example hybrid configuration:
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
vector_store = EndeeVectorStore.from_params(
|
|
215
|
+
api_token=endee_api_token,
|
|
216
|
+
index_name=index_name,
|
|
217
|
+
dimension=dimension, # dense dimension (e.g., 1536 for OpenAI)
|
|
218
|
+
space_type="cosine",
|
|
219
|
+
precision="float16",
|
|
220
|
+
hybrid=True,
|
|
221
|
+
sparse_dim=30522, # sparse dimension for SPLADE models
|
|
222
|
+
model_name="splade_pp", # or "splade_cocondenser"
|
|
223
|
+
)
|
|
224
|
+
```
|
|
142
225
|
|
|
143
226
|
---
|
|
144
227
|
|
|
@@ -215,16 +298,47 @@ print(response)
|
|
|
215
298
|
|
|
216
299
|
### Available Filter Operators
|
|
217
300
|
|
|
218
|
-
| Operator | Description |
|
|
219
|
-
|
|
220
|
-
| `FilterOperator.EQ` | Equal to |
|
|
221
|
-
| `FilterOperator.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
301
|
+
| Operator | Description | Backend Symbol | Example |
|
|
302
|
+
|----------|-------------|----------------|---------|
|
|
303
|
+
| `FilterOperator.EQ` | Equal to | `$eq` | `rating == 5` |
|
|
304
|
+
| `FilterOperator.IN` | In list | `$in` | `category in ["ai", "ml"]` |
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
> **Important Notes:**
|
|
308
|
+
> - Currently, the Endee LlamaIndex integration only supports **EQ** and **IN** metadata filters.
|
|
309
|
+
> - Range-style operators (LT, LTE, GT, GTE) are **not** supported in this adapter.
|
|
310
|
+
|
|
311
|
+
### Filter Examples
|
|
312
|
+
|
|
313
|
+
Here are practical examples showing how to use the supported filter operators:
|
|
314
|
+
|
|
315
|
+
```python
|
|
316
|
+
from llama_index.core.vector_stores.types import MetadataFilters, MetadataFilter, FilterOperator
|
|
317
|
+
|
|
318
|
+
# Example 1: Equal to (EQ)
|
|
319
|
+
# Find documents with rating equal to 5
|
|
320
|
+
rating_filter = MetadataFilter(key="rating", value=5, operator=FilterOperator.EQ)
|
|
321
|
+
filters = MetadataFilters(filters=[rating_filter])
|
|
322
|
+
# Backend: {"rating": {"$eq": 5}}
|
|
323
|
+
|
|
324
|
+
# Example 2: In list (IN)
|
|
325
|
+
# Find documents in AI or ML categories
|
|
326
|
+
category_filter = MetadataFilter(key="category", value=["ai", "ml"], operator=FilterOperator.IN)
|
|
327
|
+
filters = MetadataFilters(filters=[category_filter])
|
|
328
|
+
# Backend: {"category": {"$in": ["ai", "ml"]}}
|
|
329
|
+
|
|
330
|
+
# Example 3: Combined filters (AND logic)
|
|
331
|
+
# Find AI documents with rating equal to 5
|
|
332
|
+
filters = MetadataFilters(filters=[
|
|
333
|
+
MetadataFilter(key="category", value="ai", operator=FilterOperator.EQ),
|
|
334
|
+
MetadataFilter(key="rating", value=5, operator=FilterOperator.EQ)
|
|
335
|
+
])
|
|
336
|
+
# Backend: [{"category": {"$eq": "ai"}}, {"rating": {"$eq": 5}}]
|
|
337
|
+
|
|
338
|
+
# Create a query engine with filters
|
|
339
|
+
filtered_engine = index.as_query_engine(filters=filters)
|
|
340
|
+
response = filtered_engine.query("What is machine learning?")
|
|
341
|
+
```
|
|
228
342
|
|
|
229
343
|
---
|
|
230
344
|
|
|
@@ -415,10 +529,14 @@ Delete the index when you're done to free up resources.
|
|
|
415
529
|
| `api_token` | `str` | Your Endee API token | Required |
|
|
416
530
|
| `index_name` | `str` | Name of the index | Required |
|
|
417
531
|
| `dimension` | `int` | Vector dimension | Required |
|
|
418
|
-
| `space_type` | `str` | Distance metric | `"cosine"` |
|
|
419
|
-
| `precision` | `str` | Index precision
|
|
420
|
-
| `key` | `str` | Encryption key for metadata (256-bit hex) | `None` |
|
|
532
|
+
| `space_type` | `str` | Distance metric (`"cosine"`, `"l2"`, `"ip"`) | `"cosine"` |
|
|
533
|
+
| `precision` | `str` | Index precision (`"binary"`, `"float16"`, `"float32"`, `"int16d"`, `"int8d"`) | `"float16"` |
|
|
421
534
|
| `batch_size` | `int` | Vectors per API call | `100` |
|
|
535
|
+
| `hybrid` | `bool` | Enable hybrid search (dense + sparse vectors) | `False` |
|
|
536
|
+
| `sparse_dim` | `int` | Sparse dimension for hybrid index | `None` |
|
|
537
|
+
| `model_name` | `str` | Model name for sparse embeddings (e.g., `'splade_pp'`, `'bert_base'`) | `None` |
|
|
538
|
+
| `M` | `int` | Optional HNSW M parameter (bi-directional links per node) | `None` (backend default) |
|
|
539
|
+
| `ef_con` | `int` | Optional HNSW ef_construction parameter | `None` (backend default) |
|
|
422
540
|
|
|
423
541
|
### Distance Metrics
|
|
424
542
|
|
|
@@ -430,38 +548,39 @@ Delete the index when you're done to free up resources.
|
|
|
430
548
|
|
|
431
549
|
### Precision Settings
|
|
432
550
|
|
|
433
|
-
The `precision` parameter controls the
|
|
551
|
+
The `precision` parameter controls the vector storage format and affects memory usage and search performance:
|
|
434
552
|
|
|
435
553
|
| Precision | Description | Use Case |
|
|
436
554
|
|-----------|-------------|----------|
|
|
437
|
-
| `"
|
|
438
|
-
| `"
|
|
439
|
-
| `"
|
|
440
|
-
| `
|
|
555
|
+
| `"float32"` | Full precision floating point | Maximum accuracy, higher memory usage |
|
|
556
|
+
| `"float16"` | Half precision floating point | Balanced accuracy and memory (default) |
|
|
557
|
+
| `"binary"` | Binary vectors | Extremely compact, best for binary embeddings |
|
|
558
|
+
| `"int8d"` | 8-bit integer quantization | High compression, good accuracy |
|
|
559
|
+
| `"int16d"` | 16-bit integer quantization | Better accuracy than int8d, moderate compression |
|
|
441
560
|
|
|
442
|
-
###
|
|
561
|
+
### HNSW Parameters (Optional)
|
|
443
562
|
|
|
444
|
-
|
|
563
|
+
HNSW (Hierarchical Navigable Small World) parameters control index construction and search quality. These are **optional** - if not provided, the Endee backend uses optimized defaults.
|
|
445
564
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
565
|
+
| Parameter | Description | Impact |
|
|
566
|
+
|-----------|-------------|--------|
|
|
567
|
+
| `M` | Number of bi-directional links per node | Higher M = better recall, more memory |
|
|
568
|
+
| `ef_con` | Size of dynamic candidate list during construction | Higher ef_con = better quality, slower indexing |
|
|
569
|
+
|
|
570
|
+
**Example with custom HNSW parameters:**
|
|
450
571
|
|
|
451
|
-
|
|
572
|
+
```python
|
|
452
573
|
vector_store = EndeeVectorStore.from_params(
|
|
453
|
-
api_token=
|
|
454
|
-
index_name=
|
|
455
|
-
dimension=
|
|
574
|
+
api_token="your-token",
|
|
575
|
+
index_name="custom_index",
|
|
576
|
+
dimension=384,
|
|
456
577
|
space_type="cosine",
|
|
457
|
-
|
|
458
|
-
|
|
578
|
+
M=32, # Optional: custom M value
|
|
579
|
+
ef_con=256 # Optional: custom ef_construction
|
|
459
580
|
)
|
|
460
|
-
|
|
461
|
-
# Important: Store this key securely! You'll need it to access the index later.
|
|
462
581
|
```
|
|
463
582
|
|
|
464
|
-
|
|
583
|
+
**Note:** Only specify M and ef_con if you need to fine-tune performance. The backend defaults work well for most use cases.
|
|
465
584
|
|
|
466
585
|
---
|
|
467
586
|
|