> ## Documentation Index
> Fetch the complete documentation index at: https://ladygraph.io.vn/llms.txt
> Use this file to discover all available pages before exploring further.

# How it works

> Follow a document into the index and a question out of it.

ladyGraph has two paths. The indexing path turns changed documents into concepts. The search path answers a question by walking those concepts. The two paths share only the index, and search never calls the model that built it.

## Indexing

![Component diagram of the indexing path: a source feeds documents to the extractor, and the update loop validates and saves the result to a store](https://mintcdn.com/daves-tran/kGRmbJt6YCRhXS7k/images/ladygraph-indexing.png?fit=max\&auto=format\&n=kGRmbJt6YCRhXS7k\&q=85\&s=f4e98c5d1e42b352b5943b57160d8e20)

The indexing path

`run_update` is the whole update loop. For each changed Document it does three things:

1. **Extract.** An extractor reads the Document and returns the concepts in it, each grounded in evidence.
2. **Validate.** The result is validated before anything is saved.
3. **Save.** The concepts and the Document's version record go into the index in one transaction.

A Document whose result fails validation is rejected as a whole, and nothing of it is stored.

Only [Valid](https://ladygraph.io.vn/concepts/vocabulary.md#valid) Documents are indexed. A Document that is published, active and inside its validity period is Valid. When a Document stops being Valid, it leaves the index and takes with it every concept that only it supported.

## Search

![Component diagram of the search path: the embedder picks entry contexts, the decider routes down the context tree and judges concepts, and the resolver confirms the evidence](https://mintcdn.com/daves-tran/kGRmbJt6YCRhXS7k/images/ladygraph-search.png?fit=max\&auto=format\&n=kGRmbJt6YCRhXS7k\&q=85\&s=4ceb3e0f760f92ce7f7d52d82d3479f9)

The search path

A search does these steps:

1. **Enter by vector.** The embedder picks the starting contexts. Vectors only choose where to start at each depth of the tree.
2. **Route down the tree.** A small decision model reads the question together with the options at one level and picks one. "None of these" is always an option, so a context without an answer scores low.
3. **Judge concepts.** The same kind of decision picks among the concepts in the chosen context.
4. **Follow relations.** Typed relations lead from a concept to related ones. The number of hops is capped at 2.
5. **Resolve evidence.** The resolver reads the original text at each evidence address and confirms the fingerprint. If it cannot answer in time, the hit is still returned, marked unconfirmed.

### Off-topic questions

The last decision only ranks options against each other. On a small or vague index something always wins, so an off-topic question still gets an answer.

An optional relevance gate fixes that. With `SearchConfig(min_cosine=...)`, a question whose closest concept has a lower cosine gets no answer and costs no decider call. A concept whose human-declared word appears in the question still comes back.

The gate is off by default, because a cosine depends on the embedder and on the index. Measure the cut-off with `retrieval.calibrate(searcher, scope, off_topic=[...], on_topic=[...])`. It returns a suggestion and says when the two groups overlap.

On the sample blueprint, a cut-off of 0.64 to 0.66 refused 18 of 24 off-topic questions and kept all 27 answerable ones. It cut decider calls by 38%, which is about 40% less search time. Questions that share the domain's own words, such as an HR question in an IT index, still get through.

## Stores

![Component diagram of the stores: the in-memory store, the embedded Ladybug store, and a Ladybug server reached over Arrow Flight](https://mintcdn.com/daves-tran/kGRmbJt6YCRhXS7k/images/ladygraph-stores.png?fit=max\&auto=format\&n=kGRmbJt6YCRhXS7k\&q=85\&s=8ede2cba5445026c102c17c2b5596640)

Stores and the Flight server

An index is one `.lbdb` file. One process can own it for writing, or many can read it. `LadybugFlightStore` lets other machines read and save through a server that owns the file.

The embedded store and the Flight store run the same plan, so they cannot disagree about what a save does. The store contract tests run every scenario on the in-memory store, the embedded store and the Flight store.

> [card] [Architecture](https://ladygraph.io.vn/concepts/architecture.md)
>
> The packages and what each one imports.

> [card] [Vocabulary](https://ladygraph.io.vn/concepts/vocabulary.md)
>
> The terms used on this page, defined once.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.