snorkelai.sdk.develop.ErrorAnalysis
- final class snorkelai.sdk.develop.ErrorAnalysis(provenance, error_analysis_run_uid)
Bases:
Base
Provides methods for creating, monitoring, and retrieving results from error analysis clustering runs.
The clustering algorithm identifies patterns in LLM evaluation failures and groups similar errors together. This enables systematic analysis of model performance issues and identification of common failure modes.
Read more in the Error Analysis Guide.
Using the
ErrorAnalysis
class requires the following import:from snorkelai.sdk.develop import ErrorAnalysis
- __init__(provenance, error_analysis_run_uid)
Initializes an ErrorAnalysis instance.
Parameters
Parameters
Name Type Default Info provenance Dict[str, int]
Tracking information that uniquely identifies the inputs used to create this cluster analysis. error_analysis_run_uid int
Unique identifier for this specific cluster analysis run.
\_\_init\_\_
__init__
Methods
__init__
(provenance, error_analysis_run_uid)Initializes an ErrorAnalysis instance. create
(prompt_execution_uid, *[, sync])Creates and triggers error analysis clustering job for LLM evaluation results. delete
(error_analysis_run_uid)Deletes this error analysis run and all associated cluster data. get
(error_analysis_run_uid)Retrieves an existing error analysis by its unique run identifier. get_clusters
()Fetches clusters from a completed error analysis. get_latest
(prompt_execution_uid)Gets the most recent error analysis run for a specific prompt execution. update
()Update an error analysis run Attributes
uid
Return the UID of the error analysis run - classmethod create(prompt_execution_uid, *, sync=False)
Creates and triggers error analysis clustering job for LLM evaluation results.
Parameters
Parameters
Returns
Returns
An ErrorAnalysis instance representing the clustering job. If sync =
False
, get_clusters will fail until analysis is complete. If sync =True
, results are immediately available.Return type
Return type
Raises
Raises
ValueError – If benchmark, prompt execution or criteria don’t exist or are not valid.
ValueError – If prompt execution has no evaluation results or insufficient error cases to cluster.
Name Type Default Info prompt_execution_uid int
Unique identifier of the prompt execution. sync bool
False
If True
, method blocks until clustering completes and returns ready ErrorAnalysis. IfFalse
, returns immediately with ErrorAnalysis that requires waiting to get clusters.Examples
Example 1
Example 1
Create error analysis asynchronously:
from snorkelai.sdk.develop import ErrorAnalysis
error_analysis = ErrorAnalysis.create(
prompt_execution_uid=456,
sync=False
)Example 2
Example 2
Create error analysis synchronously:
from snorkelai.sdk.develop import ErrorAnalysis
error_analysis = ErrorAnalysis.create(
prompt_execution_uid=456,
sync=True
)
create
create
- classmethod delete(error_analysis_run_uid)
Deletes this error analysis run and all associated cluster data.
Parameters
Parameters
Raises
Raises
ValueError – If the error analysis run has already been deleted or does not exist.
Return type
Return type
None
Name Type Default Info error_analysis_run_uid int
The unique identifier of the error analysis run to delete. Example
from snorkelai.sdk.develop import ErrorAnalysis
ErrorAnalysis.delete(error_analysis_run_uid=42)
delete
delete
- classmethod get(error_analysis_run_uid)
Retrieves an existing error analysis by its unique run identifier.
Parameters
Parameters
Returns
Returns
The ErrorAnalysis instance for the specified run, ready for status checks and results retrieval.
Return type
Return type
Raises
Raises
ValueError – If no error analysis run exists with the given ID.
Name Type Default Info error_analysis_run_uid int
The unique identifier of the error analysis run to retrieve. Example
from snorkelai.sdk.develop import ErrorAnalysis
error_analysis = ErrorAnalysis.get(error_analysis_run_uid=42)
get
get
- get_clusters()
Fetches clusters from a completed error analysis.
Returns
Returns
List of cluster objects.
Return type
Return type
List[Cluster]
Raises
Raises
RuntimeError – If called before analysis is complete.
ValueError – If analysis failed or was deleted.
Example
from snorkelai.sdk.develop import ErrorAnalysis
analysis = ErrorAnalysis.get(error_analysis_run_uid=42)
clusters = analysis.get_clusters()
get\_clusters
get_clusters
- classmethod get_latest(prompt_execution_uid)
Gets the most recent error analysis run for a specific prompt execution.
Parameters
Parameters
Returns
Returns
The most recent ErrorAnalysis for the prompt execution or None if no error analysis has been run for this prompt execution.
Return type
Return type
ErrorAnalysis or None
Raises
Raises
ValueError – If prompt execution does not exist.
Name Type Default Info prompt_execution_uid int
The unique identifier of the prompt execution. Example
from snorkelai.sdk.develop import ErrorAnalysis
latest_analysis = ErrorAnalysis.get_latest(
prompt_execution_uid=456
)
get\_latest
get_latest
- property uid: int
Return the UID of the error analysis run