pixano.features.schemas.embeddings.embedding
¶
Embedding(created_at=None, updated_at=None, **data)
¶
Bases: BaseSchema, ABC
Embeddings are used to define an embedding vector for an item in a dataset.
Attributes:
| Name | Type | Description |
|---|---|---|
item_ref |
ItemRef
|
Reference to the embedding's item. |
vector |
Any
|
The embedding vector that should be defined by subclasses. |
Source code in pixano/features/schemas/base_schema.py
item
property
¶
Get the embedding's item.
to_arrow_schema(remove_vector=False, remove_metadata=False)
classmethod
¶
Get the pyarrow schema of an Embedding.
This function allows to remove the vector field and the metadata from the schema which can be useful for adding data with auto-vectorization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
remove_vector
|
bool
|
Remove the vector field. |
False
|
remove_metadata
|
bool
|
Remove the metadata. |
False
|
Returns:
| Type | Description |
|---|---|
Schema
|
The pyarrow schema. |
Source code in pixano/features/schemas/embeddings/embedding.py
ViewEmbedding(created_at=None, updated_at=None, **data)
¶
ViewEmbeddings are used to define an embedding vector for a view in a dataset.
Attributes:
| Name | Type | Description |
|---|---|---|
view_ref |
ViewRef
|
Reference to the embedding's view. |
Source code in pixano/features/schemas/base_schema.py
view
property
¶
Get the embedding's view.
create_schema(embedding_fn, table_name, dataset, **embedding_function_kwargs)
classmethod
¶
Create a ViewEmbedding schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
embedding_fn
|
str
|
The embedding function. |
required |
table_name
|
str
|
The name of the table containing the schema. |
required |
dataset
|
Dataset
|
The dataset to which the schema belongs. |
required |
embedding_function_kwargs
|
Any
|
The keyword arguments for creating the embedding function. |
{}
|
Returns:
| Type | Description |
|---|---|
type[ViewEmbedding]
|
The |
Source code in pixano/features/schemas/embeddings/embedding.py
get_embedding_fn_from_table(dataset, table_name, metadata)
staticmethod
¶
Get the embedding function from a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
The dataset containing the table. |
required |
table_name
|
str
|
The name of the table containing the embedding function. |
required |
metadata
|
dict
|
The pyarrow metadata of the table. |
required |
Returns:
| Type | Description |
|---|---|
EmbeddingFunction
|
The embedding function. |
Source code in pixano/features/schemas/embeddings/embedding.py
create_view_embedding_function(type_embedding_function, name, dataset)
¶
Create a ViewEmbeddingFunction based on an
EmbeddingFunction.
Source code in pixano/features/schemas/embeddings/embedding.py
is_embedding(cls, strict=False)
¶
Check if a class is an Embedding or subclass of Embedding.
is_view_embedding(cls, strict=False)
¶
Check if a class is an ViewEmbedding or subclass of ViewEmbedding.