The per-chunk ontology list keeps to the prompt budget - #704
Merged
Merged
Conversation
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
deleted the
fix/the-per-chunk-ontology-list-has-a-budget
branch
September 14, 2026 15:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.unicode-segmentation(already in the tree). A full inline list is a small ontology and keeps descriptions whole.Measured
Recall bench (NVIDIA filings, 52 hand-checked items, schema.org), measured together with #705 on the same run:
The heavier case,
google-deepmind.txtfrom 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_finishescargo test -p utopia-extract -p utopia-server, clippy and fmt clean🤖 Generated with Claude Code