retrieval

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 16 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

Index

Constants

View Source
const (
	PayloadPrivacyFull     = "full-text"
	PayloadPrivacyRedacted = "redacted-checksum"
)
View Source
const OpenSearchMappingVersion = "opensearch-passages-v1"

Variables

This section is empty.

Functions

func ValidateEmbeddingProviderCompliance

func ValidateEmbeddingProviderCompliance(providerName string, consent bool, config map[string]string) error

Types

type DeterministicEmbedding

type DeterministicEmbedding struct{ Dimensions int }

DeterministicEmbedding is a local, dependency-free embedding scaffold for tests and offline workflows.

func (DeterministicEmbedding) Embed

func (d DeterministicEmbedding) Embed(text string) ([]float64, error)

func (DeterministicEmbedding) EmbeddingBackendName

func (d DeterministicEmbedding) EmbeddingBackendName() string

type EmbeddingAdapter

type EmbeddingAdapter interface{ EmbeddingBackendName() string }

EmbeddingAdapter is the optional embedding-provider seam.

type EmbeddingComplianceProfile

type EmbeddingComplianceProfile struct {
	TextEgress       string `json:"textEgress"`
	RequiresConsent  bool   `json:"requiresConsent"`
	RequiredConfig   string `json:"requiredConfig"`
	ModelVersionLock string `json:"modelVersionLock"`
	Dimensionality   string `json:"dimensionality"`
	RetentionPolicy  string `json:"retentionPolicy"`
	Redaction        string `json:"redaction"`
}

type EmbeddingModel

type EmbeddingModel interface {
	EmbeddingBackendName() string
	Embed(string) ([]float64, error)
}

EmbeddingModel embeds passage/query text for vector retrieval.

type EmbeddingProvider

type EmbeddingProvider struct {
	Name                         string                     `json:"name"`
	ModelID                      string                     `json:"modelId"`
	ProviderKind                 string                     `json:"providerKind"`
	Dimensions                   int                        `json:"dimensions"`
	LicenseNotes                 string                     `json:"licenseNotes"`
	VectorIndexInvalidation      string                     `json:"vectorIndexInvalidation"`
	RetrievalBenchmarkCompatible bool                       `json:"retrievalBenchmarkCompatible"`
	Compliance                   EmbeddingComplianceProfile `json:"compliance"`
}

type EmbeddingProviderRegistry

type EmbeddingProviderRegistry struct {
	SchemaVersion string              `json:"schemaVersion"`
	Providers     []EmbeddingProvider `json:"providers"`
}

func DefaultEmbeddingProviderRegistry

func DefaultEmbeddingProviderRegistry() EmbeddingProviderRegistry

func (EmbeddingProviderRegistry) Provider

type HTTPEmbedding

type HTTPEmbedding struct {
	Endpoint string
	Model    string
	Client   *http.Client
}

HTTPEmbedding calls an opt-in local embedding service for passage/query vectors.

func (HTTPEmbedding) Embed

func (h HTTPEmbedding) Embed(text string) ([]float64, error)

func (HTTPEmbedding) EmbeddingBackendName

func (h HTTPEmbedding) EmbeddingBackendName() string

type HybridIndex

type HybridIndex struct {
	Lexical SearchAdapter
	Vector  SearchAdapter
	RRFK    float64
}

HybridIndex combines lexical and vector retrieval results with deterministic de-duplication.

func (HybridIndex) Close

func (h HybridIndex) Close() error

Close closes both backing indexes.

func (HybridIndex) Rebuild

func (h HybridIndex) Rebuild(docs []parsing.ParsedDocument) error

Rebuild updates both backing indexes.

func (HybridIndex) Retrieve

func (h HybridIndex) Retrieve(query string) ([]PassageResult, error)

Retrieve returns reciprocal-rank-fused lexical/vector hits with deterministic de-duplication.

type HybridTuningCandidate

type HybridTuningCandidate struct {
	Name           string             `json:"name"`
	LexicalWeight  float64            `json:"lexicalWeight"`
	VectorWeight   float64            `json:"vectorWeight"`
	BackendWeights map[string]float64 `json:"backendWeights"`
	RRFK           float64            `json:"rrfK"`
}

func DefaultHybridTuningCandidates

func DefaultHybridTuningCandidates() []HybridTuningCandidate

type HybridTuningEvaluation

type HybridTuningEvaluation struct {
	CandidateName  string             `json:"candidateName"`
	LexicalWeight  float64            `json:"lexicalWeight"`
	VectorWeight   float64            `json:"vectorWeight"`
	BackendWeights map[string]float64 `json:"backendWeights"`
	RecallAtK      float64            `json:"recallAtK"`
	MRR            float64            `json:"mrr"`
	Score          float64            `json:"score"`
}

type HybridTuningFile

type HybridTuningFile struct {
	SchemaVersion         string                   `json:"schemaVersion"`
	CalibrationMethod     string                   `json:"calibrationMethod"`
	QuerySetChecksum      string                   `json:"querySetChecksum"`
	QueryCount            int                      `json:"queryCount"`
	K                     int                      `json:"k"`
	Candidates            []HybridTuningCandidate  `json:"candidates"`
	Evaluations           []HybridTuningEvaluation `json:"evaluations"`
	SelectedConfiguration HybridTuningCandidate    `json:"selectedConfiguration"`
	ReproducibilityNotes  []string                 `json:"reproducibilityNotes"`
}

func CalibrateHybridRetrieval

func CalibrateHybridRetrieval(queries []HybridTuningQuery, lexical, vector map[string][]PassageResult, candidates []HybridTuningCandidate, k int) (HybridTuningFile, error)

type HybridTuningQuery

type HybridTuningQuery struct {
	ID                 string   `json:"id"`
	Query              string   `json:"query"`
	RelevantPassageIDs []string `json:"relevantPassageIds"`
}

type NoopEmbeddingAdapter

type NoopEmbeddingAdapter struct{}

NoopEmbeddingAdapter reserves the optional embeddings seam without requiring a provider.

func (NoopEmbeddingAdapter) EmbeddingBackendName

func (NoopEmbeddingAdapter) EmbeddingBackendName() string

type NoopVectorAdapter

type NoopVectorAdapter struct{}

NoopVectorAdapter reserves the optional Qdrant seam without requiring the service.

func (NoopVectorAdapter) VectorBackendName

func (NoopVectorAdapter) VectorBackendName() string

type OpenSearchBulkFailure

type OpenSearchBulkFailure struct {
	DocumentID string `json:"documentId"`
	Status     int    `json:"status"`
	Type       string `json:"type,omitempty"`
	Reason     string `json:"reason,omitempty"`
}

type OpenSearchBulkReport

type OpenSearchBulkReport struct {
	SchemaVersion  string                  `json:"schemaVersion"`
	Backend        string                  `json:"backend"`
	Index          string                  `json:"index"`
	MappingVersion string                  `json:"mappingVersion"`
	Attempted      int                     `json:"attempted"`
	Indexed        int                     `json:"indexed"`
	Failed         int                     `json:"failed"`
	Failures       []OpenSearchBulkFailure `json:"failures,omitempty"`
}

type OpenSearchIndex

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

OpenSearchIndex is an optional passage search adapter backed by OpenSearch.

func NewOpenSearchIndex

func NewOpenSearchIndex(options OpenSearchOptions) (*OpenSearchIndex, error)

NewOpenSearchIndex creates an OpenSearch passage index adapter.

func (*OpenSearchIndex) Close

func (o *OpenSearchIndex) Close() error

Close closes adapter resources. The HTTP client has no persistent resource to close.

func (*OpenSearchIndex) Rebuild

func (o *OpenSearchIndex) Rebuild(docs []parsing.ParsedDocument) error

Rebuild bulk-indexes parsed passages into OpenSearch.

func (*OpenSearchIndex) RebuildWithReport

func (o *OpenSearchIndex) RebuildWithReport(docs []parsing.ParsedDocument) (OpenSearchBulkReport, error)

RebuildWithReport bulk-indexes parsed passages and records partial-failure provenance.

func (*OpenSearchIndex) Retrieve

func (o *OpenSearchIndex) Retrieve(query string) ([]PassageResult, error)

Retrieve searches OpenSearch for matching passages.

type OpenSearchOptions

type OpenSearchOptions struct {
	BaseURL string
	Index   string
	Timeout time.Duration
}

OpenSearchOptions configures the optional OpenSearch adapter.

type PassageResult

type PassageResult struct {
	PaperID    string
	SectionID  string
	PassageID  string
	Text       string
	Highlights []string `json:"Highlights,omitempty"`
}

PassageResult is one full-text retrieval hit.

type QdrantIndex

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

QdrantIndex is an optional passage vector retrieval adapter backed by Qdrant.

func NewQdrantIndex

func NewQdrantIndex(options QdrantOptions) (*QdrantIndex, error)

func (*QdrantIndex) Close

func (q *QdrantIndex) Close() error

func (*QdrantIndex) Rebuild

func (q *QdrantIndex) Rebuild(docs []parsing.ParsedDocument) error

Rebuild upserts parsed passages into Qdrant with deterministic point IDs.

func (*QdrantIndex) RebuildWithReport

