Skip to content

Indexing and retrieval

Indexing prepares source material for search. Retrieval selects evidence for a question. This page follows the intended flow and shows where experiments can replace individual steps.

Implemented foundations

  • Datasets/loaders, Source and Chunk records, and the four indexing step contracts have initial implementations. ZeroEmbedder is a shape-only placeholder.
  • Source and Chunk are immutable and carry a required collection_id; chunks also carry their ordinal in the chunker's result. Their IDs are deterministic UUIDv8s derived from the same fields as their fingerprints, so re-creating equal records reproduces their IDs. Dataset and converter producers take the collection as an argument.
  • Benchmark inputs: QAQuestion with its public QuestionInput and SpanEvidence/DocumentEvidence gold, the QABenchmark corpus and questions bundle, and LegacyFixture for the repository's fixture files. Evidence names native document keys, which are the corpus Sources' external_ids. HotpotQA reads HippoRAG's 1,000-question HotpotQA sample with sentence or passage gold. It and the MultiHop-RAG corpus download pinned, hash-checked files on first use into the datasets folder beside the computation cache. Each declares its files and licence terms in a DatasetEntry, listed in triplum.datasets.catalogue.CATALOGUE. The triplum datasets commands list, download, verify, remove and licence manage these downloads.
  • Retrieval: the Retriever contract returning ranked RetrievalHits, and BM25, lexical search over an in-memory snapshot of one collection's chunks with the HIPPORAG1 (default) and BM25S_DEFAULT presets. It indexes what its corpus viewer may read in that collection and returns only that collection's chunks each query's viewer may read; term statistics are per collection, and scores still depend on every indexed chunk. WholeText keeps each source as one chunk.
  • Store-managed text search: TextSearchStore adds explicit index_text/search_text operations for one collection's snapshot. MemoryStore and SQLAlchemyStore reuse BM25 in Python; SQLiteStore persists native FTS5 indexes in separate tables per collection. Failed rebuilds retain the old snapshot. Given a viewer, searches filter before choosing the top k; omitted viewers do not filter access.
  • Retrieval recall: resolving gold evidence to Source ids, span and document coverage at several k, and means across questions. examples/bm25_recall.py scores BM25 on a fixture or on HotpotQA. Answer scoring, dense retrieval, fusion and the other baselines besides BM25, and a benchmark runner with run identity are not implemented.
  • Collection has a baseline record and SQL mapping; listing sources and BM25 are scoped to one collection. Collection storage operations and derived-record scope enforcement are not implemented.
  • Record stores support memory and SQL persistence: sources are insert-only and each source has one current chunk list, replaced as a whole. Each source is added with the principals allowed to read it. Reads given a Viewer return only what it may read; omitted viewers do not filter access. Listing sources takes one collection id. Revoking access and access for derived records are not implemented. A source's optional external_id is unique within its collection. Temporal history of changed documents and origin normalization are not settled. Computation caching supports optional intermediate-result reuse, normalized positional/keyword call arguments, per-computation SQLite tables and CLI/library inspection and clearing, including retained function names and source locations for selecting multiple computation fingerprints. Optional runtime dependency tracing validates observed application helpers before reusing results. Static computation identity refreshes its bounded loaded-definition/settings projection before every lookup, including supported referenced application class definitions; its documented limits include name-only fallback for unsupported classes and Pydantic models, and require stable inputs/context during each call. Fingerprintable data models provide field-value identity for use with the cache decorators, with explicit bookkeeping exclusions; a separate mixin supports existing Pydantic bases. Source/Chunk implement record fingerprint methods.
  • Indexing/ingestion prototypes remain under review. Vector search, graph retrieval and answer generation are intended responsibilities, not a supported end-to-end pipeline.

The diagrams below show those responsibilities, not a mandatory sequence of classes.

1. Indexing: prepare searchable evidence

