Skip to content

Commit 412f953

Browse files
authored
Add initial Vamana docstrings to Python (#386)
1 parent 917dff1 commit 412f953

File tree

3 files changed

+55
-8
lines changed

3 files changed

+55
-8
lines changed

_quarto.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ quartodoc:
3939
- index.Index
4040
- flat_index
4141
- ivf_flat_index
42+
- vamana_index
4243
- ingestion
4344

4445
website:

apis/python/src/tiledb/vector_search/vamana_index.py

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
"""
2+
Vamana Index implementation.
3+
4+
Vamana is based on Microsoft's DiskANN vector search library, as described in these papers:
5+
```
6+
Subramanya, Suhas Jayaram, and Rohan Kadekodi. DiskANN: Fast Accurate Billion-Point Nearest Neighbor Search on a Single Node.
7+
8+
Singh, Aditi, et al. FreshDiskANN: A Fast and Accurate Graph-Based ANN Index for Streaming Similarity Search. arXiv:2105.09613, arXiv, 20 May 2021, http://arxiv.org/abs/2105.09613.
9+
10+
Gollapudi, Siddharth, et al. “Filtered-DiskANN: Graph Algorithms for Approximate Nearest Neighbor Search with Filters.” Proceedings of the ACM Web Conference 2023, ACM, 2023, pp. 3406-16, https://doi.org/10.1145/3543507.3583552.
11+
```
12+
"""
113
import warnings
214
from typing import Any, Mapping
315

@@ -17,14 +29,14 @@
1729

1830
class VamanaIndex(index.Index):
1931
"""
20-
Open a Vamana index
32+
Opens a `VamanaIndex`.
2133
2234
Parameters
2335
----------
2436
uri: str
25-
URI of the index
37+
URI of the index.
2638
config: Optional[Mapping[str, Any]]
27-
config dictionary, defaults to None
39+
TileDB config dictionary.
2840
"""
2941

3042
def __init__(
@@ -59,6 +71,9 @@ def __init__(
5971
self.size = self.base_size
6072

6173
def get_dimensions(self):
74+
"""
75+
Returns the dimension of the vectors in the index.
76+
"""
6277
return self.dimensions
6378

6479
def query_internal(
@@ -69,16 +84,16 @@ def query_internal(
6984
**kwargs,
7085
):
7186
"""
72-
Query an VAMANA index
87+
Queries a `VamanaIndex`.
7388
7489
Parameters
7590
----------
76-
queries: numpy.ndarray
77-
ND Array of queries
91+
queries: np.ndarray
92+
2D array of query vectors. This can be used as a batch query interface by passing multiple queries in one call.
7893
k: int
79-
Number of top results to return per query
94+
Number of results to return per query vector.
8095
opt_l: int
81-
How deep to search. Should be >= k. Defaults to 100.
96+
How deep to search. Should be >= k, and if it's not, we will set it to k.
8297
"""
8398
warnings.warn("The Vamana index is not yet supported, please use with caution.")
8499
if self.size == 0:
@@ -111,6 +126,23 @@ def create(
111126
storage_version: str = STORAGE_VERSION,
112127
**kwargs,
113128
) -> VamanaIndex:
129+
"""
130+
Creates an empty VamanaIndex.
131+
Parameters
132+
----------
133+
uri: str
134+
URI of the index.
135+
dimensions: int
136+
Number of dimensions for the vectors to be stored in the index.
137+
vector_type: np.dtype
138+
Datatype of vectors.
139+
Supported values (uint8, int8, float32).
140+
config: Optional[Mapping[str, Any]]
141+
TileDB config dictionary.
142+
storage_version: str
143+
The TileDB vector search storage version to use.
144+
If not provided, use the latest stable storage version.
145+
"""
114146
warnings.warn("The Vamana index is not yet supported, please use with caution.")
115147
validate_storage_version(storage_version)
116148
ctx = vspy.Ctx(config)

documentation/Building.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ Credentials:
7171
- Some tests run on TileDB Cloud using your current environment variable `TILEDB_REST_TOKEN` - you will need a valid API token for the tests to pass. See [Create API Tokens](https://docs.tiledb.com/cloud/how-to/account/create-api-tokens) for for instructions on getting one.
7272
- For continuous integration, the token is configured for the `unittest` user and all tests should pass.
7373

74+
## Quarto
75+
76+
First install quarto with [their instructions](https://quarto.org/docs/get-started) or [with Homebrew](https://formulae.brew.sh/cask/quarto).
77+
78+
Then run:
79+
80+
```bash
81+
pip install quartodoc
82+
quartodoc build
83+
quarto render --fail-if-warnings
84+
```
85+
86+
You can them open up `docs/documentation/index.html` in a web browser to preview the results.
87+
7488
# Dependencies
7589

7690
## Linux

0 commit comments

Comments
 (0)