func (q *QdrantIndex) RebuildWithReport(docs []parsing.ParsedDocument) (QdrantRebuildReport, error)

func (*QdrantIndex) Retrieve

func (q *QdrantIndex) Retrieve(query string) ([]PassageResult, error)

Retrieve searches Qdrant by embedded query vector.

func (*QdrantIndex) VectorBackendName

func (q *QdrantIndex) VectorBackendName() string

type QdrantOptions

type QdrantOptions struct {
	BaseURL                string
	Collection             string
	Timeout                time.Duration
	Embeddings             EmbeddingModel
	PayloadPrivacy         string
	InvalidateBeforeUpsert bool
}

QdrantOptions configures the optional Qdrant adapter.

type QdrantRebuildReport

type QdrantRebuildReport struct {
	SchemaVersion           string `json:"schemaVersion"`
	Backend                 string `json:"backend"`
	Collection              string `json:"collection"`
	EmbeddingProvider       string `json:"embeddingProvider"`
	Dimension               int    `json:"dimension"`
	PayloadPrivacy          string `json:"payloadPrivacy"`
	InvalidatedBeforeUpsert bool   `json:"invalidatedBeforeUpsert"`
	Attempted               int    `json:"attempted"`
	Indexed                 int    `json:"indexed"`
	TextEgress              string `json:"textEgress"`
}

type RetrievalBackendBenchmark

type RetrievalBackendBenchmark struct {
	Backend             string  `json:"backend"`
	RecallAtK           float64 `json:"recallAtK"`
	MRR                 float64 `json:"mrr"`
	Score               float64 `json:"score"`
	ReproducibilityNote string  `json:"reproducibilityNote,omitempty"`
	PrivacyNote         string  `json:"privacyNote,omitempty"`
}

type RetrievalBenchmarkFixture

type RetrievalBenchmarkFixture struct {
	SchemaVersion  string                                `json:"schemaVersion"`
	FixtureID      string                                `json:"fixtureId,omitempty"`
	Queries        []HybridTuningQuery                   `json:"queries"`
	BackendResults map[string]map[string][]PassageResult `json:"backendResults"`
}

func DefaultRetrievalBenchmarkFixture

func DefaultRetrievalBenchmarkFixture() RetrievalBenchmarkFixture

type RetrievalBenchmarkQueryResult

type RetrievalBenchmarkQueryResult struct {
	QueryID string                    `json:"queryId"`
	Backend string                    `json:"backend"`
	TopK    []string                  `json:"topK"`
	Metrics RetrievalBackendBenchmark `json:"metrics"`
}

type RetrievalBenchmarkReport

type RetrievalBenchmarkReport struct {
	SchemaVersion        string                          `json:"schemaVersion"`
	FixtureID            string                          `json:"fixtureId"`
	QuerySetChecksum     string                          `json:"querySetChecksum"`
	QueryCount           int                             `json:"queryCount"`
	K                    int                             `json:"k"`
	Backends             []RetrievalBackendBenchmark     `json:"backends"`
	SelectedBackend      string                          `json:"selectedBackend"`
	QueryResults         []RetrievalBenchmarkQueryResult `json:"queryResults"`
	ReproducibilityNotes []string                        `json:"reproducibilityNotes"`
	PrivacyNotes         []string                        `json:"privacyNotes"`
}

func RunRetrievalBenchmark

func RunRetrievalBenchmark(fixture RetrievalBenchmarkFixture, k int) (RetrievalBenchmarkReport, error)

type SQLiteIndex

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

SQLiteIndex stores parsed passages in a local SQLite FTS index.

func OpenSQLiteIndex

func OpenSQLiteIndex(path string) (*SQLiteIndex, error)

OpenSQLiteIndex opens a local SQLite FTS passage index.

func (*SQLiteIndex) Close

func (i *SQLiteIndex) Close() error

Close closes the SQLite index.

func (*SQLiteIndex) Rebuild

func (i *SQLiteIndex) Rebuild(docs []parsing.ParsedDocument) error

Rebuild replaces all indexed parsed passages.

func (*SQLiteIndex) Retrieve

func (i *SQLiteIndex) Retrieve(query string) ([]PassageResult, error)

Retrieve returns passages matching a full-text query.

type SearchAdapter

type SearchAdapter interface {
	Rebuild([]parsing.ParsedDocument) error
	Retrieve(string) ([]PassageResult, error)
	Close() error
}

SearchAdapter is the passage retrieval seam for local and optional search backends.

type VectorAdapter

type VectorAdapter interface{ VectorBackendName() string }

VectorAdapter is the optional vector-store seam for future Qdrant integration.

Jump to

Keyboard shortcuts

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