Skip to main content
Custom Scores are the most flexible way to implement evaluation workflows using ABV. As any other evaluation method the purpose of custom scores is to assign evaluations metrics to Traces, Observations, Sessions, or DatasetRuns via the Score object (see Scores Data Model). This is achieved by ingesting scores via the ABV SDKs or API.

Common Use Cases

  • Collecting user feedback: Capture in-app feedback from users on application quality or performance via the Browser SDK.
  • Custom evaluation data pipeline: Continuously monitor quality by fetching traces from ABV, running custom evaluations, and ingesting scores back.
  • Custom internal workflow tooling: build custom internal tooling that helps you manage human-in-the-loop workflows. Ingest scores back into ABV, optionally following your custom schema by referencing a config.
  • Custom run-time evaluations: e.g. track whether the generated SQL code actually worked, or if the structured output was valid JSON.

Ingesting Scores via API/SDKs

You can add scores via the ABV SDKs or API. Scores can take one of three data types: Numeric, Categorical or Boolean. If a score is ingested manually using a trace_id to link the score to a trace, it is not necessary to wait until the trace has been created. The score will show up in the scores table and will be linked to the trace once the trace with the same trace_id is created. Here are examples by Score data types

Python SDK

Install package
Numeric Numeric score values must be provided as float.

Categorical

Categorical score values must be provided as strings.

Boolean

Boolean scores must be provided as a float. The value’s string equivalent will be automatically populated and is accessible on read.

JS/TS SDK

Environment variables Add your ABV credentials as environment variables, e.g. use .env file and dotenv package to load variable values.
.env
alternatively use Constructor parameters

Numeric

Numeric score values must be provided as float.

Categorical

Categorical score values must be provided as strings.

Boolean

Boolean scores must be provided as a float. The value’s string equivalent will be automatically populated and is accessible on read. See API reference for more details on POST/GET scores endpoints.
→ More details in Python SDK docs and JS/TS SDK docs. See API reference for more details on POST/GET score configs endpoints.

Preventing Duplicate Scores

By default, ABV allows for multiple scores of the same name on the same trace. This is useful if you’d like to track the evolution of a score over time or if e.g. you’ve received multiple user feedback scores on the same trace. In some cases, you want to prevent this behavior or update an existing score. This can be achieved by creating an idempotency key on the score and add this as an id when creating the score, e.g. <trace_id>-<score_name>.

Enforcing a Score Config

Score configs are helpful when you want to standardize your scores for future analysis. To enforce a score config, you can provide a configId when creating a score to reference a ScoreConfig that was previously created. Score Configs can be defined in the ABV UI or via our API. . Whenever you provide a ScoreConfig, the score data will be validated against the config. The following rules apply:
  • Score Name: Must equal the config’s name
  • Score Data Type: When provided, must match the config’s data type
  • Score Value when Type is numeric: Value must be within the min and max values defined in the config (if provided, min and max are optional and otherwise are assumed as -āˆž and +āˆž respectively)
  • Score Value when Type is categorical: Value must map to one of the categories defined in the config
  • Score Value when Type is boolean: Value must equal 0 or 1

Python SDK

Numeric Scores When ingesting numeric scores, you can provide the value as a float. If you provide a configId, the score value will be validated against the config’s numeric range, which might be defined by a minimum and/or maximum value.
Categorical Scores Categorical scores are used to evaluate data that falls into specific categories. When ingesting categorical scores, you can provide the value as a string. If you provide a configId, the score value will be validated against the config’s categories.
Boolean Scores When ingesting boolean scores, you can provide the value as a float. If you provide a configId, the score’s name and config’s name must match as well as their data types.

JS/TS SDK

Numeric Scores When ingesting numeric scores, you can provide the value as a float. If you provide a configId, the score value will be validated against the config’s numeric range, which might be defined by a minimum and/or maximum value.
Categorical Scores Categorical scores are used to evaluate data that falls into specific categories. When ingesting categorical scores, you can provide the value as a string. If you provide a configId, the score value will be validated against the config’s categories.
Boolean Scores When ingesting boolean scores, you can provide the value as a float. If you provide a configId, the score’s name and config’s name must match as well as their data types.
→ More details in Python SDK docs and JS/TS SDK docs. See API reference for more details on POST/GET score configs endpoints.

Inferred Score Properties

Certain score properties might be inferred based on your input:
  • If you don’t provide a score data type it will always be inferred. See tables below for details.
  • For boolean and categorical scores, we will provide the score value in both numerical and string format where possible. The score value format that is not provided as input, i.e. the translated value is referred to as the inferred value in the tables below.
  • On read for boolean scores both numerical and string representations of the score value will be returned, e.g. both 1 and True.
  • For categorical scores, the string representation is always provided and a numerical mapping of the category will be produced only if a ScoreConfig was provided.
Detailed Examples:

Numeric Scores

For example, let’s assume you’d like to ingest a numeric score to measure accuracy. We have included a table of possible score ingestion scenarios below.

Categorical Scores

For example, let’s assume you’d like to ingest a categorical score to measure correctness. We have included a table of possible score ingestion scenarios below.

Boolean Scores

For example, let’s assume you’d like to ingest a boolean score to measure helpfulness. We have included a table of possible score ingestion scenarios below.

Update Existing Scores via API/SDKs

When creating a score, you can provide an optional id parameter. This will update the score if it already exists within your project. If you want to update a score without needing to fetch the list of existing scores from ABV, you can set your own id parameter as an idempotency key when initially creating the score.