rag

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArtifactKey

func ArtifactKey(corpusID, fileID string) string

ArtifactKey builds the deterministic artifact key for a file within a corpus, matching what Ingest uses internally when FileID is set. Exported so callers (e.g. a delete-by-file tool) can reconstruct it without duplicating the format.

func ChunkEnrichmentCacheKey

func ChunkEnrichmentCacheKey(chunkText, enricherKey string) string

ChunkEnrichmentCacheKey builds the deterministic cache key for a chunk's enrichment result, mirroring DocumentChunkCacheKey's shape.

func DocumentChunkCacheKey

func DocumentChunkCacheKey(doc Document, chunkerKey string) string

func DocumentReaderChunkOptionsForProfile

func DocumentReaderChunkOptionsForProfile(profile ChunkProfile, opts documentreader.ChunkOptions) documentreader.ChunkOptions

DocumentReaderChunkOptionsForProfile maps a RAG chunk profile to hybrid document-reader chunk options while preserving caller-provided structural options.

Types

type ArtifactChunkCache

type ArtifactChunkCache struct {
	Store  storage.ArtifactStore
	Prefix string
}

ArtifactChunkCache persists cached chunks in the configured artifact store.

func NewArtifactChunkCache

func NewArtifactChunkCache(store storage.ArtifactStore) *ArtifactChunkCache

func (*ArtifactChunkCache) GetChunks

func (c *ArtifactChunkCache) GetChunks(ctx context.Context, key string) ([]Chunk, bool, error)

func (*ArtifactChunkCache) PutChunks

func (c *ArtifactChunkCache) PutChunks(ctx context.Context, key string, chunks []Chunk) error

type ArtifactEnrichmentCache

type ArtifactEnrichmentCache struct {
	Store  storage.ArtifactStore
	Prefix string
}

ArtifactEnrichmentCache persists cached enrichment results in the configured artifact store.

func NewArtifactEnrichmentCache

func NewArtifactEnrichmentCache(store storage.ArtifactStore) *ArtifactEnrichmentCache

func (*ArtifactEnrichmentCache) GetEnrichment

func (c *ArtifactEnrichmentCache) GetEnrichment(ctx context.Context, key string) ([]string, bool, error)

func (*ArtifactEnrichmentCache) PutEnrichment

func (c *ArtifactEnrichmentCache) PutEnrichment(ctx context.Context, key string, questions []string) error

type CachedDocumentChunker

type CachedDocumentChunker struct {
	Chunker DocumentChunker
	Cache   ChunkCache
}

CachedDocumentChunker wraps a DocumentChunker with a deterministic cache.

The cache key includes document bytes/text, filename, the cache schema version, and the wrapped chunker's option fingerprint when available.

func NewCachedDocumentChunker

func NewCachedDocumentChunker(chunker DocumentChunker, cache ChunkCache) *CachedDocumentChunker

func (*CachedDocumentChunker) Split

func (c *CachedDocumentChunker) Split(ctx context.Context, text string) ([]Chunk, error)

func (*CachedDocumentChunker) SplitDocument

func (c *CachedDocumentChunker) SplitDocument(ctx context.Context, doc Document) ([]Chunk, error)

type CachedEnricher

type CachedEnricher struct {
	Enricher Enricher
	Cache    EnrichmentCache
}

CachedEnricher wraps an Enricher with a deterministic cache, keyed by chunk text plus the wrapped enricher's option fingerprint when available.

func NewCachedEnricher

func NewCachedEnricher(enricher Enricher, cache EnrichmentCache) *CachedEnricher

func (*CachedEnricher) EnrichChunks

func (c *CachedEnricher) EnrichChunks(ctx context.Context, texts []string) ([][]string, error)

type Chunk

type Chunk struct {
	Key      string
	Text     string
	Position int
	Metadata map[string]string
}

type ChunkCache

type ChunkCache interface {
	GetChunks(ctx context.Context, key string) ([]Chunk, bool, error)
	PutChunks(ctx context.Context, key string, chunks []Chunk) error
}

ChunkCache stores document-aware chunking outputs under a deterministic key.

type ChunkCacheKeyProvider

type ChunkCacheKeyProvider interface {
	ChunkCacheKey() string
}

ChunkCacheKeyProvider lets chunkers include their own options in cache keys.

type ChunkProfile

