EmbeddingIndex#
EmbeddingIndex #
Represents an index for managing embedding features.
| PARAMETER | DESCRIPTION |
|---|---|
index_name | The name of the embedding index. The name of the project index is used if not provided. TYPE: |
features | A list of TYPE: |
col_prefix | The prefix to be added to column names when using project index. It is managed by Hopsworks and should not be provided. TYPE: |
Example
embedding_index = EmbeddingIndex()
embedding_index.add_embedding(name="user_vector", dimension=256)
embeddings = embedding_index.get_embeddings()
feature_group property writable #
feature_group
FeatureGroup: The feature group object that contains the embedding feature.
add_embedding #
add_embedding(
name: str,
dimension: int,
similarity_function_type: SimilarityFunctionType
| None = SimilarityFunctionType.L2,
model=None,
)
Adds a new embedding feature to the index.
Example
embedding_index = EmbeddingIndex()
embedding_index.add_embedding(name="user_vector", dimension=256)
# Attach a hsml model to the embedding feature
embedding_index = EmbeddingIndex()
embedding_index.add_embedding(name="user_vector", dimension=256, model=hsml_model)
| PARAMETER | DESCRIPTION |
|---|---|
name | The name of the embedding feature. TYPE: |
dimension | The dimensionality of the embedding feature. TYPE: |
similarity_function_type | The type of similarity function to be used. TYPE: |
model |
DEFAULT: |
count #
Count the number of records in the feature group.
| PARAMETER | DESCRIPTION |
|---|---|
options | The options used for the request to the vector database. The keys are attribute values of TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
int | The number of records in the feature group. |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If the feature group is not initialized. |
hopsworks.client.exceptions.FeatureStoreException | If an error occurs during the count operation. |
get_embedding #
get_embedding(name: str) -> EmbeddingFeature
Get EmbeddingFeature associated with the feature name.
| PARAMETER | DESCRIPTION |
|---|---|
name | The name of the embedding feature. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
EmbeddingFeature | The |
get_embeddings #
get_embeddings() -> list[EmbeddingFeature]
Returns the list of EmbeddingFeature objects associated with the index.
| RETURNS | DESCRIPTION |
|---|---|
list[EmbeddingFeature] | All embedding features in the index. |