text

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 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"

MetricAnswerRelevance identifies whether output addresses its input.

View Source
const MetricCorrectness eval.MetricName = "correctness"

MetricCorrectness identifies agreement with an explicit reference answer.

View Source
const MetricGroundedness eval.MetricName = "groundedness"

MetricGroundedness identifies support from supplied evidence.

Variables

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

ErrInvalidSample identifies missing generated-text inputs or evidence.

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)

NewAnswerRelevanceEvaluator binds the text-specific prompt to the generic model judge.

func (*AnswerRelevanceEvaluator) Evaluate

type AnswerRelevanceSample

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

AnswerRelevanceSample relates generated output to the input it should answer.

func (AnswerRelevanceSample) Validate

func (a AnswerRelevanceSample) Validate() error

type CorrectnessEvaluator

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

CorrectnessEvaluator scores generated output against an explicit reference.

func NewCorrectnessEvaluator

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

NewCorrectnessEvaluator binds the reference-aware prompt to the generic model judge.

func (*CorrectnessEvaluator) Evaluate

type CorrectnessSample

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

CorrectnessSample supplies an explicit reference rather than treating retrieved evidence as ground truth.

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)

NewGroundednessEvaluator binds the evidence-aware prompt to the generic model judge.

func (*GroundednessEvaluator) Evaluate

type GroundednessSample

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

GroundednessSample keeps evidence separate from generated output so support is not conflated with answer relevance.

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