type ChunkProfile struct {
	Name          ChunkProfileName `json:"name"`
	MaxTokens     int              `json:"max_tokens"`
	OverlapTokens int              `json:"overlap_tokens,omitempty"`
}

ChunkProfile describes the chunking policy to use for document ingestion. Token limits are intentionally conservative: large-context LLMs can read more, but retrieval quality usually degrades when indexed chunks become too broad or noisy.

func DefaultChunkProfile

func DefaultChunkProfile() ChunkProfile

DefaultChunkProfile returns the default enterprise RAG profile.

func NewCustomChunkProfile

func NewCustomChunkProfile(maxTokens, overlapTokens int) (ChunkProfile, error)

NewCustomChunkProfile validates and returns a custom chunk profile.

func RecommendedChunkProfile

func RecommendedChunkProfile(name ChunkProfileName) (ChunkProfile, bool)

RecommendedChunkProfile returns one of Seshat's built-in chunk profiles.

type ChunkProfileName

type ChunkProfileName string

ChunkProfileName identifies a recommended chunking profile for RAG ingestion. The profile controls indexing granularity; answer-time context expansion should still be used when a large LLM needs neighboring chunks.

const (
	ChunkProfileSmall      ChunkProfileName = "small"
	ChunkProfileMedium     ChunkProfileName = "medium"
	ChunkProfileLarge      ChunkProfileName = "large"
	ChunkProfileStructured ChunkProfileName = "structured"
	// ChunkProfileTable routes to TableChunker: table rows/structure stay
	// intact as their own chunk(s) (header row repeated on every split
	// piece) instead of a generic splitter cutting through the middle of a
	// table. See TableChunker's own doc comment.
	ChunkProfileTable ChunkProfileName = "table"
	// ChunkProfileQA routes to QAChunker: one chunk per detected
	// question/answer pair instead of arbitrary token-count splitting. See
	// QAChunker's own doc comment.
	ChunkProfileQA     ChunkProfileName = "qa"
	ChunkProfileCustom ChunkProfileName = "custom"
)

type Chunker

type Chunker interface {
	Split(ctx context.Context, text string) ([]Chunk, error)
}

Chunker splits a text into indexable chunks. The context allows implementations that call remote services (e.g. SemanticChunker).

func DefaultChunker

func DefaultChunker() Chunker

DefaultChunker returns a ParagraphChunker with sensible defaults.

type Document

type Document struct {
	Filename string
	Text     string
	Data     []byte
}

Document is the original source material plus its text representation. Plain text chunkers can ignore Data. Document-aware chunkers can prefer Data to preserve layout, headings, page numbers, tables, and captions.

type DocumentChunker

type DocumentChunker interface {
	Chunker
	SplitDocument(ctx context.Context, doc Document) ([]Chunk, error)
}

DocumentChunker is implemented by chunkers that can split the original document, not just extracted plain text.

type Embedder

type Embedder interface {
	EmbedTexts(ctx context.Context, texts []string) ([][]float32, error)
}

type Enricher

type Enricher interface {
	// EnrichChunks returns, for each text in order, the synthetic questions
	// generated for it. Implementations should be best-effort per item (see
	// e.g. internal/rag/enricher.LLMEnricher) - a single chunk's failure
	// returns an empty, not necessarily nil, slice at that index rather than
	// failing the whole batch. A non-nil error here means something more
	// fundamental went wrong (e.g. ctx cancelled) and Ingest should abort,
	// the same contract Embedder.EmbedTexts already has.
	EnrichChunks(ctx context.Context, texts []string) ([][]string, error)
}

Enricher generates synthetic questions per chunk - questions that chunk's content would answer - so they can be indexed alongside it. This is a known retrieval-recall technique: chunk text is usually declarative, but users phrase queries as questions, so embedding the chunk together with questions it answers closes that vocabulary gap (see RAGFlow's own "Extractor" pipeline stage, which this mirrors). Optional: nil (the default) disables enrichment entirely - see Service.SetEnricher. Costs one LLM call per chunk, so it is opt-in, never a forced default.

type EnricherCacheKeyProvider

type EnricherCacheKeyProvider interface {
	EnricherCacheKey() string
}

EnricherCacheKeyProvider lets an Enricher include its own configuration (model, questions-per-chunk, prompt version) in cache keys, so changing that configuration doesn't silently reuse stale enrichment results - the same purpose ChunkCacheKeyProvider serves for chunkers.

type EnrichmentCache