flowchart TD
    A[Dataset or input collection] --> B[Load / parse]
    B --> C[Optional OCR / preprocessing]
    C --> S[Identified source text]
    S --> H[Chunking]
    H --> K[Initial chunks]
    K --> T[Text index]
    K --> P[Prepare embedding input]
    K -. Optional enrichment .-> E[Descriptions / keywords / questions]
    E --> P
    S -. Selected context .-> P
    P --> V[One vector per chunk]
    K -. Optional extraction .-> G[Resolve entities and facts]
    G --> GI[Graph index]

Obtain source text

A loader obtains a document, webpage or other input. Parsing, optional OCR and preprocessing make its text available as a Source. The basic record exists; richer provenance and loader/OCR interfaces remain open.

Produce initial chunks

Chunking chooses the portions to retrieve. A simple approach keeps the whole text as one chunk; others split it into smaller or overlapping pieces. Initial chunks need a relationship back to the source. Hierarchical chunking may also preserve sections and their contained passages.

Current offsets address Source.text. Representing earlier text versions and hierarchical containment remains open.

Optionally enrich and embed

Embedding preparation chooses which text and context contribute to a chunk's vector. The basic case uses the chunk text unchanged. An advanced case adds generated descriptions or questions:

Original:    Returns are accepted within 30 days of purchase.
Description: This shop's returns policy.
Question:    How long do I have to return a purchase?
                         ↓ preparation and embedding
                    One chunk vector

These are several associated strings, with one indexed vector per chunk per chosen embedding configuration. How they combine is undecided. A generated indexing question is enrichment; it is not the question a user later asks, nor an evaluation answer.

Original evidence and generated text need distinguishable provenance. Their physical types are still open. Preparation and encoding should be replaceable without requiring a pipeline registry.

Add graph and summary branches when needed

Extraction identifies candidate entities and relations from evidence. Resolution connects mentions to entities and produces supported facts. This branch need not consume the text prepared for embedding, and basic text retrieval does not require it.

Advanced pipelines may group graph entities into communities and summarize their evidence, or summarize a document's chunk hierarchy. Community membership and document containment are different relationships. Summaries can depend on multiple sources. Whether summaries share a type with chunks, and how they are indexed, remain undecided.

2. Retrieval: select evidence for a question

flowchart TD
    Q[User question + permitted view] --> R[Retrieve]
    I[Text / vector / graph indexes] --> R
    R --> E[Selected evidence]
    E --> O[Optional reranking]
    O --> F[Format evidence]
    Q --> F
    F --> L[LLM]
    L --> A[Answer]
  1. Retrieve. Search text, vectors or graph relationships for relevant evidence. Vector search may encode the user's question; this is separate from embedding source chunks during indexing.
  2. Optionally rerank. Reassess candidate relevance to the question.
  3. Format. Present the selected evidence to the model: for example passages, triples or graph structure. Chunk retrieval returns ranked hits; how graph facts and supporting passages travel together is undecided.
  4. Answer. Give the question and formatted evidence to the LLM.

A record store read given a viewer returns only the sources and chunks it may read; without a viewer it is not filtered by access (access control is deferred). BM25 retrieval searches one collection and filters by the query's viewer before ranking; its term statistics are per collection but not yet scoped to the viewer. Vector and graph retrieval are not implemented; graph traversal is to use the visible graph. Reads do not take a temporal view yet. Derived summaries must preserve their supporting sources' access restrictions.

Composing and reusing steps

Choose the branches the experiment needs: basic text retrieval, enriched vectors, graph records or summaries. Decision points lists current replacement boundaries.

Optional caching lets selected steps or larger blocks reuse results. Equal intermediate content can reuse downstream work even when different upstream processes produced it. Configured computations select effective settings explicitly; loaded application code and statically resolved helpers contribute automatically to identity. No manual dependency list or version bump is required. See computation fingerprints. Deterministic Source/Chunk IDs, collection membership, fingerprint field selection and benchmark cache policy remain under review.