World's first open-source enterprise world model.
0006 · Ontology scale and the extraction prompt
- Status: Superseded by 0044 · was built
- Written: 2026-08-29 · condensed into English 2026-09-03
- Related: 0008 packs are now the starting ontology; 0012 measured the bias that forced ancestor completion.
The problem
The extraction prompt inlined the whole ontology once per chunk; extraction.rs called
entity_types(kb) with no selection step. After importing schema.org (968 classes, 1034
relations, 599 attributes) each chunk cost 108,133 tokens.
0001 P3 had guessed "800 classes blows the
prompt" and got the shares wrong: classes 38%, relations 34%, attributes 28%.
Decisions
- Switch by budget. If the ontology fits, inline it all, unchanged: a forty-class
ontology is 2k characters and retrieval would be a wasted round trip. If not, each
chunk retrieves its own candidates with
chunk.embedding(already loaded for entity resolution), falling back to the full list when nothing is retrieved. The budget is in characters because description lengths differ by orders of magnitude, and it measures the textbuild_listsactually lays out. It is a deployment setting because tuning it needs paired runs per level, and nobody reruns a curve that needs a server restart per point. - Three details that exist only once there is a choice. Signatures may name only
inlined classes (an absent class in
works_at (person → organization)teaches the model a type that does not exist; an unselected side becomes*); attributes follow their domain class; both paths share onebuild_lists, or the prompt stops matching what the code accepts. - Ancestor completion (2026-09-02): whatever retrieval hits, its
subClassOfancestors are inlined too, breadth-first with a visited set. The chain is the ontology's own declaration of generalization; no hand-kept list of "general classes". The only detail forced by real data.
The bench (scripts/bench/corpora/pharma.json, 5 Chinese pharmaceutical documents,
one run each) showed no degradation up to 58,651 characters of ontology (about 15k tokens,
202 classes): entities per run swung 23–28 with no trend, so 24,000 is conservative. Full
inline has a ceiling unrelated to quality: at 394 classes (169,380 characters) it hit the
vendor's per-minute token limit (429) and never finished; retrieval did. With schema.org,
correctly typed entities went 2 of 19 with seeds only, 7 with the large ontology in
post-hoc resolution, 12 with per-chunk retrieval. Caveats: single runs (the same input has
produced 25 and 18 entities) and alphabetical subsets (subset.mjs takes the first N
classes), hence no hit rate.
Dead ends
- A fixed floor of built-in classes. Its premise, that seed classes are the general
ones, died when #128 stopped seeding.
0012 measured the symptom:
retrieval favors leaf classes that appear literally in the text (
researcherranks 4th of 976,person359th), soemployee (organization → person)degraded to(* → *). BATCH = 16in the ontology index, chosen from synthetic short texts; 64 doubled throughput.join_allover 31 embedding batches held the sharedmodel_concurrencygate for fifteen minutes; nowEMBED_JOBS = 4.
Revisions
- Withdrawn: "the 108k prompt ate 5 entities". The bench ingested first and imported
later, so both runs extracted with 9 seed classes and
prompt_tokens_estmeasured an ontology extraction never saw; 25 vs 18 was run variance. The bench now reportsontology_at_extractionandontology_at_resolutionseparately and has--ontology-first. - 2026-09-14 (#701): the per-chunk list keeps to the budget. The budget only decided whether the whole ontology fits; the list retrieval produced had no limit, and the floors added since (ancestors, signature classes, relations declared on the retrieved classes) laid out 56,155 characters for one schema.org chunk, 2.3 times the budget, 85% of a 19,735-token prompt in which the text was under 2%. Candidates now queue by distance (retrieved first, floor additions after, relations and attributes taking turns), each bringing its signature classes, and the list takes the longest prefix whose laid-out text fits. A retrieved list carries each description's first sentence (UAX #29); descriptions were 84% of it. A full inline list is a small ontology and keeps its descriptions. Recall bench 48/52 against 47/52 before; prompt per extraction call on the same four filings 13.5k → 8.1k tokens, measured together with the sentence-numbered reply.
- 2026-09-02: per-chunk retrieval sends one vector query per chunk with concurrency up to
worker_concurrency(cap 256 since #133) against a pool of 32; migration0011records it.
Open questions
- Legitimacy of the corpus. The set grew from two to eight, with generation scripts
committed, but
scripts/bench/truth/still holds only the hand-filledpharmaandtechkeys. The intended fix is Chinese Wikipedia text with WikidataP31as the type answer, so the answer stops being our opinion; noP31code exists yet. - Budget and per-chunk candidate counts (24,000; 40 classes / 30 relations / 30
attributes) are guesses; tuning before the corpus question is settled only tightens the
overfit.
run.mjs --packs schema-org,prov-owalks the real cold-start path, but that comparison has not been run.
Status history
The status line as it stood on 2026-09-27, before status lines were cut to one line:
Built · the character budget (
deployment_settings.ontology_prompt_budget, 24,000) and per-chunk retrieval are live, values unchanged; the "built-in classes always present" floor is replaced by ancestor completion; the per-chunk list keeps to the same budget and carries first sentences (#701); answer keys are still hand-filled.