type EnrichmentCache interface {
	GetEnrichment(ctx context.Context, key string) ([]string, bool, error)
	PutEnrichment(ctx context.Context, key string, questions []string) error
}

EnrichmentCache stores per-chunk enrichment results (synthetic questions) under a deterministic key - the same content-hash-keying idea as ChunkCache, so a re-ingest of unchanged chunks doesn't re-bill the LLM.

type HeadingChunker

type HeadingChunker struct {
	Profile ChunkProfile
}

HeadingChunker cuts a markdown document along its own structure: a heading hierarchy (markdown headings, numbered outline, or structural words like "Chapter"/"Article"/"Capítulo"/"Artigo"), paragraphs, lists, tables and fenced code. Each chunk carries the path of headings it sits under ("Part One > Article 5 > Clause 5.2"), in its text (so embedding and BM25 relevance benefit from the section context) and in Metadata["heading_path"] (for citation and display without re-parsing the text).

A block is never cut in the middle of what it is (a paragraph is cut between sentences, a table between rows with its header repeated, code between lines, a list between items), small sections are joined to their neighbours with their headings written in the text so no chunk is a title and one line, and a paragraph that has to be cut overlaps with the piece before it by the profile's OverlapTokens. See markdownChunker for the details.

Inspired by RAGFlow's bullets_category/tree_merge (rag/nlp/__init__.py:370-387,1120-1164), not a port of it.

A document with no heading at all is simply packed block by block.

func NewHeadingChunker

func NewHeadingChunker(profile ChunkProfile) *HeadingChunker

NewHeadingChunker creates a heading-aware chunker using one of Seshat's recommended chunk profiles (same defaulting guard as NewHybridDocumentChunkerForProfile).

func (*HeadingChunker) Split

func (c *HeadingChunker) Split(_ context.Context, text string) ([]Chunk, error)

func (*HeadingChunker) SplitDocument

func (c *HeadingChunker) SplitDocument(ctx context.Context, doc Document) ([]Chunk, error)

SplitDocument satisfies DocumentChunker by ignoring the original bytes - HeadingChunker works on already-extracted text/patterns, not layout, the same as ParagraphChunker/SemanticChunker.

type HybridDocumentChunker

type HybridDocumentChunker struct {
	Client      documentreader.HybridChunker
	Options     documentreader.ChunkOptions
	Profile     ChunkProfile
	Fallback    Chunker
	FailOnError bool
}

HybridDocumentChunker chunks rich documents with a document-aware hybrid chunker. The backend can be local, docling-serve, seshat-intelligence, or any other document reader implementing documentreader.HybridChunker. It falls back to a plain text chunker unless FailOnError is set.

func NewHybridDocumentChunker

func NewHybridDocumentChunker(client documentreader.HybridChunker, opts documentreader.ChunkOptions) *HybridDocumentChunker

NewHybridDocumentChunker creates a document-aware chunker backed by the given document reader.

func NewHybridDocumentChunkerForProfile

func NewHybridDocumentChunkerForProfile(client documentreader.HybridChunker, profile ChunkProfile, opts documentreader.ChunkOptions) *HybridDocumentChunker

NewHybridDocumentChunkerForProfile creates a document-aware chunker using one of Seshat's recommended chunking profiles. When the backend is unavailable or fails, the fallback depends on the profile: "structured" falls back to HeadingChunker (heading/numbering-hierarchy aware), "table" to TableChunker (keeps table rows intact), "qa" to QAChunker (one chunk per detected Q/A pair) - every other profile keeps the plain fallback unchanged.

func (*HybridDocumentChunker) ChunkCacheKey

func (c *HybridDocumentChunker) ChunkCacheKey() string

func (*HybridDocumentChunker) Split

func (c *HybridDocumentChunker) Split(ctx context.Context, text string) ([]Chunk, error)

func (*HybridDocumentChunker) SplitDocument

func (c *HybridDocumentChunker) SplitDocument(ctx context.Context, doc Document) ([]Chunk, error)

type IngestRequest

type IngestRequest struct {
	CorpusID string
	// FileID, when non-empty, produces a deterministic artifact key ("rag/{CorpusID}/{FileID}").
	// This makes Upsert idempotent: re-ingesting the same file replaces its vectors in-place
	// rather than creating orphaned duplicates alongside the old ones.
	FileID   string
	Filename string
	Text     string
	// Data carries the original document bytes when ingestion can provide
	// them. Chunkers that understand document structure can use it instead of
	// splitting the already-extracted Text representation.
	Data []byte
	// ScopeID tags every chunk produced from this ingest with a permission
	// scope (a workspace ID for shared content, or an owning user ID for
	// personal content). Empty means unscoped — no scope_id metadata is
	// written, and the chunk is invisible to any search that filters on it.
	// Mutually exclusive with ScopeIDs - set at most one of the two.
	ScopeID string
	// ScopeIDs tags every chunk with multiple permission scopes at once
	// (e.g. a connector-synced document visible to several identities:
	// specific users, groups, a domain). Takes precedence over ScopeID when
	// both would apply from a caller's perspective - callers should set
	// only one. Encoded as a JSON array in the scope_id metadata field, so
	// a single "$in" filter transparently matches both the scalar (ScopeID)
	// and multi-valued (ScopeIDs) representations - see vector.matchesFilter
	// and pgvector_store.go's pgFilterClause.
	ScopeIDs []string
}

type IngestResult

type IngestResult struct {
	Artifact storage.ArtifactRef
	Chunks   int
}

type MemoryChunkCache

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

MemoryChunkCache is useful for tests and short-lived local runs.

func NewMemoryChunkCache

func NewMemoryChunkCache() *MemoryChunkCache

func (*MemoryChunkCache) GetChunks

func (c *MemoryChunkCache) GetChunks(_ context.Context, key string) ([]Chunk, bool, error)

func (*MemoryChunkCache) PutChunks

func (c *MemoryChunkCache) PutChunks(_ context.Context, key string, chunks []Chunk) error

type MemoryEnrichmentCache

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

MemoryEnrichmentCache is useful for tests and short-lived local runs.

func NewMemoryEnrichmentCache

func NewMemoryEnrichmentCache() *MemoryEnrichmentCache

func (*MemoryEnrichmentCache) GetEnrichment

func (c *MemoryEnrichmentCache) GetEnrichment(_ context.Context, key string) ([]string, bool, error)

func (*MemoryEnrichmentCache) PutEnrichment

func (c *MemoryEnrichmentCache) PutEnrichment(_ context.Context, key string, questions []string) error

type ParagraphChunker

type ParagraphChunker struct {
	MaxChunkChars int
}

ParagraphChunker splits on blank lines and hard-caps each paragraph at MaxChunkChars characters. It does not call any remote service.

func (ParagraphChunker) Split

func (c ParagraphChunker) Split(_ context.Context, text string) ([]Chunk, error)

type QAChunker

type QAChunker struct {
	Profile  ChunkProfile
	Fallback Chunker
}

QAChunker splits a naturally question/answer-formatted document (FAQs, support docs) into one chunk per Q/A pair, instead of arbitrary token-count splitting that can separate a question from its own answer or merge several unrelated pairs into one chunk. Each pair's chunk carries the question in Metadata["qa_question"], for citation/UI display without re-parsing the text - the same idea as HeadingChunker's Metadata["heading_path"].

Two independent detection strategies are tried, in order:

  1. Explicit "Q:"/"A:" labels (also "Question:"/"Answer:", numbered "Q1:", and bold "**Q:**" markdown) - the common plain-text FAQ shape.
  2. Markdown headings ending in "?" (e.g. "## What is your return policy?") - the common Markdown/docling-converted FAQ shape. Reuses HeadingChunker's own heading-detection (matchHeading) and ancestor-path tracking, so a nested "Category > Question?" structure keeps its category context; a heading that does NOT end in "?" still produces an ordinary (non-QA-tagged) section chunk exactly as HeadingChunker would, rather than being silently dropped - QA tagging is additive on top of HeadingChunker's own behavior, never a narrower view of the document.

A document matching neither pattern delegates entirely to Fallback - QAChunker is additive, never worse than the fallback's own baseline, the same contract HeadingChunker/TableChunker already establish.

func NewQAChunker

func NewQAChunker(profile ChunkProfile) *QAChunker

NewQAChunker creates a QA-pair-aware chunker using one of Seshat's recommended chunk profiles (same defaulting guard as NewHeadingChunker/NewTableChunker). The fallback is HeadingChunker, so a document with no QA structure at all still gets heading-aware chunking rather than plain paragraph splitting.

func (*QAChunker) Split

func (c *QAChunker) Split(ctx context.Context, text string) ([]Chunk, error)

func (*QAChunker) SplitDocument

func (c *QAChunker) SplitDocument(ctx context.Context, doc Document) ([]Chunk, error)

SplitDocument satisfies DocumentChunker by ignoring the original bytes - QAChunker works on already-extracted text/patterns, the same as HeadingChunker/TableChunker/ParagraphChunker/SemanticChunker.

type Reranker

type Reranker interface {
	Rerank(ctx context.Context, query string, docs []string, topN int) (indices []int, scores []float32, err error)
	IsConfigured() bool
}

Reranker reorders a candidate set of documents by semantic relevance. Implementations are optional — when nil the RAG service returns vector results in score order without a second-pass rerank.

Rerank returns (indices, scores) where indices[i] is the position of the i-th most relevant document in the original docs slice. Pass topN=0 to return all results.

type SearchRequest

type SearchRequest struct {
	CorpusID string
	Query    string
	TopK     int
	// HybridWeight blends vector similarity with BM25 keyword search.
	// 0 (default) = pure vector; 1 = pure BM25; intermediate = linear blend.
	HybridWeight float32
	// RerankWeight blends the (normalized) reranker score with the original
	// retrieval score, when a reranker is configured - a separate knob from
	// HybridWeight, which blends at retrieval time (vector vs BM25); this
	// one blends after retrieval (retrieval score vs rerank score). Above 0
	// and up to 1, an explicit weight (1 = fully trust the reranker). Left
	// at the zero value (0, the common case for a caller with no opinion)
	// falls back to the service's configured default (see
	// Service.SetRerankWeight) instead of silently disabling the blend - a
	// caller that genuinely wants zero reranker influence should simply not
	// configure a reranker, rather than rely on this field to suppress one.
	// Ignored when no reranker is configured.
	RerankWeight float32
	// Filter restricts results by metadata key-value predicates.
	// Passed through to vector.Query.Filter unchanged.
	Filter map[string]any
}

type SearchResponse

type SearchResponse struct {
	CorpusID string         `json:"corpus_id"`
	Results  []SearchResult `json:"results"`
}

type SearchResult

