text

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package text evaluates generated text without imposing one shared sample on metrics with different semantic inputs.

Index

Constants

View Source
const MetricAnswerRelevance eval.MetricName = "answer_relevance"
View Source
const MetricCorrectness eval.MetricName = "correctness"
View Source
const MetricGroundedness eval.MetricName = "groundedness"

Variables

View Source
var ErrInvalidSample = errors.New("eval/text: invalid sample")

Functions

This section is empty.

Types

type AnswerRelevanceEvaluator

type AnswerRelevanceEvaluator struct {
	// contains filtered or unexported fields
}

AnswerRelevanceEvaluator scores whether generated output addresses its originating input. Groundedness is intentionally evaluated separately.

func NewAnswerRelevanceEvaluator

func NewAnswerRelevanceEvaluator(config ModelEvaluatorConfig) (*AnswerRelevanceEvaluator, error)

func (*AnswerRelevanceEvaluator) Evaluate

type AnswerRelevanceSample

type AnswerRelevanceSample struct {
	Input  string `json:"input"`
	Output string `json:"output"`
}

func (AnswerRelevanceSample) Validate

func (a AnswerRelevanceSample) Validate() error

type CorrectnessEvaluator

type CorrectnessEvaluator struct {
	// contains filtered or unexported fields
}

func NewCorrectnessEvaluator

func NewCorrectnessEvaluator(config ModelEvaluatorConfig) (*CorrectnessEvaluator, error)

func (*CorrectnessEvaluator) Evaluate

type CorrectnessSample

type CorrectnessSample struct {
	Input     string `json:"input"`
	Output    string `json:"output"`
	Reference string `json:"reference"`
}

func (CorrectnessSample) Validate

func (c CorrectnessSample) Validate() error

type GroundednessEvaluator

type GroundednessEvaluator struct {
	// contains filtered or unexported fields
}

GroundednessEvaluator scores whether generated output is supported by the supplied evidence.

func NewGroundednessEvaluator

func NewGroundednessEvaluator(config ModelEvaluatorConfig) (*GroundednessEvaluator, error)

func (*GroundednessEvaluator) Evaluate

type GroundednessSample

type GroundednessSample struct {
	Output   string   `json:"output"`
	Evidence []string `json:"evidence"`
}

func (GroundednessSample) Clone

func (GroundednessSample) EvidenceText

func (g GroundednessSample) EvidenceText() string

func (GroundednessSample) Validate

func (g GroundednessSample) Validate() error

type ModelEvaluatorConfig

type ModelEvaluatorConfig struct {
	Model          chat.Model
	PromptTemplate *chatclient.Template
	// Threshold is optional. Without one, evaluation produces a score without
	// inventing a pass/fail decision.
	Threshold *eval.Score
	Samples   int
}

ModelEvaluatorConfig configures model-backed text metrics. Each evaluator exposes only the prompt variables its own sample contains. Samples greater than one use the median judge score.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL