Documentation ¶
Index ¶
- type CompressedDocument
- type CompressedVectorStore
- type Compressor
- type DummyCompressor
- type GzipCompressor
- type Heap
- type MemoryVectorStore
- func (m *MemoryVectorStore) Insert(ctx context.Context, d gollum.Document) error
- func (m *MemoryVectorStore) Persist(ctx context.Context, bucket *blob.Bucket, path string) error
- func (m *MemoryVectorStore) Query(ctx context.Context, qb QueryRequest) ([]*gollum.Document, error)
- func (m *MemoryVectorStore) RetrieveAll(ctx context.Context) ([]gollum.Document, error)
- type NodeSimilarity
- type QueryRequest
- type StdGzipCompressor
- type VectorStore
- type ZstdCompressor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompressedDocument ¶
type CompressedVectorStore ¶
type CompressedVectorStore struct { Data []CompressedDocument Compressor Compressor }
func NewDummyVectorStore ¶
func NewDummyVectorStore() *CompressedVectorStore
func NewGzipVectorStore ¶
func NewGzipVectorStore() *CompressedVectorStore
func NewStdGzipVectorStore ¶
func NewStdGzipVectorStore() *CompressedVectorStore
func NewZstdVectorStore ¶
func NewZstdVectorStore() *CompressedVectorStore
func (*CompressedVectorStore) Insert ¶
Insert compresses the document and inserts it into the store. An alternative implementation would ONLY store the compressed representation and decompress as necessary.
func (*CompressedVectorStore) Query ¶
func (cvs *CompressedVectorStore) Query(ctx context.Context, qb QueryRequest) ([]*gollum.Document, error)
func (*CompressedVectorStore) RetrieveAll ¶
type Compressor ¶
Compressor is a single method interface that returns a compressed representation of an object.
type DummyCompressor ¶
type DummyCompressor struct { }
func (*DummyCompressor) Compress ¶
func (g *DummyCompressor) Compress(src []byte) []byte
type GzipCompressor ¶
type GzipCompressor struct {
// contains filtered or unexported fields
}
GzipCompressor uses the klauspost/compress gzip compressor. We generally suggest using this optimized implementation over the stdlib.
func (*GzipCompressor) Compress ¶
func (g *GzipCompressor) Compress(src []byte) []byte
type Heap ¶
type Heap []NodeSimilarity
Heap is a custom heap implementation, to avoid interface{} conversion. I _think_ theoretically that a memory arena would be useful here, but that feels a bit beyond the pale, even for me. In benchmarking, we see that allocations are limited by scale according to k -- since K is known, we should be able to allocate a fixed-size arena and use that. That being said... let's revisit in the future :)
func (*Heap) Pop ¶
func (h *Heap) Pop() NodeSimilarity
func (*Heap) Push ¶
func (h *Heap) Push(e NodeSimilarity)
type MemoryVectorStore ¶
MemoryVectorStore embeds documents on insert and stores them in memory
func NewMemoryVectorStore ¶
func NewMemoryVectorStore(llm gollum.Embedder) *MemoryVectorStore
func (*MemoryVectorStore) Query ¶
func (m *MemoryVectorStore) Query(ctx context.Context, qb QueryRequest) ([]*gollum.Document, error)
func (*MemoryVectorStore) RetrieveAll ¶
RetrieveAll returns all documents
type NodeSimilarity ¶
type QueryRequest ¶
type QueryRequest struct { // Query is the text to query Query string // EmbeddingStrings is a list of strings to concatenate and embed instead of Query EmbeddingStrings []string // EmbeddingFloats is a query vector to use instead of Query EmbeddingFloats []float32 // K is the number of results to return K int }
QueryRequest is a struct that contains the query and optional query strings or embeddings
type StdGzipCompressor ¶
type StdGzipCompressor struct {
// contains filtered or unexported fields
}
StdGzipCompressor uses the std gzip compressor.
func (*StdGzipCompressor) Compress ¶
func (g *StdGzipCompressor) Compress(src []byte) []byte
type VectorStore ¶
type ZstdCompressor ¶
type ZstdCompressor struct {
// contains filtered or unexported fields
}
ZstdCompressor uses the klauspost/compress zstd compressor.
func (*ZstdCompressor) Compress ¶
func (g *ZstdCompressor) Compress(src []byte) []byte