Add embedding similarity calculations - #993
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #993 +/- ##
=============================================
- Coverage 81.50% 80.07% -1.43%
- Complexity 2923 3013 +90
=============================================
Files 122 124 +2
Lines 11653 11992 +339
=============================================
+ Hits 9498 9603 +105
- Misses 2155 2389 +234
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Great work on this 👏 To me, the math, classes, and tests are really solid. One thing I hit while reading through the When two posts share more than one provider/model pair, there's currently no way to compare them. In Two issues with this:
This is easy to hit in practice: embed a couple of posts with Ollama while testing locally, later re-embed them with OpenAI, and Suggestion: add optional |
Thanks for the review. I did initially have model and provider as arguments you could pass in (thus the discrepancy in that error message) but removed that to keep things as simple as possible. This WP-CLI command is only there for test purposes and the plan is to remove all that code prior to the next release. So I'm happy to make changes there as needed but not overly concerned with making it perfect as it's just a test tool. Curious if you're seeing actual issues in the embedding code or if this is just an issue with that WP-CLI command? Also worth noting the work is not finished here (as you mention, there isn't a real way to delete embeddings yet). All of the actual sync work will be coming in a new PR. |
|
Oh, just the WP-CLI command, the embedding code itself looks solid to me. That explains the error message, now it makes sense, and given the command is throwaway, I wouldn't polish it further. I'll admit I was hoping these CLI commands would actually ship, though. As a plugin developer, I'd probably reach for That said, I get that freezing a debug tool into a public contract before the sync layer exists would be premature. Totally fine waiting for a proper |
So I guess no reason we couldn't leave these types of commands in, just wasn't sure if they'd provide enough value to justify having in place (and having to maintain going forward). I do think once we have all the pieces in place here, most of the functionality that's in the command will be moved out into various other embedding classes (and the command can then be updated to use as much of that as possible). So your note here around the same post being embedded twice with different models is something we'll want to account for in the larger scope here. |
What?
Partially closes #962
Adds a
Vector_Mathclass with various public methods that can be used to run similarity calculations against two vector embeddings. Also adds aVector_Rankerclass to score vectors against one another.Why?
#892 and #975 brought in embedding code from the PHP AI Client. #976 brought in the data layer to store embeddings. This PR is one of the next steps in the overall embedding goal, allowing us to run comparisons from one vector to another.
How?
Vector_Mathclass with various public methods that can be used to run similarity calculations against two vector embeddingsVector_Rankerclass to score vectors against one anotherUse of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Fable 5.1, Opus 5
Used for: Planning approach and executing on that. Review of approach and final review and testing by me
Testing Instructions
Easiest way to test is the custom WP-CLI command added as part of this PR:
Changelog Entry