Repository navigation
perf(recall): count each source fact's tokens once per recall (#6329) - #6405
Merged
Merged
Conversation
Observations that cite the same source no longer recount its text for every per-observation budget, and an unlimited budget no longer counts at all.
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 #6329. Based on @harshitgupta31415's patch (929aabd) — thanks for the report and the fix.
What changes
truncatedflag. The default 4,096-token total budget path is unchanged apart from the guard it no longer needs.Numbers (this Mac, real tokenizer, median of 5)
The reporter's patch only cached counts when sources repeat; this one always caches (a dict lookup is cheaper than a tokenizer call), which keeps a single code path.
Tests
Two new tests in
tests/test_source_facts_selection.py: a shared source is counted once but still charged to every observation, and an unlimited budget counts nothing. Both fail onmainand pass here; the 10 existing tests still pass.