benchdata

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

Overview

Package benchdata loads BEIR-format retrieval benchmark data (the layout CORE-Bench ships: per-repo corpus.jsonl / queries.jsonl / qrels/test.tsv) and manages the on-disk embedding-matrix cache shared by cmd/corebench and cmd/ftdata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BM25Tokenize

func BM25Tokenize(s string) []string

func Dot

func Dot(a, b []float32) float32

Dot is the similarity between two L2-normalized vectors.

func LoadMatrix

func LoadMatrix(path string, count, dim int) ([]float32, bool)

LoadMatrix reads a cached row-major float32 embedding matrix written by SaveMatrix, validating the (count, dim) header against expectations.

func LoadQrels

func LoadQrels(path string) (map[string]map[string]int, error)

LoadQrels reads a BEIR qrels TSV (query-id, corpus-id, score header line).

func PeekMatrix

func PeekMatrix(path string) (count, dim int, ok bool)

PeekMatrix reads only the (count, dim) header, so callers can validate a cache without loading gigabytes.

func ReadJSONL

func ReadJSONL(path string, fn func([]byte) error) error

func Sanitize

func Sanitize(s string) string

Sanitize turns a repo key into a filesystem-safe cache-file stem.

func SaveMatrix

func SaveMatrix(path string, mat []float32, count, dim int) error

Types

type BM25Index

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

BM25Index is a small in-memory BM25 (k1=1.2, b=0.75) with the same tokenization idea as the store's FTS layer: runs of letters/digits/ underscore, lowercased. Used for seed fusion in corebench and for mining hard negatives in ftdata.

func NewBM25Index

func NewBM25Index(docs []CorpusDoc) *BM25Index

func (*BM25Index) Rank

func (b *BM25Index) Rank(query string, cand []int) []int

Rank scores the candidate rows for the query and returns them best-first.

type CorpusDoc

type CorpusDoc struct {
	ID   string `json:"_id"`
	Text string `json:"text"`
}

func LoadCorpus

func LoadCorpus(path string, maxChars int) ([]CorpusDoc, error)

type Query

type Query struct {
	ID   string `json:"_id"`
	Text string `json:"text"`
	// Filtered is the benchmark's temporal filter: the corpus ids that
	// existed at the query's repo snapshot. Empty = whole corpus eligible.
	Filtered []string `json:"filtered_corpus_id"`
}

func LoadQueries

func LoadQueries(path string, maxChars int) ([]Query, error)

Jump to

Keyboard shortcuts

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