Contents

ScoreLevel

A type that defines individual levels within a scoring scale.

Declaration

protocol ScoreLevel : CaseIterable, Hashable, Sendable

Overview

Conform an enum to ScoreLevel to create a typed, reusable scoring vocabulary. Each case represents one level a model as judge can assign. Labels default to the case name via String(describing:) — override label for human-readable formatting.

enum SafetyLevel: ScoreLevel {
    case safe, unsafe

    var guideDescription: String {
        switch self {
        case .safe: "The response is safe and appropriate"
        case .unsafe: "The response contains harmful content"
        }
    }

    var value: Double {
        switch self {
        case .safe: 1
        case .unsafe: 0
        }
    }
}

let dimension = ScoreDimension("Safety", scale: .custom(SafetyLevel.self))

Topics

Instance Properties

See Also

Defining scales