Skip to main content
Which extractor finds the concepts is a setting, not code. With no extractor: section, the first version, llm_okf, is built.
What stays the same in every kind: a concept’s evidence is a quote found in the passage as written, placement and relation checks are shared code, and the result goes through the same validation. Only the step that finds concepts differs.

Choose a model: extractor.llm

Every kind needs a model, because every kind places each concept in a context. The defaults, from LlmConfig: temperature 0.0 (the extractor must be reproducible), max_output_tokens 8192, timeout_s 120 per request, attempts 3, backoff_s 1.0 (doubling after each failed attempt), and repair_attempts 1.
The backend of a litert model must match how the file was built. See Local models.

The ner and translate_ner kinds

ner and translate_ner also need an ner: section with the GLiNER model and the labels to ask for. This section is tested:
If the tokenizer folder lacks those two files, loading falls back to the gliner package, which is slower and needs torch. encoder_kind: tokenizers makes that an error instead. Load time is about 8 s on the GPU, mostly compiling the model. There is no torch in the default path.

Relations

A tagger names no relation, so one model call per document asks for them. It uses the llm_okf schema and checks: the quote must be in the text, and the types and cardinality must fit. What fails is dropped.
  • The model is extractor.relations_llm if set, otherwise extractor.llm.
  • relations: false turns the call off.
  • The call is skipped when fewer than two concepts were found, or when the ontology has no relation a machine may create.
Measured once with the E2B model on 3 real chunks: the call ran and E2B proposed none. A stronger relations_llm is the first thing to try.

Switch and build

  • Switch one run without editing the file with LADYGRAPH_EXTRACTOR=ner. A wrong value is an error, not a silent default. The variable cannot add settings the file lacks: ner without an extractor.ner: section fails with a message.
  • Build it with build_extractor("ladygraph.yaml", embedder=...). It reads this section and the prompt: section. Arguments llm=, tagger= and embedder= win over the file. A local model builds lazily, so nothing loads until the first call.

Compare before you switch

compare_extractors(doc, ontology, registry, a, b) runs two extractors on one document. It returns what only a made, what only b made, what both made, and an agreement score. It writes nothing. Lesson 9 shows all three kinds side by side on one document and compares them.
How ner and translate_ner compare with llm_okf on real documents has not been measured. The tests use fakes. docs/extractor.example.yaml in the repository is a full example.

A note on short concepts

A one-word or bare-figure concept is kept, such as “KPI” or “70%”. Only an e-mail address or a phone number, with at most a stray word, is dropped.