lib

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NDCG

func NDCG(relevances map[int]float64, predicted []int, k int) float64

NDCG computes Normalized Discounted Cumulative Gain at K. relevances maps doc ID to relevance score (higher = more relevant). predicted is the ordered list of predicted doc IDs.

func NDCGAtK

func NDCGAtK(goldRelevances []map[int]float64, predicted [][]int, k int) float64

NDCGAtK computes NDCG@K for multiple queries. goldRelevances[i] is the relevance map for query i. predicted[i] is the predicted ranking for query i.

Types

type EvalConfig

type EvalConfig struct {
	K          int
	NumQueries int
	Warmup     int
}

EvalConfig captures basic evaluation knobs.

type EvalGPUResult

type EvalGPUResult struct {
	K, NumQueries int
	P50SearchMs   float64
	P95SearchMs   float64
	P50EndToEndMs float64
	P95EndToEndMs float64
	QPS           float64
	RecallAtK     float64
}

func RunEvalGPU

func RunEvalGPU(model *gobed.EmbeddingModel, docs []gobed.Document, base EvalConfig, graph gobed.GPUCagraConfig) (EvalGPUResult, error)

type EvalResult

type EvalResult struct {
	K            int
	NumQueries   int
	P50LatencyMs float64
	P95LatencyMs float64
	QPS          float64
	RecallAtK    float64
	NDCGAtK      float64
}

EvalResult summarizes latency and recall metrics.

func RunEval

func RunEval(model *gobed.EmbeddingModel, docs []gobed.Document, cfg EvalConfig) (EvalResult, error)

RunEval builds an index with provided documents, then evaluates search latency and recall@K against a brute-force baseline on CPU. Embeddings are computed once for the baseline/queries.

type FSIndexer

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

FSIndexer indexes a filesystem tree into a VectorIndex.

func NewFSIndexer

func NewFSIndexer(root string, model *gobed.EmbeddingModel, cfg gobed.VectorIndexConfig) (*FSIndexer, error)

NewFSIndexer creates a filesystem indexer with a fresh VectorIndex.

func (*FSIndexer) CreatedAt

func (f *FSIndexer) CreatedAt() time.Time

CreatedAt returns now for simple logging; reserved for future persistent state.

func (*FSIndexer) Index

func (f *FSIndexer) Index() *gobed.VectorIndex

Index exposes the underlying vector index (read-only usage recommended).

func (*FSIndexer) IndexAll

func (f *FSIndexer) IndexAll() (int, error)

IndexAll walks the root and indexes supported text files. It chunks files into paragraphs (blank-line separated) to improve recall.

func (*FSIndexer) Reindex

func (f *FSIndexer) Reindex() (int, error)

Reindex updates changed files (mtime-based). For now, rebuilds entries per changed file.

func (*FSIndexer) Root

func (f *FSIndexer) Root() string

Root returns the root path of the indexer.

type FileDoc

type FileDoc struct {
	ID      int
	Path    string
	Offset  int // byte offset in file
	Length  int // bytes
	Text    string
	ModTime int64 // file mtime unix
}

FileDoc represents a chunk of a file indexed as a document.

Jump to

Keyboard shortcuts

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