> ## 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.

# Configure a project

> Write a ladygraph.yaml and the data files beside it.

A program is given one file, `ladygraph.yaml`. It holds the settings and names two data files that sit next to it. This page shows how to write your own, section by section. The minimal file below is tested: `tests/test_project_paths.py` loads it.

## The files

| File | What it is | Needed? | Who writes it |
| - | - | - | - |
| `ladygraph.yaml` | The settings, and the paths of the files below | Yes | You |
| `ontology.yaml` | The concept types and relation types your index may use | Yes, to index | You |
| `glossary.yaml` | The term list the translator uses (source term to English) | Only if you translate | The [term-list builder](https://ladygraph.io.vn/guides/term-list-builder.md) proposes it, and a person approves it |
| A credentials file or environment variables | Keys and gateway addresses | When a service needs a key | Never in the YAML itself. The YAML names the variable. |

The example files `prompt.example.yaml`, `extractor.example.yaml`, `entity_kinds.example.yaml` and `glossary_builder.example.yaml` are examples of a section of `ladygraph.yaml`, not separate files to load.

> [!NOTE]
>
> **Paths.** A relative path in `ladygraph.yaml` is relative to the file's own folder, not to where you start the program. This holds for `ontology:`, `glossary:`, `sources:` entries, and the model and checkpoint paths in `extractor:`. A key that names a missing file is an error that says which key and where it looked.

**Which setting wins.** When a setting appears in several places, the order is: arguments passed in code, then `LADYGRAPH_EXTRACTOR` (for `extractor.kind` only), then the file, then the defaults.

## What a sufficient folder looks like

`docs/example_project/` in the repository is a real folder you can copy. `tests/test_project_paths.py` loads it, so it stays correct.

```text theme={null}
my_project/
├── ladygraph.yaml            the one file a program is given; every path in it is relative to this folder
├── ontology.yaml             `ontology:`  the types and relations (required to index)
├── glossary.yaml             `glossary:`  the term list (only if you translate)
├── notes/                    `sources[0].path: notes/*.md`  your documents
│   └── leave.md
├── models/                   only for local models; large files, kept out of version control
│   ├── gemma-4-E2B-it-gpu.litertlm     `extractor.llm.model`
│   ├── gliner_gpu.tflite               `extractor.ner.tagger.tflite`
│   └── gliner_small-v2.5/              `extractor.ner.tagger.tokenizer`
│       ├── tokenizer.json
│       └── gliner_config.json
└── glossary.proposed.yaml    written by the term-list builder, for a person to review
```

* **Required to index:** `ladygraph.yaml`, `ontology.yaml`, and a source (here `notes/`).
* **Optional:** `glossary.yaml` (translation only) and `models/` (local models only).
* **Not in the folder:** keys, which are environment variables, and the index store, wherever your program points it.
* **No model files?** Use `extractor.llm` with `backend: litellm` and delete the `ner:` section. The folder is then just the four files and `notes/`.

## A minimal file

Create a folder with these files. `notes/` holds your markdown.

```yaml ladygraph.yaml theme={null}
ontology: ontology.yaml
glossary: glossary.yaml           # leave out if you do not translate

prompt:
  domain: company HR policy notes
  word_language: English

sources:
  - name: notes
    kind: markdown
    scheme: notes
    path: notes/*.md
    split_level: 2

extractor:
  kind: llm_okf
  llm:                                # every kind needs a model: it reads the document and places each concept
    backend: litellm                  # a gateway you run, for example LiteLLM serving any hosted model
    model: my-model                   # the gateway's model name
    api_base: http://localhost:4000/v1
    api_key_env: LADYGRAPH_LLM_KEY    # the NAME of the environment variable that holds the key
  # A model file on this machine instead (the path is relative to this file):
  # llm: {backend: litert, model: models/gemma-4-E2B-it-gpu.litertlm, device: gpu}
```

```yaml ontology.yaml theme={null}
types:
  rule: {description: A limit, condition or entitlement}
  unit: {description: A unit that acts or approves}
relations:
  APPROVED_BY: {description: A rule is approved by a unit, from: [rule], to: [unit]}
```

> [!WARNING]
>
> Without an `extractor.llm:` section, or an `llm=` argument in code, `build_extractor` stops with "no model". A file that only loads is not yet a file that runs.

Check that it loads, from any folder:

```python theme={null}
from ladygraph.project import project_paths, load_ontology
from ladygraph.sources.factory import load_sources
from ladygraph.extractors.prompt import load_prompt
from ladygraph.extractors.config import load_extractor_config

cfg = "path/to/ladygraph.yaml"
print(project_paths(cfg))                 # the resolved ontology and glossary paths
print(list(load_ontology(cfg).types))     # ['rule', 'unit']
print(list(load_sources(cfg)))            # ['notes']
print(load_prompt(cfg).domain, load_extractor_config(cfg).kind)
```

## The sections

Each section is read on its own from the same file. `prompt:` and `extractor:` reject a key they do not know, so a typo is an error and not a setting that silently does nothing.

| Section | What it sets | Read more |
| - | - | - |
| `ontology:`, `glossary:` | The paths of the two data files | [The data files](#the-data-files) |
| `sources:` | Where documents come from: `sql`, `json`, `markdown`, `pydantic` | [Sources](https://ladygraph.io.vn/guides/sources.md) |
| `prompt:` | The wording of the extraction prompts: domain, languages, what to skip, one example | [Prompt and glossary](https://ladygraph.io.vn/guides/prompt-and-glossary.md) |
| `extractor:` | Which extractor finds concepts (the feature flag), and its model and tagger | [Extractors](https://ladygraph.io.vn/guides/extractors.md) |
| `chunking:` (under a markdown source) | How a long, loosely structured text is cut into passages | [Sources](https://ladygraph.io.vn/guides/sources.md#long-text-chunking) |
| `entities:` | Codes and abbreviations a deployment names, such as document codes and form codes | [Entity kinds](https://ladygraph.io.vn/guides/entity-kinds.md) |
| `glossary_builder:` | The authoring tool that proposes glossary entries. Nothing here runs at index time. | [Term-list builder](https://ladygraph.io.vn/guides/term-list-builder.md) |

> [!NOTE]
>
> **Keys such as `scope`, `store`, `embedder` and `timezone`.** The demo's `ladygraph.yaml` has them, but the demo script reads them, not a loader in the package. Writing them does nothing in your own program unless your program reads them. The same holds for `serve_min_trust`, which `docs/INTERFACE.md` shows. The source search found no reader of these keys in the package.

## The data files

### ontology.yaml

`types:` maps a type name to a `description`. `relations:` maps a relation name to a `description`, `from` and `to` (lists of types, where an empty list means any), and optionally these keys:

| Key | Default | Meaning |
| - | - | - |
| `requires_actor` | none | `human` or `process`. Only an actor whose name starts with that prefix, such as `human:ops-finance`, may create the relation. A relation that needs a human is not shown to an automated extractor. |
| `max_targets` | none (many) | The most targets one source concept may have. |
| `max_sources` | none (many) | The most sources one target concept may have. |
| `traverse` | `true` | When `false`, the relation is stored but search never follows it. |
| `weight` | `1.0` | The relation's weight, which scales the score of a concept reached over it. |
| `limit_hint` | empty | A plain-language limit shown to the extractor. It overrides the one generated from the cardinality. |

Every type a tagger label maps to must exist here, or the extractor stops with an error that names it. The core loader reads this format (`Ontology.load`). The demo's mined ontology has another shape and goes through its own converter.

Lesson 1 shows the checks on a small ontology: an allowed relation, a relation from the wrong type, a relation that needs a human actor, and a relation the ontology does not declare. An undeclared relation is kept as an untyped link.

### glossary.yaml

Needed only when you translate.

```yaml theme={null}
terms:
  - {vi: [licencia anual], en: annual leave, expect: [leave]}
  - {vi: [iva, impuesto al valor agregado], en: VAT, expect: [vat, value-added], status: proposed}
examples:
  - {vi: "...", en: "..."}
```

| Key | Meaning |
| - | - |
| `vi` | The source forms that trigger the term. Matched ignoring case, in NFC. |
| `en` | The wording shown to the model. |
| `expect` | Lower-case stems. When a `vi` form is in the source, one of them must appear in the English, or the translation is rejected. |
| `ok_if`, `contamination` | Stop a glossary word from being copied into an unrelated sentence. Set `contamination: false` for common words. |
| `status` | `approved` (the check enforces it, and the default) or `proposed` (shown to the model as a hint only). The builder writes `proposed`, and a person changes it to `approved` after reading it. |

> [!NOTE]
>
> `vi` is a historical key name. It lists the source-language forms of a term, whatever the language.

## Secrets

Never put a key in a YAML file. Put the name of an environment variable (`api_key_env`, `gateway.api_key_env`) and set the variable in the shell. The builder refuses to print or write key values.

## When it does not work

| You see | Cause |
| - | - |
| `... is not a file (looked for <path>)` | The `ontology:` or `glossary:` path is wrong. It was resolved from the folder of `ladygraph.yaml`. |
| A validation error naming a key | A typo or unknown key in `prompt:` or `extractor:`. |
| `extractor.kind 'ner' needs an ner: section` | `ner` or `translate_ner` was chosen without `ner.labels`. |
| `LADYGRAPH_EXTRACTOR='x': expected one of ...` | The variable holds a value that is not an extractor kind. |
| `no model: pass llm=... or set extractor.llm` | The extractor needs a model to place concepts, in every kind. |
| `maps to types the ontology does not have` | A `ner.labels` value is not a type in `ontology.yaml`. |
| A source is skipped with a warning | Its `kind:` has no adapter. |


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