Skip to content

The per-chunk ontology list keeps to the prompt budget - #704

Merged
WaylandYang merged 4 commits into
devfrom
fix/the-per-chunk-ontology-list-has-a-budget
Sep 14, 2026
Merged

WaylandYang merged 4 commits into
devfrom
fix/the-per-chunk-ontology-list-has-a-budget

Conversation

@WaylandYang

@WaylandYang WaylandYang commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Closes #701.

Problem

With schema.org the extraction prompt was about 20k tokens per call. The budget in 0006 (ontology_prompt_budget, 24,000 characters) only decided whether the whole ontology fits. Once retrieval took over, the per-chunk list had no limit. Three floors added since then (ancestors, signature classes, relations declared on the retrieved classes) laid out 56,155 characters for one chunk: 2.3 times the budget, and 85% of the prompt. Descriptions were 84% of that list.

Change

  • The per-chunk list keeps to the same budget. Candidates queue by distance: retrieved relations and attributes first, taking turns; floor additions after. Each candidate brings its signature classes. The list takes the longest prefix whose laid-out text (PromptLists::chars, the same measure the full list uses) fits the budget. Length only grows with the prefix, so a binary search finds it. Floor relations still pull no signature classes, as before.
  • A retrieved list carries each description's first sentence. Sentence bounds follow UAX Fix GLIBC mismatch, and make the release prove the container boots #29 through unicode-segmentation (already in the tree). A full inline list is a small ontology and keeps descriptions whole.
  • 0006 status line, a revision entry and the README row are updated.

Measured

Recall bench (NVIDIA filings, 52 hand-checked items, schema.org), measured together with #705 on the same run:

before after
recall 47/52 48/52 (1σ ≈ 2.7)
prompt per extraction call, same 76 chunks 13.5k 8.1k
total prompt tokens, same 76 chunks 1,029,899 617,215

The heavier case, google-deepmind.txt from ai-timeline (41 chunks, re-extracted with both PRs): prompt per call 19,473 → 8,300 tokens, output 1,605 → 965.

Tests

  • a_description_is_cut_at_its_first_sentence, two_ranked_lists_take_turns_and_the_longer_one_finishes
  • cargo test -p utopia-extract -p utopia-server, clippy and fmt clean

🤖 Generated with Claude Code

WaylandYang and others added 3 commits September 14, 2026 17:31
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: WaylandYang <wayland0916@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: WaylandYang <wayland0916@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: WaylandYang <wayland0916@gmail.com>
@WaylandYang
WaylandYang merged commit adbbfbb into dev Sep 14, 2026
4 checks passed
@WaylandYang
WaylandYang deleted the fix/the-per-chunk-ontology-list-has-a-budget branch September 14, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The per-chunk ontology list has no budget

1 participant