Documentation
¶
Overview ¶
Package ir provides standard information-retrieval metrics for benchmark runners.
Index ¶
- func ReadDocuments(reader io.Reader, visit func(Document) error) error
- func ReadRun(reader io.Reader) (map[string][]string, error)
- func SelectQueryIDs(queryIDs []string, limit int, seed uint64) ([]string, error)
- func WriteRun(writer io.Writer, queryID string, results []RunResult, tag string) error
- type Comparison
- type Document
- type DocumentSink
- type IngestStats
- type Interval
- type Metrics
- type NodeIndexer
- type NornicDocumentSink
- type NornicRetriever
- type Qrels
- type Query
- type QueryEmbedder
- type QueryManifest
- type Retriever
- type RunResult
- type RunStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadDocuments ¶
ReadDocuments streams official BEIR corpus.jsonl entries to visit.
func SelectQueryIDs ¶
SelectQueryIDs chooses at most limit unique query IDs without replacement. It sorts the input before sampling so output is independent of ingestion order.
Types ¶
type Comparison ¶
type Comparison struct {
Queries int `json:"queries"`
Baseline Metrics `json:"baseline"`
Candidate Metrics `json:"candidate"`
AbsoluteDelta Metrics `json:"absolute_delta"`
RecallAt10CI Interval `json:"recall_at_10_ci_95"`
RecallAt100CI Interval `json:"recall_at_100_ci_95"`
NDCGAt10CI Interval `json:"ndcg_at_10_ci_95"`
}
Comparison is a paired evaluation of candidate results against a baseline.
type Document ¶
type Document struct {
ID string `json:"_id"`
Title string `json:"title"`
Text string `json:"text"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Document is the logical BEIR corpus retrieval unit.
type DocumentSink ¶
DocumentSink accepts a BEIR document while preserving its retrieval identity.
type IngestStats ¶
type IngestStats struct {
Documents int64
}
IngestStats reports the number of corpus documents accepted by a sink.
func IngestDocuments ¶
func IngestDocuments(ctx context.Context, reader io.Reader, sink DocumentSink) (IngestStats, error)
IngestDocuments streams corpus.jsonl into sink without retaining the corpus in memory. The sink is responsible for transactional batching and index life cycle.
type Metrics ¶
type Metrics struct {
RecallAt10 float64 `json:"recall_at_10"`
RecallAt100 float64 `json:"recall_at_100"`
NDCGAt10 float64 `json:"ndcg_at_10"`
MRRAt10 float64 `json:"mrr_at_10"`
MAPAt100 float64 `json:"map_at_100"`
}
Metrics is the standard metric set used by retrieval benchmarks.
type NodeIndexer ¶
NodeIndexer is the search index operation required after a benchmark write.
type NornicDocumentSink ¶
type NornicDocumentSink struct {
Engine storage.Engine
Indexer NodeIndexer
}
NornicDocumentSink imports one BEIR document as one NornicDB retrieval unit. The beir_id property is the lossless persistent map when storage namespaces rewrite the physical node ID.
func (*NornicDocumentSink) StoreDocument ¶
func (s *NornicDocumentSink) StoreDocument(ctx context.Context, document Document) error
StoreDocument persists and indexes a BEIR document with its original ID.
type NornicRetriever ¶
type NornicRetriever struct {
Service *search.Service
Embedder QueryEmbedder
Options *search.SearchOptions
}
NornicRetriever adapts the existing search service to the benchmark retriever. A nil Embedder intentionally executes BM25-only retrieval.
type Query ¶
type Query struct {
ID string `json:"_id"`
Text string `json:"text"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Query is an official BEIR query.
func FilterQueriesWithQrels ¶
FilterQueriesWithQrels retains only queries that have relevance judgments.
type QueryEmbedder ¶
QueryEmbedder produces a query embedding for vector and hybrid benchmark variants.
type QueryManifest ¶
type QueryManifest struct {
Dataset string `json:"dataset"`
Split string `json:"split"`
Seed uint64 `json:"seed"`
QueryIDs []string `json:"query_ids"`
SHA256 string `json:"sha256"`
}
QueryManifest records the exact query subset shared by all benchmark variants.
func NewQueryManifest ¶
func NewQueryManifest(dataset, split string, queries []Query, limit int, seed uint64) (QueryManifest, error)
NewQueryManifest deterministically selects query IDs and records their digest.
type RunResult ¶
RunResult is one ranked retrieval result expressed with its BEIR document ID.
func RunResultsFromSearchResults ¶
func RunResultsFromSearchResults(results []search.SearchResult) ([]RunResult, error)
RunResultsFromSearchResults converts hydrated NornicDB results into evaluation-facing BEIR IDs. Every benchmark result must carry beir_id.
type RunStats ¶
type RunStats struct {
Queries int64
}
RunStats reports one manifest-driven retrieval execution.
func RunManifest ¶
func RunManifest(ctx context.Context, manifest QueryManifest, queries []Query, retriever Retriever, topK int, tag string, writer io.Writer) (RunStats, error)
RunManifest executes only the query IDs in manifest and writes a TREC run in manifest order. Queries must contain every selected official query ID.