aip_sdk.embeddings
Embedding projections: tune a config locally, then read a run's coordinates.
Two entry points, one config type. compute() runs the embedding pipelines
in this process so a config can be tuned against data you already hold; the same
EmbedProjectConfig then goes to
aip.run(..., embeddings=config) and the platform persists the coordinates
with the run output, where aip_sdk.run.EmbeddingsHandle.coordinates()
reads them back.
Every result frame is long/tidy — one row per (row, pipeline) pair with
row_id, pipeline_id, x, y, cluster_id — rather than one wide
frame per pipeline, so a plot can facet or filter on pipeline_id without
reshaping, and adding a pipeline to a config never changes the frame's columns.
SavedAssignedDimension is what save_clusters() returns after
cluster labels are written to the platform's dataset-scoped assignment store.
Saved dimensions resolve as assigned:<name> and can drive slice delta grouping
(group_by=assigned:<name>) on any later run of the same dataset.
Requires the embeddings extra for config types and validation:
pip install 'aip-sdk[embeddings]'
Local compute() also needs the modality encoders your config names — install
embeddings-compute for all modalities, or embeddings-text / embeddings-image
for one family only:
pip install 'aip-sdk[embeddings,embeddings-compute]'
pip install 'aip-sdk[embeddings,embeddings-text]' # text-only preview
Reading a completed run's coordinates needs no extra.
aip_sdk.embeddings.CLUSTER_ASSIGN_SOURCE_OP
aip_sdk.embeddings.CLUSTER_ASSIGN_SOURCE_OP = 'transform.embed_project'
No docstring is defined in the source.
aip_sdk.embeddings.COORDINATE_COLUMNS
aip_sdk.embeddings.COORDINATE_COLUMNS = ('row_id', 'pipeline_id', 'x', 'y', 'cluster_id')
No docstring is defined in the source.
aip_sdk.embeddings.EMBED_COLUMN
aip_sdk.embeddings.EMBED_COLUMN = 'embed'
No docstring is defined in the source.
aip_sdk.embeddings.EmbeddingComputeResult
aip_sdk.embeddings.EmbeddingComputeResult(coordinates: pd.DataFrame, pipelines: tuple[EmbeddingPipeline, ...])
Coordinates and per-pipeline diagnostics from one compute() call.
Attributes
coordinatespd.DataFrame: Tidy frame withCOORDINATE_COLUMNS, carrying only the pipelines that succeeded.pipelinestuple[EmbeddingPipeline, ...]: Every configured pipeline, succeeded and failed alike, so a caller can see what a config actually produced.
aip_sdk.embeddings.EmbeddingComputeResult.coordinates
aip_sdk.embeddings.EmbeddingComputeResult.coordinates: pd.DataFrame
No docstring is defined in the source.
aip_sdk.embeddings.EmbeddingComputeResult.failed
aip_sdk.embeddings.EmbeddingComputeResult.failed: tuple[EmbeddingPipeline, ...]
Pipelines that produced no coordinates, each carrying its error.
aip_sdk.embeddings.EmbeddingComputeResult.for_pipeline
aip_sdk.embeddings.EmbeddingComputeResult.for_pipeline(pipeline_id: str) -> pd.DataFrame
Return just pipeline_id's coordinates, indexed by position.
Parameters
pipeline_idstr: A derived pipeline id, as listed bypipeline_ids.
Returns
pd.DataFrame: The subset ofcoordinatesfor that pipeline.
Raises
EmbeddingsError: If no succeeded pipeline has that id.
aip_sdk.embeddings.EmbeddingComputeResult.pipeline_ids
aip_sdk.embeddings.EmbeddingComputeResult.pipeline_ids: tuple[str, ...]
Ids of the pipelines that produced coordinates.
aip_sdk.embeddings.EmbeddingComputeResult.pipelines
aip_sdk.embeddings.EmbeddingComputeResult.pipelines: tuple[EmbeddingPipeline, ...]
No docstring is defined in the source.
aip_sdk.embeddings.EmbeddingComputeResult.succeeded
aip_sdk.embeddings.EmbeddingComputeResult.succeeded: tuple[EmbeddingPipeline, ...]
Pipelines that produced coordinates.
aip_sdk.embeddings.EmbeddingPipeline
aip_sdk.embeddings.EmbeddingPipeline(pipeline_id: str, status: str, supervised: bool, supervision_column: str | None = None, trustworthiness: float | None = None, error: str | None = None)
One pipeline's outcome and diagnostics.
Attributes
pipeline_idstr: Derived id,<projection>.<embedding>.<label>— e.g.umap.text_qa.unsupervised. Derived from the pipeline's steps, so two configs naming the same steps produce the same id.statusstr:"succeeded"or"failed".supervisedbool: Whether the projection was guided by a per-row score.supervision_columnstr | None: Column that guided it, or None when unsupervised.trustworthinessfloat | None: How faithfully the 2D layout preserves the high-dimensional neighbourhoods, in[0, 1]. None when the pipeline failed, and also None on a succeeded pipeline whose frame was too small for the score to be defined — the layout is still usable, only this diagnostic is absent.errorstr | None: Why the pipeline produced no coordinates, or None on success.
aip_sdk.embeddings.EmbeddingPipeline.error
aip_sdk.embeddings.EmbeddingPipeline.error: str | None = None
No docstring is defined in the source.
aip_sdk.embeddings.EmbeddingPipeline.pipeline_id
aip_sdk.embeddings.EmbeddingPipeline.pipeline_id: str
No docstring is defined in the source.
aip_sdk.embeddings.EmbeddingPipeline.status
aip_sdk.embeddings.EmbeddingPipeline.status: str
No docstring is defined in the source.
aip_sdk.embeddings.EmbeddingPipeline.succeeded
aip_sdk.embeddings.EmbeddingPipeline.succeeded: bool
Whether this pipeline produced coordinates.
aip_sdk.embeddings.EmbeddingPipeline.supervised
aip_sdk.embeddings.EmbeddingPipeline.supervised: bool
No docstring is defined in the source.
aip_sdk.embeddings.EmbeddingPipeline.supervision_column
aip_sdk.embeddings.EmbeddingPipeline.supervision_column: str | None = None
No docstring is defined in the source.
aip_sdk.embeddings.EmbeddingPipeline.trustworthiness
aip_sdk.embeddings.EmbeddingPipeline.trustworthiness: float | None = None
No docstring is defined in the source.
aip_sdk.embeddings.ID_COLUMNS
aip_sdk.embeddings.ID_COLUMNS = ('row_id', 'input_id', 'image_id')
No docstring is defined in the source.
aip_sdk.embeddings.JsonDict
aip_sdk.embeddings.JsonDict = dict[str, Any]
No docstring is defined in the source.
aip_sdk.embeddings.META_KEY
aip_sdk.embeddings.META_KEY = 'meta'
No docstring is defined in the source.
aip_sdk.embeddings.NOISE_LABEL
aip_sdk.embeddings.NOISE_LABEL = 'noise'
No docstring is defined in the source.
aip_sdk.embeddings.NO_EMBEDDINGS
aip_sdk.embeddings.NO_EMBEDDINGS = '__none__'
No docstring is defined in the source.
aip_sdk.embeddings.RegisteredEmbeddingConfig
aip_sdk.embeddings.RegisteredEmbeddingConfig(id: str, workspace_id: str, name: str, config: JsonDict, created_at: datetime, updated_at: datetime)
A workspace-scoped EmbedProjectConfig registered under a name.
aip_sdk.embeddings.RegisteredEmbeddingConfig.config
aip_sdk.embeddings.RegisteredEmbeddingConfig.config: JsonDict
No docstring is defined in the source.
aip_sdk.embeddings.RegisteredEmbeddingConfig.created_at
aip_sdk.embeddings.RegisteredEmbeddingConfig.created_at: datetime
No docstring is defined in the source.
aip_sdk.embeddings.RegisteredEmbeddingConfig.id
aip_sdk.embeddings.RegisteredEmbeddingConfig.id: str
No docstring is defined in the source.
aip_sdk.embeddings.RegisteredEmbeddingConfig.name
aip_sdk.embeddings.RegisteredEmbeddingConfig.name: str
No docstring is defined in the source.
aip_sdk.embeddings.RegisteredEmbeddingConfig.updated_at
aip_sdk.embeddings.RegisteredEmbeddingConfig.updated_at: datetime
No docstring is defined in the source.
aip_sdk.embeddings.RegisteredEmbeddingConfig.workspace_id
aip_sdk.embeddings.RegisteredEmbeddingConfig.workspace_id: str
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension
aip_sdk.embeddings.SavedAssignedDimension(id: str, name: str, authored_by: str, source_op: str | None, source_run_id: str | None, category_count: int, dataset_version_id: str, assigned_rows: int, total_rows: int, unassigned_rows: int)
A row_id -> category assignment persisted as a dataset-scoped assigned: dimension.
Attributes
idstr: Qualified dimension id,assigned:<name>.namestr: Dimension name within the assigned namespace.authored_bystr: How the assignment came about —clusteringfor a save fromsave_clusters(),userfor one fromsave_dimension(). Metadata only: both resolve identically when grouping.source_opstr | None: Op that produced the labels, when one did —transform.embed_projectfor a cluster save, absent for a user-authored one.source_run_idstr | None: Run the labels were extracted from, when provided.category_countint: Distinct cluster labels saved.dataset_version_idstr: Version the assignment was validated against.assigned_rowsint: Rows that received a cluster label.total_rowsint: Rows in the target version.unassigned_rowsint: Version rows with no saved label.
aip_sdk.embeddings.SavedAssignedDimension.assigned_rows
aip_sdk.embeddings.SavedAssignedDimension.assigned_rows: int
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.authored_by
aip_sdk.embeddings.SavedAssignedDimension.authored_by: str
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.category_count
aip_sdk.embeddings.SavedAssignedDimension.category_count: int
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.dataset_version_id
aip_sdk.embeddings.SavedAssignedDimension.dataset_version_id: str
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.id
aip_sdk.embeddings.SavedAssignedDimension.id: str
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.name
aip_sdk.embeddings.SavedAssignedDimension.name: str
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.source_op
aip_sdk.embeddings.SavedAssignedDimension.source_op: str | None
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.source_run_id
aip_sdk.embeddings.SavedAssignedDimension.source_run_id: str | None
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.total_rows
aip_sdk.embeddings.SavedAssignedDimension.total_rows: int
No docstring is defined in the source.
aip_sdk.embeddings.SavedAssignedDimension.unassigned_rows
aip_sdk.embeddings.SavedAssignedDimension.unassigned_rows: int
No docstring is defined in the source.
aip_sdk.embeddings.attach_clusters
aip_sdk.embeddings.attach_clusters(df: pd.DataFrame, pipeline_id: str, id_column: str | None = None) -> pd.DataFrame
Return df with one pipeline's x, y, and cluster_id alongside.
The wide counterpart to flatten_embed_column(): for plotting a single
layout coloured by a column the run already carries, one frame is easier to
work with than a join.
Parameters
dfpd.DataFrame: A run-output frame carrying anembedcolumn.pipeline_idstr: Which pipeline's coordinates to attach.id_columnstr | None: Row-identity column. Defaults to the first ofID_COLUMNSpresent in df.
Returns
pd.DataFrame: A copy of df withx,y, andcluster_idcolumns added. Rowpd.DataFrame: count and row order are unchanged.
Raises
EmbeddingsError: If df has noembedcolumn, no row-identity column, or no coordinates for pipeline_id.
Examples:
plot_df = aip.embeddings.attach_clusters(run.output(), "umap.text_qa.unsupervised")
plot_df.plot.scatter(x="x", y="y", c="llm.bleu", colormap="viridis")
aip_sdk.embeddings.compute
aip_sdk.embeddings.compute(df: pd.DataFrame, config: EmbedProjectConfig, available_metrics: list[str] | None = None, cache_dir: str | None = None) -> EmbeddingComputeResult
Run every configured embedding pipeline over df, in this process.
No platform run, no SUT inference, no scoring — this is the authoring loop
for an embedding config: change a projection parameter, recompute, look at
the layout. The config that produces a layout you want is then passed
verbatim to aip.run(..., embeddings=config), which applies the same
pipelines to a run's scored output.
Row order is preserved and row count is invariant: the coordinate for row i of df is the coordinate reported against that row's identity.
Parameters
dfpd.DataFrame: Rows to embed. Needs a row-identity column (seerow_id_column()) plus whatever columns the configured embeddings read —promptfor text,image_pathandlabelfor image.configEmbedProjectConfig: The pipelines to run, and the embedding, projection, and clustering libraries they draw on.available_metricslist[str] | None: Per-row score columns a supervised pipeline may use. Supplies the columns for aexpand_supervision_over_metricswhose ownmetricsis unset; without it, such an expansion contributes no pipelines.cache_dirstr | None: Where to keep the embedding chunk cache. Defaults to a temporary directory removed when the call returns, on both the success and the failure path.
Returns
AnEmbeddingComputeResult: class:EmbeddingComputeResultwhosecoordinatescarries theEmbeddingComputeResult: succeeded pipelines and whosepipelinesdescribes all of them.
Raises
EmbeddingsNotInstalledError: If theembeddingsextra is not installed.EmbeddingsError: If df has no row-identity column, exceeds the config's row ceiling, or no pipeline produced coordinates.
Examples:
import aip_sdk as aip
from aip_embeddings_core import (
ClusteringConfig,
EmbeddingConfig,
EmbeddingPipelineConfig,
EmbedProjectConfig,
ProjectionConfig,
)
config = EmbedProjectConfig(
embeddings={"qa": EmbeddingConfig(modality="text", task_type="single_turn_llm")},
projections={"unsup": ProjectionConfig(n_neighbors=8)},
clusterings={"default": ClusteringConfig(min_cluster_size=5)},
pipelines=[EmbeddingPipelineConfig(embedding="qa", projection="unsup", clustering="default")],
)
result = aip.embeddings.compute(df, config)
print(result.pipeline_ids)
result.coordinates.head()
aip_sdk.embeddings.flatten_embed_column
aip_sdk.embeddings.flatten_embed_column(df: pd.DataFrame, id_column: str | None = None) -> pd.DataFrame
Explode a run output's nested embed column into a tidy frame.
The persisted embed struct holds one entry per row, keyed by pipeline id,
so reading it means walking rows and pipelines together. This does that walk
and attaches each coordinate to its row's identity.
Parameters
dfpd.DataFrame: A run-output frame carrying anembedcolumn, as returned byaip_sdk.run.Run.output().id_columnstr | None: Row-identity column to key coordinates by. Defaults to the first ofID_COLUMNSpresent in df.
Returns
pd.DataFrame: Tidy frame withCOORDINATE_COLUMNS. Empty (with those columns)pd.DataFrame: when the frame carries no coordinates.
Raises
EmbeddingsError: If df has noembedcolumn or no row-identity column.
Examples:
df = run.output()
coords = aip.embeddings.flatten_embed_column(df)
coords[coords.pipeline_id == "umap.text_qa.unsupervised"].head()
aip_sdk.embeddings.get
aip_sdk.embeddings.get(config_ref: str, *, workspace_id: str | None = None, client: APIClient | None = None) -> RegisteredEmbeddingConfig
Fetch a registered embedding config by id, or by name within one workspace.
The result can be passed straight to aip.run(..., embeddings=…) as a
one-run override — no need to reach into .config.
Parameters
config_refstr: The config's id, or its workspace-scoped name.workspace_idstr | None: Which workspace to resolve a name in. Names are unique only within a workspace, so pass this whenever the same name may exist in several — includingNO_EMBEDDINGS, which every workspace has. Not needed whenconfig_refis an id, or when you can see exactly one workspace.clientAPIClient | None: Optional pre-configured API client.
Returns
RegisteredEmbeddingConfig: The registered config, carrying itsid,nameand timestamps.
Raises
EmbeddingConfigNotFoundError: If no live config matches in a workspace the caller can see.ValidationError: If the name is ambiguous across workspaces the caller can see and noworkspace_idwas given. The message names the candidates.
aip_sdk.embeddings.list_embedding_configs
aip_sdk.embeddings.list_embedding_configs(page: int = 1, per_page: int = 100, *, workspace_id: str | None = None, client: APIClient | None = None, all_workspaces: bool = False) -> list[RegisteredEmbeddingConfig]
List registered embedding configs, newest first.
Reads your session's workspace unless you name one, and raises if none is set.
Pass all_workspaces=True to read across every workspace you can access.
Parameters
pageint: 1-based page number.per_pageint: Page size.workspace_idstr | None: Restrict to one workspace.clientAPIClient | None: Optional pre-configured API client.all_workspacesbool: Read across every workspace you can access.
Returns
list[RegisteredEmbeddingConfig]: The registered configs on the requested page.
Raises
ForbiddenError: Ifworkspace_idnames a workspace the caller cannot access.InvalidArgumentError: If bothworkspace_idandall_workspacesare given.NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, andall_workspaceswas not set.
aip_sdk.embeddings.pipelines_from_embed_column
aip_sdk.embeddings.pipelines_from_embed_column(df: pd.DataFrame) -> tuple[EmbeddingPipeline, ...]
Read per-pipeline metadata out of a run output's embed column.
Provenance travels with the coordinates, so this needs no second request.
meta.pipelines lists every configured pipeline — succeeded and failed.
Coordinate struct keys list only the pipelines that produced coordinates, so
the full set is the union of both when meta is present.
Parameters
dfpd.DataFrame: A run-output frame carrying anembedcolumn.
Returns
OneEmbeddingPipeline: class:EmbeddingPipelineper configured pipeline, ordered by id....: Failed pipelines carrystatus='failed'anderror; they have notuple[EmbeddingPipeline, ...]: coordinates. Empty when the frame carries none.
Raises
EmbeddingsError: If df has noembedcolumn.
aip_sdk.embeddings.register
aip_sdk.embeddings.register(name: str, config: EmbedProjectConfig | dict[str, Any], *, workspace_id: str | None = None, client: APIClient | None = None) -> RegisteredEmbeddingConfig
Register an EmbedProjectConfig under a workspace-scoped name.
Parameters
namestr: Catalogue name — unique among live configs in the workspace.configEmbedProjectConfig | dict[str, Any]: The sameEmbedProjectConfigused withaip.run(..., embeddings=config).workspace_idstr | None: Workspace to register in. Falls back to the client's configured workspace (AIP_WORKSPACE_ID); a membership is never picked arbitrarily, so a caller with no configured workspace must pass one.clientAPIClient | None: Optional pre-configured API client.
Returns
RegisteredEmbeddingConfig: The registered config, carrying the server-assignedidand timestamps.
Raises
DuplicateEmbeddingConfigError: If the name is already taken in the workspace.NoWorkspaceSelectedError: If no workspace is given and none is configured for the session.InvalidArgumentError: Ifconfigis not a validEmbedProjectConfig.
aip_sdk.embeddings.require_extra
aip_sdk.embeddings.require_extra() -> None
Raise unless local compute dependencies are installed.
Checks aip-embeddings-core ([embeddings]) and at least one modality
package ([embeddings-compute], [embeddings-text], or
[embeddings-image]). Core alone is enough for typed config authoring
and read-back — call this only before compute().
Raises
EmbeddingsNotInstalledError: If core or any modality package is missing.
Examples:
aip.embeddings.require_extra() # fail now, not after loading 10GB of frames
aip_sdk.embeddings.row_id_column
aip_sdk.embeddings.row_id_column(df: pd.DataFrame) -> str
Return the name of df's row-identity column.
Looks for ID_COLUMNS in order — row_id, then the schema-specific
input_id (text) and image_id (image).
Parameters
dfpd.DataFrame: Frame to inspect.
Returns
str: The column name found.
Raises
EmbeddingsError: If the frame carries none of them.
aip_sdk.embeddings.save_clusters
aip_sdk.embeddings.save_clusters(dataset: str, name: str, pipeline_id: str, *, df: pd.DataFrame | None = None, coordinates: pd.DataFrame | None = None, compute_result: EmbeddingComputeResult | None = None, source_run_id: str | None = None, version_id: str | None = None, client: APIClient | None = None) -> SavedAssignedDimension
Save one pipeline's cluster labels as a dataset-scoped assigned dimension.
Extracts row_id → cluster_id from embedding coordinates and calls
POST /datasets/{id}/dimensions:assign with authored_by="clustering".
The saved dimension resolves as assigned:<name> on every later run of
the same dataset, so slice delta grouping can use
group_by=assigned:<name>.
Unclustered rows are omitted from the assignment: HDBSCAN reports them as
the label "noise", and a pipeline with clustering disabled as null.
Both are dropped rather than saved, so they appear under missing: in
join coverage rather than as a noise category.
Parameters
datasetstr: Dataset id, or"name@vN"to pin the validation version.namestr: Assigned dimension name — lowercase, underscores, no dots.pipeline_idstr: Which pipeline's cluster labels to save.dfpd.DataFrame | None: Run output carrying a nestedembedcolumn. Mutually exclusive withcoordinates=andcompute_result=.coordinatespd.DataFrame | None: Tidy coordinate frame withCOORDINATE_COLUMNS.compute_resultEmbeddingComputeResult | None: Result ofcompute(); itscoordinatesare used.source_run_idstr | None: Run the labels were extracted from — stored as metadata.version_idstr | None: Dataset version whose row ids are validated. Defaults to the latest version. Mutually exclusive with aname@vNpin on dataset — passing both raises rather than silently choosing one.clientAPIClient | None: Optional pre-configured API client.
Returns
SavedAssignedDimension: The saved dimension, including coverage counts from the platform.
Raises
EmbeddingsError: If no coordinate source is given, more than one is given, df carries noembedcolumn, the coordinates frame is missing a required column, dataset is malformed, dataset andversion_id=pin different versions, the pinned version does not exist, the pipeline has no cluster labels, a row carries conflicting labels, or every row is unclustered noise.AipError: If no client is given and none is configured.UnprocessableEntityError: If the name or assignments fail platform validation.NotFoundError: If the dataset does not exist.ConflictError: If concurrent saves of the same dimension cannot be serialised.
Examples:
df = run.output()
saved = aip.embeddings.save_clusters(
dataset.id,
"clusters_semantic",
"umap.text_qa.unsupervised",
df=df,
source_run_id=run.id,
)
# Slice delta: group_by=saved.id