Document and validate search scoring implementation using chunk embeddings#35
Open
Document and validate search scoring implementation using chunk embeddings#35
Conversation
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: streed <805140+streed@users.noreply.github.com>
…dings Co-authored-by: streed <805140+streed@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] The search scoring should use the distance between the query embedding and the returned chunk's embedding.
Document and validate search scoring implementation using chunk embeddings
Sep 24, 2025
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.
This PR addresses the requirement that "search scoring should use the distance between the query embedding and the returned chunk's embedding" by documenting and validating that the current implementation already correctly implements this behavior.
Analysis
Upon investigation, the search implementation in
SearchWithOptionsalready correctly uses chunk-level embeddings for distance calculation:The system:
score = 1.0 - distanceChanges Made
Enhanced Code Documentation
Comprehensive Testing
TestSQLiteStorage_SearchScoring_ChunkEmbeddingDistancetest that validates:Documentation
SEARCH_SCORING.mdexplaining the implementation details, score interpretation, and performance characteristicsValidation
The implementation was tested with known embedding vectors to verify mathematical correctness:
All existing tests continue to pass, confirming no regressions were introduced.
Conclusion
The search scoring implementation was already correct and meeting the specified requirements. This PR adds explicit documentation, validation, and clarity to make the chunk embedding distance calculation behavior transparent and well-tested.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.