-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Indexes as backend specific arguments
- Loading branch information
1 parent
5483487
commit e728315
Showing
24 changed files
with
234 additions
and
111 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
from vectordb_orm.backends.milvus.indexes import (Milvus_BIN_FLAT, | ||
Milvus_BIN_IVF_FLAT, | ||
Milvus_FLAT, Milvus_HNSW, | ||
Milvus_IVF_FLAT, | ||
Milvus_IVF_PQ, | ||
Milvus_IVF_SQ8) | ||
from vectordb_orm.backends.milvus.milvus import MilvusBackend | ||
from vectordb_orm.backends.pinecone.indexes import (PineconeIndex, | ||
PineconeSimilarityMetric) | ||
from vectordb_orm.backends.pinecone.pinecone import PineconeBackend | ||
from vectordb_orm.base import VectorSchemaBase | ||
from vectordb_orm.fields import EmbeddingField, VarCharField, PrimaryKeyField | ||
from vectordb_orm.enums import ConsistencyType | ||
from vectordb_orm.fields import EmbeddingField, PrimaryKeyField, VarCharField | ||
from vectordb_orm.session import VectorSession | ||
from vectordb_orm.indexes import FLAT, IVF_FLAT, IVF_SQ8, IVF_PQ, HNSW, BIN_FLAT, BIN_IVF_FLAT | ||
from vectordb_orm.similarity import ConsistencyType | ||
from vectordb_orm.backends.milvus import MilvusBackend | ||
from vectordb_orm.backends.pinecone import PineconeBackend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from vectordb_orm.backends.milvus.indexes import * | ||
from vectordb_orm.backends.milvus.milvus import * | ||
from vectordb_orm.backends.milvus.similarity import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from vectordb_orm.backends.pinecone.indexes import * | ||
from vectordb_orm.backends.pinecone.pinecone import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from enum import Enum | ||
|
||
from vectordb_orm.index import IndexBase | ||
|
||
|
||
class PineconeSimilarityMetric(Enum): | ||
COSINE = "cosine" | ||
EUCLIDEAN = "euclidean" | ||
DOT_PRODUCT = "dotproduct" | ||
|
||
|
||
class PineconeIndex(IndexBase): | ||
""" | ||
Pinecone only supports one type of index | ||
""" | ||
def __init__(self, metric_type: PineconeSimilarityMetric): | ||
self.metric_type = metric_type | ||
self._assert_metric_type(metric_type) | ||
|
||
def get_index_parameters(self): | ||
return {} | ||
|
||
def get_inference_parameters(self): | ||
return {"metric_type": self.metric_type.name} | ||
|
||
def _assert_metric_type(self, metric_type: PineconeSimilarityMetric): | ||
# Only support valid combinations of metric type and index | ||
if isinstance(metric_type, PineconeSimilarityMetric): | ||
raise ValueError(f"Index type {self} is not supported for metric type {metric_type}") |
Oops, something went wrong.