Files
wehub-resource-sync a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

50 lines
1.5 KiB
Go

// Package stdbench loads standardized code-retrieval benchmarks —
// CoIR, SWE-ContextBench, and ContextBench — into a single normalized
// {corpus, queries, qrels} model and scores a retriever against them
// with the textbook Recall@K / Precision@K / NDCG@K / MRR metrics.
//
// The loaders parse the on-disk formats; the actual retrieval is left
// to the caller (the `gortex eval stdbench` verb wires Gortex's BM25
// backend in), so the same harness measures whatever retriever is
// handed to Evaluate.
package stdbench
// Doc is one corpus document — a code snippet, file, or symbol the
// retriever ranks. ID is the identifier the benchmark's relevance
// judgements reference.
type Doc struct {
ID string
Text string
}
// Query is one benchmark query plus its graded relevance judgements.
// Relevant maps a corpus Doc.ID to its relevance grade: 1 means
// relevant, higher grades mean more relevant (CoIR / BEIR qrels carry
// graded labels; the JSONL task benchmarks default every gold ID to
// grade 1).
type Query struct {
ID string
Text string
Relevant map[string]int
}
// Dataset is a loaded benchmark: a corpus to index plus the queries to
// run against it.
type Dataset struct {
Name string
Corpus []Doc
Queries []Query
}
// RelevantCount returns the number of queries that carry at least one
// relevance judgement — the denominator Evaluate averages over.
func (d Dataset) RelevantCount() int {
n := 0
for _, q := range d.Queries {
if len(q.Relevant) > 0 {
n++
}
}
return n
}