Skip to content

EmbeddingIndex#

[source]

EmbeddingIndex#

hsfs.embedding.EmbeddingIndex(index_name=None, features=None, col_prefix=None)

Represents an index for managing embedding features.

Arguments

  • index_name Optional[str]: The name of the embedding index. The name of the project index is used if not provided.
  • features Optional[List[hsfs.embedding.EmbeddingFeature]]: A list of EmbeddingFeature objects for the features that contain embeddings that should be indexed for similarity search.
  • col_prefix Optional[str]: The prefix to be added to column names when using project index. It is managed by Hopsworks and should not be provided.

Example

embedding_index = EmbeddingIndex()
embedding_index.add_embedding(name="user_vector", dimension=256)
embeddings = embedding_index.get_embeddings()

Properties#

[source]

col_prefix#

str: The prefix to be added to column names.


[source]

feature_group#

FeatureGroup: The feature group object that contains the embedding feature.


[source]

index_name#

str: The name of the embedding index.


Methods#

[source]

add_embedding#

EmbeddingIndex.add_embedding(name, dimension, similarity_function_type="l2_norm")

Adds a new embedding feature to the index.

Example:

embedding_index = EmbeddingIndex()
embedding_index.add_embedding(name="user_vector", dimension=256)

Arguments

  • name str: The name of the embedding feature.
  • dimension int: The dimensionality of the embedding feature.
  • similarity_function_type Optional[hsfs.embedding.SimilarityFunctionType]: The type of similarity function to be used.

[source]

from_json_response#

EmbeddingIndex.from_json_response(json_dict)

[source]

get_embeddings#

EmbeddingIndex.get_embeddings()

Returns the list of hsfs.embedding.EmbeddingFeature objects associated with the index.

Returns

A list of hsfs.embedding.EmbeddingFeature objects


[source]

json#

EmbeddingIndex.json()

Serialize the EmbeddingIndex object to a JSON string.


[source]

to_dict#

EmbeddingIndex.to_dict()

Convert the EmbeddingIndex object to a dictionary.

Returns: dict: A dictionary representation of the EmbeddingIndex object.