indexing

package
v0.0.0-...-7b96089 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document interface {
	// ID returns the unique ID for the document.
	ID() string

	// Content returns the content of the document.
	Content() string
}

Document represents a single document.

type Index

type Index[K comparable] interface {
	ReadOnlyIndex[K]

	Add(key K, value ...llm.Embedding) error
	Remove(key K) bool
}

type IndexEntry

type IndexEntry[K comparable] struct {
	// DocumentID is the unique ID for the document.
	DocumentID K
	// IndexID is the unique ID for the index.
	IndexID int64
	// ChunkIndex is the index of the chunk in the document.
	ChunkIndex int
	// ChunkCount is the total number of chunks in the document.
	ChunkCount int
	// Embedding is the embedding for the chunk.
	Embedding llm.Embedding
	// Valid indicates whether the entry is valid or not.
	Valid bool
}

IndexEntry represents a single entry in the index.

type ReadOnlyIndex

type ReadOnlyIndex[K comparable] interface {
	Query(q llm.Embedding, k int64) ([]SearchHit[K], error)
}

type SearchHit

type SearchHit[K comparable] struct {
	IndexEntry[K]

	// Distance is the distance between the query and the document.
	Distance float32
}

SearchHit represents a single search hit.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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