type SearchResult struct {
	Key      string            `json:"key"`
	Text     string            `json:"text"`
	Score    float32           `json:"score"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type SemanticChunker

type SemanticChunker struct {

	// Threshold below which two consecutive sentences are considered
	// semantically distinct and a new chunk is started. Default: 0.3.
	Threshold float32
	// MaxChunkChars is the hard character cap per chunk. Default: 2000.
	MaxChunkChars int
	// MinChunkChars is the minimum size a chunk must reach before it can be
	// split off. Chunks below this are merged with the next. Default: 100.
	MinChunkChars int
	// contains filtered or unexported fields
}

SemanticChunker groups sentences into chunks based on cosine similarity between consecutive sentence embeddings. A new chunk is started whenever similarity falls below Threshold. Inspired by the Max-Min algorithm (Springer 2025) as implemented in the mcp-local-rag reference.

Falls back to ParagraphChunker behaviour when the embedder returns an error, so ingest never fails due to a temporary embedding outage.

func NewSemanticChunker

func NewSemanticChunker(embedder Embedder, threshold float32) *SemanticChunker

NewSemanticChunker creates a SemanticChunker with sensible defaults. threshold ≤ 0 → use default 0.3.

func (*SemanticChunker) Split

func (c *SemanticChunker) Split(ctx context.Context, text string) ([]Chunk, error)

Split embeds each sentence and groups them into chunks by similarity. On embedder error it falls back to ParagraphChunker.

type Service

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

func NewService

func NewService(artifacts storage.ArtifactStore, vectors vector.Store, embedder Embedder, chunker Chunker) *Service

func (*Service) DeleteFileChunks

func (s *Service) DeleteFileChunks(ctx context.Context, namespace, artifactKey string, keepBelow int) error

DeleteFileChunks removes artifactKey's chunk records whose position is keepBelow or greater - either stale chunks left over from a re-ingest that produced fewer chunks than its previous run (keepBelow = the new chunk count), or every chunk for the file when deleting it outright (keepBelow = 0).

This lists every record actually in namespace and filters by the artifact_key/position metadata Ingest attaches to each chunk, rather than guessing an upper bound on how many old chunks might exist: an earlier version capped the search at a fixed ceiling past the new count (500 here, 2000 for rag_delete's whole-file case), so a file that shrank by more than that many chunks - or was simply larger than the ceiling to begin with - left orphaned vectors beyond it that no delete call could ever reach, still returned by future searches as phantom results.

func (*Service) DeleteNamespace

func (s *Service) DeleteNamespace(ctx context.Context, namespace string) error

DeleteNamespace removes all vector records for the given corpus namespace.

func (*Service) Ingest

func (s *Service) Ingest(ctx context.Context, request IngestRequest) (IngestResult, error)

func (*Service) Search

func (s *Service) Search(ctx context.Context, request SearchRequest) (SearchResponse, error)

func (*Service) SetEnricher

func (s *Service) SetEnricher(e Enricher)

SetEnricher installs a chunk-enrichment step run during Ingest, before embedding: each chunk's synthetic questions (see Enricher's doc comment) are appended to the text that gets embedded, not to the chunk's stored/ displayed text. Pass nil (the default) to disable enrichment - it costs one LLM call per chunk, so it is never on by default.

func (*Service) SetRerankMargin

func (s *Service) SetRerankMargin(m float32)

SetRerankMargin sets the margin at or above which the first stage is trusted and the reranker is not asked (see defaultRerankMargin). 0 or less asks it for every search.

func (*Service) SetRerankWeight

func (s *Service) SetRerankWeight(w float32)

SetRerankWeight overrides the default blend weight (0.7, see the measures at defaultRerankWeight) applied between the reranker's normalized score and each result's original retrieval score, for any SearchRequest that doesn't set its own RerankWeight. w is clamped to [0,1].

func (*Service) SetReranker

func (s *Service) SetReranker(r Reranker)

SetReranker installs a second-pass reranker applied after vector retrieval. Pass nil to disable reranking.

func (*Service) Vectors

func (s *Service) Vectors() vector.Store

Vectors returns the underlying vector store, e.g. for callers that need to inspect raw records directly (tests, admin tooling).

type TableChunker

type TableChunker struct {
	Profile  ChunkProfile
	Fallback Chunker
}

TableChunker splits a Markdown/GFM document while keeping every table's rows intact as their own chunk(s), instead of letting a generic character/token splitter cut through the middle of a table (which destroys the header-to-cell association the table's meaning depends on). A table larger than the chunk profile's token budget is split by data row, but the header + separator row is repeated at the top of every resulting piece, so each chunk remains a valid, self-contained table rather than a headerless fragment.

Text outside any detected table is delegated to Fallback (default HeadingChunker via NewTableChunker, so section/heading context is preserved for the surrounding prose too, not just the tables).

A document with no GFM table at all delegates entirely to Fallback - TableChunker is additive, never worse than the fallback's own baseline for a document that has nothing for it to do, the same contract HeadingChunker already established for its own fallback.

func NewTableChunker

func NewTableChunker(profile ChunkProfile) *TableChunker

NewTableChunker creates a table-aware chunker using one of Seshat's recommended chunk profiles (same defaulting guard as NewHeadingChunker/NewHybridDocumentChunkerForProfile). The fallback for non-table text is HeadingChunker, so a table-and-headings document gets both behaviors at once.

func (*TableChunker) Split

func (c *TableChunker) Split(_ context.Context, text string) ([]Chunk, error)

func (*TableChunker) SplitDocument

func (c *TableChunker) SplitDocument(ctx context.Context, doc Document) ([]Chunk, error)

SplitDocument satisfies DocumentChunker by ignoring the original bytes - TableChunker works on already-extracted Markdown text, the same as HeadingChunker/ParagraphChunker/SemanticChunker.

type VectorStore

type VectorStore = vector.Store

Directories

Path Synopsis
Package enricher implements RAG's optional chunk-enrichment step: an LLM generates synthetic questions per chunk, run concurrently across chunks with a bounded worker pool.
Package enricher implements RAG's optional chunk-enrichment step: an LLM generates synthetic questions per chunk, run concurrently across chunks with a bounded worker pool.
Package reranker implements RAG's optional second-pass reranking step: an HTTP client speaking the Cohere-compatible rerank API shape ({query, documents, top_n} -> {results: [{index, relevance_score}]}), which LangSearch's hosted API, vLLM's built-in reranker endpoint, and Cohere itself all speak.
Package reranker implements RAG's optional second-pass reranking step: an HTTP client speaking the Cohere-compatible rerank API shape ({query, documents, top_n} -> {results: [{index, relevance_score}]}), which LangSearch's hosted API, vLLM's built-in reranker endpoint, and Cohere itself all speak.

Jump to

Keyboard shortcuts

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