hsfs.embedding #
EmbeddingFeature #
Represents an embedding feature.
| 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 used for the embedding feature. Available functions are TYPE: |
model | A Model in hsml. TYPE: |
feature_group | The feature group object that contains the embedding feature. TYPE: |
embedding_index | The index for managing embedding features. TYPE: |
name property #
str: The name of the embedding feature.
dimenstion property #
The dimensionality of the embedding feature.
This one is excluded from the docs as the name is misspelled but kept to avoid breaking the API.
similarity_function_type property #
similarity_function_type: SimilarityFunctionType
SimilarityFunctionType: The type of similarity function used for the embedding feature.
feature_group property writable #
feature_group: FeatureGroup | None
The feature group object that contains the embedding feature.
embedding_index property writable #
embedding_index: EmbeddingIndex | None
The index for managing embedding features.
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 the features that contain embeddings that should be indexed for similarity search. 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 | None
The feature group object that contains the embedding feature.
add_embedding #
add_embedding(
name: str,
dimension: int,
similarity_function_type: SimilarityFunctionType = SimilarityFunctionType.L2,
model: Model | None = 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 |
TYPE: |
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. |
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. |