eval

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpRankingDiagnostics

func DumpRankingDiagnostics(path string, results []Result) error

func Summarize

func Summarize(results []Result) (recallAt5, recallAt10, mrr float64)

func SummarizeByTag

func SummarizeByTag(results []Result) (map[string]Summary, map[string]int)

SummarizeByTag aggregates metrics per slice tag. A result contributes to every tag it carries; untagged results land in the "untagged" bucket.

Types

type DiagnosticCandidate

type DiagnosticCandidate struct {
	Rank          int                      `json:"rank"`
	File          string                   `json:"file"`
	QualifiedName string                   `json:"qualified_name"`
	Kind          string                   `json:"kind"`
	Score         float32                  `json:"score"`
	Why           string                   `json:"why"`
	Features      retrieve.RankingFeatures `json:"features"`
	Hit           bool                     `json:"hit"`
}

type DiagnosticRow

type DiagnosticRow struct {
	QueryID        string                `json:"query_id"`
	Mode           string                `json:"mode"`
	Expected       []string              `json:"expected"`
	EffectiveAlpha float32               `json:"effective_alpha"`
	Candidates     []DiagnosticCandidate `json:"candidates"`
}

type GlobalSummary

type GlobalSummary struct {
	QueryCount int
	Vector     Summary
	Hybrid     Summary
}

func SummarizeGlobal

func SummarizeGlobal(projects []ProjectSummary) GlobalSummary

type Manifest

type Manifest struct {
	Projects []ManifestProject `json:"projects"`
}

func LoadManifest

func LoadManifest(path string) (Manifest, error)

type ManifestProject

type ManifestProject struct {
	Name             string `json:"name"`
	IndexPath        string `json:"index_path"`
	CasesPath        string `json:"cases_path"`
	CasesHoldoutPath string `json:"cases_holdout_path"`
}

type ProjectSummary

type ProjectSummary struct {
	Project    string
	QueryCount int
	Vector     Summary
	Hybrid     Summary
	AvgLatency time.Duration
}

func BuildProjectSummary

func BuildProjectSummary(project string, vector, hybrid []Result) ProjectSummary

type QueryCase

type QueryCase struct {
	ID       string   `json:"id"`
	Query    string   `json:"query"`
	Expected []string `json:"expected"`
	// MinHits is the minimum number of `Expected` symbols that must appear in
	// top-K for RecallAt5/RecallAt10 to be true. Default 1 (any-of semantics).
	// Used for multi-hop queries where we want "find 3 of 4 flow stages in top-5".
	MinHits int `json:"min_hits,omitempty"`
	// NotExpected lists symbols that are lexical/semantic traps. If any of these
	// appear in top-5, TrapsHit is incremented. Doesn't affect Recall directly,
	// reported as a separate precision-against-traps metric.
	NotExpected []string `json:"not_expected,omitempty"`
	// Category is informational: paraphrastic|multi-hop|intent-vs-def|negative|cross-language.
	Category string `json:"category,omitempty"`
	// Tags label eval slices (sibling-ambiguous, constructor, layer-conflict, ...).
	// Used for per-slice metric aggregation; a case may carry several tags.
	Tags []string `json:"tags,omitempty"`
}

func LoadCases

func LoadCases(path string) ([]QueryCase, error)

type Result

type Result struct {
	QueryID    string
	Mode       string
	Expected   []string
	TopK       []string
	Symbols    []retrieve.ScoredResult
	Hits       []int
	RecallAt5  bool
	RecallAt10 bool
	MRR        float64
	Latency    time.Duration
	Stats      retrieve.Stats
	// HitsAt5/HitsAt10: count of Expected symbols in top-K (for multi-hop scoring).
	HitsAt5  int
	HitsAt10 int
	// MinHits used for this case (0 means default 1 was applied).
	MinHits int
	// TrapsAt5: count of NotExpected symbols that appear in top-5.
	TrapsAt5 int
	// Tags copied from the QueryCase for per-slice aggregation.
	Tags []string
	// TotalTokens is the packed response size (information-per-token metric).
	TotalTokens int
}

func RunEval

func RunEval(ctx context.Context, retriever *retrieve.Retriever, cases []QueryCase, mode retrieve.Mode) []Result

func RunEvalAlpha

func RunEvalAlpha(ctx context.Context, retriever *retrieve.Retriever, cases []QueryCase, mode retrieve.Mode, alpha float32) []Result

func RunEvalAlphaRerankK

func RunEvalAlphaRerankK(ctx context.Context, retriever *retrieve.Retriever, cases []QueryCase, mode retrieve.Mode, alpha float32, rerankK int) []Result

func RunEvalAlphaRerankKAdaptive

func RunEvalAlphaRerankKAdaptive(ctx context.Context, retriever *retrieve.Retriever, cases []QueryCase, mode retrieve.Mode, alpha float32, rerankK int, adaptiveRerank bool) []Result

func RunEvalFull

func RunEvalFull(ctx context.Context, retriever *retrieve.Retriever, cases []QueryCase, mode retrieve.Mode, alpha float32, rerankK int, adaptiveRerank bool, skipRerank, skipIntent bool) []Result

func RunEvalFullDPP

func RunEvalFullDPP(ctx context.Context, retriever *retrieve.Retriever, cases []QueryCase, mode retrieve.Mode, alpha float32, rerankK int, adaptiveRerank bool, skipRerank, skipIntent bool, _ float32, _ bool, _ bool) []Result

func RunEvalFullWithAlphaSet

func RunEvalFullWithAlphaSet(ctx context.Context, retriever *retrieve.Retriever, cases []QueryCase, mode retrieve.Mode, alpha float32, alphaSet bool, rerankK int, adaptiveRerank bool, skipRerank, skipIntent bool, opts ...func(*retrieve.Request)) []Result

type Summary

type Summary struct {
	HitAt1     float64
	HitAt3     float64
	RecallAt5  float64
	RecallAt10 float64
	NDCGAt5    float64
	MRR        float64
}

func SummarizeDetailed

func SummarizeDetailed(results []Result) Summary

Jump to

Keyboard shortcuts

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