annbakeoff

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package annbakeoff evaluates a candidate ANN payload without making it part of dbrain's serving or cache lifecycle.

Index

Constants

View Source
const (
	SchemaVersion = "dbrain.semantic-ann-bakeoff.v1"

	StatusPassed   = "passed"
	StatusRejected = "rejected"

	ReasonHeapLimit   = "heap_system_limit_exceeded"
	ReasonRecallFloor = "recall_floor_not_met"
)
View Source
const BackendHNSW = "hnsw"

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory func(Options) (Index, error)

Factory creates one empty candidate index for a screening stage.

type HNSW

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

HNSW is the narrow backend adapter used by the segmented-index bakeoff. It owns no files and is not a serving Searcher.

func NewHNSW

func NewHNSW(opts HNSWOptions) (*HNSW, error)

func (*HNSW) Add

func (h *HNSW) Add(nodes ...HNSWNode) error

func (*HNSW) Close

func (h *HNSW) Close() error

Close is a no-op because this adapter owns only Go-managed in-memory state.

func (*HNSW) Export

func (h *HNSW) Export(w io.Writer) error

func (*HNSW) Import

func (h *HNSW) Import(r io.Reader) error

func (*HNSW) Reserve

func (h *HNSW) Reserve(int) error

Reserve is a no-op because coder/hnsw grows its graph as nodes are added. It preserves the candidate-index contract used by the content-free bakeoff.

func (*HNSW) Search

func (h *HNSW) Search(query []float32, limit int) ([]HNSWHit, error)

type HNSWHit

type HNSWHit = semanticindex.HNSWHit

type HNSWNode

type HNSWNode = semanticindex.HNSWNode

type HNSWOptions

type HNSWOptions struct {
	Dimensions int
	Seed       uint64
	M          int
	EfSearch   int
}

HNSWOptions configure one in-memory HNSW graph. Segment persistence and publication remain the caller's responsibility.

type Index

type Index interface {
	Reserve(int) error
	Add(...semanticindex.HNSWNode) error
	Search([]float32, int) ([]semanticindex.HNSWHit, error)
	Export(io.Writer) error
	Import(io.Reader) error
	Close() error
}

Index is the narrow candidate contract used only by the content-free ANN bakeoff. It deliberately contains no SQLite, segment, or serving behavior.

type Options

type Options struct {
	Sizes           []int
	Dimensions      int
	QueryCount      int
	WarmRepetitions int
	Seed            uint64
	RecallAt        int
	MinimumRecall   float64
	MaxHeapSysBytes uint64
	EfSearch        int
	M               int
	Connectivity    int
	ExpansionAdd    int
	ExpansionSearch int
}

Options bounds one deterministic candidate screening run.

type Report

type Report struct {
	SchemaVersion string         `json:"schema_version"`
	Backend       string         `json:"backend"`
	Dimensions    int            `json:"dimensions"`
	Seed          uint64         `json:"seed"`
	RecallAt      int            `json:"recall_at"`
	MinimumRecall float64        `json:"minimum_recall"`
	EfSearch      int            `json:"ef_search,omitempty"`
	M             int            `json:"m,omitempty"`
	Parameters    map[string]int `json:"parameters"`
	Status        string         `json:"status"`
	Stages        []StageReport  `json:"stages"`
}

Report contains content-free evidence for a single backend screening run.

func Run

func Run(ctx context.Context, opts Options) (Report, error)

Run builds every requested stage in order. Gate failures are reported in the returned report rather than becoming opaque errors, allowing callers to save the exact evidence before stopping the next stage.

func RunWith

func RunWith(ctx context.Context, opts Options, backend string, parameters map[string]int, factory Factory) (Report, error)

RunWith evaluates one named candidate against the deterministic corpus and exact oracle. Candidate errors are returned; gate failures stay in Report so callers can persist the evidence before stopping.

type StageReport

type StageReport struct {
	VectorCount      int            `json:"vector_count"`
	EfSearch         int            `json:"ef_search,omitempty"`
	M                int            `json:"m,omitempty"`
	Parameters       map[string]int `json:"parameters"`
	Status           string         `json:"status"`
	Reason           string         `json:"reason,omitempty"`
	CorpusBuildNanos int64          `json:"corpus_build_nanos"`
	GraphBuildNanos  int64          `json:"graph_build_nanos"`
	ExportNanos      int64          `json:"export_nanos"`
	ReopenNanos      int64          `json:"reopen_nanos"`
	ExactQueryNanos  int64          `json:"exact_query_nanos"`
	QueryP50Nanos    int64          `json:"query_p50_nanos"`
	QueryP95Nanos    int64          `json:"query_p95_nanos"`
	PayloadBytes     int            `json:"payload_bytes"`
	RecallAtK        float64        `json:"recall_at_k"`
	ReopenRecallAtK  float64        `json:"reopen_recall_at_k"`
	BuildHeapAlloc   uint64         `json:"build_heap_alloc_bytes"`
	BuildHeapSys     uint64         `json:"build_heap_sys_bytes"`
	LoadedHeapAlloc  uint64         `json:"loaded_heap_alloc_bytes"`
	LoadedHeapSys    uint64         `json:"loaded_heap_sys_bytes"`
}

StageReport records one vector-count stage. Durations are nanoseconds so a downstream report can derive milliseconds without losing short query times.

Jump to

Keyboard shortcuts

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