Hamming AI comes with pre-built scorers that cover a wide range of use cases. If you need to score your experiments in a different way, you can do so by creating a custom scorer.

Definitions

A custom scorer is a function that computes a score of a given experiment result.

Looking at the function output, we can define a custom scorer as:

  1. Classification Scorer: A function that returns a categorical value. (e.g. low, medium, high)
  2. Numerical Scorer: A function that returns a real number.

Based on the execution environment, we can define a custom scorer as:

  1. Local Scorer: A function that runs on the machine that executes the experiment.
  2. Remote Scorer: A function that runs on Hamming AI platform. [Coming soon]

Before you begin

Follow the Evaluations Guide to get familiar with running experiments on Hamming AI. You should have a dataset ID and a secret key to continue with this guide.

Creating a Custom Scorer (hello world) - Python

Simple custom scorer that scores if the length of the answers has the same parity.

Creating a Custom Scorer (multiple outputs) - Python

Sometimes you may have multiple correct outputs to compare your model’s output to. See example dataset row:

{
    "question":
        "Can you explain the differences between quantum mechanics and classical physics?",
    "answers": [
        "Quantum mechanics differs from classical physics in several ways. For instance, it introduces the concept of wave-particle duality, where particles can exhibit both wave-like and particle-like properties. Additionally, it incorporates the principle of uncertainty, which states that certain pairs of properties, like position and momentum, cannot be simultaneously measured with arbitrary precision.",
        "Quantum mechanics introduces wave-particle duality and the uncertainty principle, which are not present in classical physics.",
        "Classical physics is deterministic, while quantum mechanics is probabilistic.",
        "Quantum mechanics requires the use of complex numbers and operators, unlike classical physics.",
    ],
}

Creating a Custom Scorer (reference-free scoring) - Python

Sometimes you may have no clear expected output to compare your model’s output to. See example dataset row:

{
    "question": "Can you explain the differences between quantum mechanics and classical physics? Make sure to include delve in your answer.",
}