feat(memory): add hotness scoring for cold/hot memory lifecycle (#296)#297
Open
r266-tech wants to merge 1 commit intovolcengine:mainfrom
Open
feat(memory): add hotness scoring for cold/hot memory lifecycle (#296)#297r266-tech wants to merge 1 commit intovolcengine:mainfrom
r266-tech wants to merge 1 commit intovolcengine:mainfrom
Conversation
…engine#296) Add a hotness_score() function that combines access frequency (sigmoid of log1p(active_count)) with time-based recency decay (exponential, 7-day half-life) to produce a 0.0-1.0 score for each context. The hierarchical retriever now blends this hotness score with the semantic similarity score: final = (1 - alpha) * semantic + alpha * hotness, where alpha defaults to 0.2 (HOTNESS_ALPHA class constant). Key properties: - alpha=0 preserves existing behavior exactly (backward compatible) - Default alpha=0.2 gives a mild boost without overriding semantic relevance - No schema changes, no Context class modifications - Pure additive: new file + minimal retriever modification Closes volcengine#296
|
|
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.
Summary
Implements cold/hot memory lifecycle management as requested in #296.
Adds a hotness score that combines access frequency and recency to boost frequently-used, recently-updated contexts in search results.
Changes
New:
openviking/retrieve/memory_lifecycle.pyhotness_score(active_count, updated_at, now, half_life_days)→float [0.0, 1.0]sigmoid(log1p(active_count)) * exp_decay(age, half_life=7d)Modified:
openviking/retrieve/hierarchical_retriever.py_convert_to_matched_contexts()final_score = (1 - alpha) * semantic_score + alpha * hotness_scoreHOTNESS_ALPHA = 0.2(class constant, easily configurable)New:
tests/test_memory_lifecycle.pyBackward Compatibility
active_countandupdated_atfields on ContextDesign Decisions
Closes #296