Semantic (vector) search for the AI plugin — fixes, tests & validation atop #891 - #943
Semantic (vector) search for the AI plugin — fixes, tests & validation atop #891#943ColinM-sys wants to merge 7 commits into
Conversation
…c-search-implementation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #943 +/- ##
=============================================
- Coverage 76.01% 73.95% -2.07%
- Complexity 3032 3123 +91
=============================================
Files 132 140 +8
Lines 12001 12476 +475
=============================================
+ Hits 9123 9227 +104
- Misses 2878 3249 +371
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:
|
08e4883 to
730c39d
Compare
…1 VIP lint) Replace the unbounded WP_Query (posts_per_page => -1) in Vector_Search with a bounded, filterable lookup of only posts that have a stored embedding, via a new Embedding_Store::get_indexed_ids() using SELECT DISTINCT. Fixes the PHPCS VIP violation and avoids loading every published post into memory to score. Adds tests for the new method.
730c39d to
2c240c9
Compare
The checkbox and the search field can live in separate admin forms, and the previous onchange auto-submit dropped the wpai_semantic flag — so checking the box and clicking "Search Posts" ran a plain keyword search instead of semantic. Bind the flag to whichever form owns the search input and keep it in sync with the checkbox so the search term and the flag always submit together.
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @priyanshuhaldar007, @ColinM-sys. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
|
@ColinM-sys please see the new tracking issue for embedding integration in the AI plugin (#962) and whether you might be interested in coordinating with @artpi and @priyanshuhaldar007 who've also worked on #683 and #891 respectively on the smaller, more reviewable PRs on the path toward implementing embedding support... thanks! |
Tested via WP Playground previewUsed the PR's own Playground preview link (CI artifact Install & load
Feature registration
Runtime behavior without an embedding provider
CI
Net: the plugin-side code in this PR is clean and mergeable-safe on its own — installs without fatals/warnings and degrades gracefully with no provider configured. The real blocker for the feature actually working end-to-end is still the provider layer (#962), same as noted for #891/#683. |
|
Thanks @jeffpaul — I'm in, and #962's approach makes sense. Happy to coordinate with @artpi and @priyanshuhaldar007. From #943 I can carve out focused PRs against
On the testing note in #962: I run local models daily, so I can build the Ollama-based test workflow — validating embedding generation and similarity against a local model with zero provider API costs. Thanks @dugyen for the independent Playground testing above — good confirmation that the plugin-side code is safe standalone and degrades gracefully without a provider, which should make the carved-out foundation PRs straightforward to review. I'll watch php-ai-client#274 (per @dkotter's note on #962) and branch the foundation PRs to line up with it. Happy to take whichever piece is most useful first, or split differently if @artpi or @priyanshuhaldar007 are already picking things up. I'll keep #943 open as the working end-to-end reference until the pieces land, then close it. |
Summary
WordPress's AI plugin does not yet ship semantic / vector search — it exists only in in-progress PRs. This PR moves that capability toward a mergeable state.
Credit / authorship — this builds directly on others' work:
VECTORindex (the future high-performance backend).generate_embeddings().I'm not the author of the underlying feature; this PR adds fixes + tests + validation on top of #891 and reports a key upstream finding.
What THIS PR adds on top of #891
posts_per_page => -1(VIP-prohibited, unbounded) inVector_Search::search()with a bounded, filterable lookup.Embedding_Store::get_indexed_ids( $post_types, $limit )— scores only posts that actually have an embedding (efficiency + fixes the lint), bounded by the newwpai_semantic_search_max_candidatesfilter (default 2000). UsesSELECT DISTINCTto avoid duplicate candidates.test_get_indexed_ids_returns_only_indexed_posts,test_get_indexed_ids_respects_limit.CHANGES_REQUESTEDreview (now stale).Validation
wp-env(WP 7.0.4, MariaDB 12.3.2): plugin loads, no fatals, experiment registers.Indexer→Embedding_Generator→ AI Client → Google embedding provider →Vector_Search), using the Google embedding provider (PR ai-provider-for-google#30) withgemini-embedding-001(3072-dim):Dependency: what else needs to merge for this to work end-to-end
This feature generates embeddings through the AI Client, so it needs an AI provider plugin that ships embedding execution. The client side is already in place (#892, merged), but no released provider does embeddings yet (Google 1.1.0 / OpenAI 1.0.3 / Ollama 1.1.1). That support is in the provider PRs below, and at least one of these must merge and be released for semantic search to work out of the box:
Until one ships, the feature installs and loads but reports "no provider with embedding support configured." This is the same upstream dependency that has #891/#683 marked "blocked"; it lives in the provider layer, not this plugin.
This branch overlaps #891 (it includes that work because #891 isn't merged to
developyet). It's offered to help #891 land; happy to instead submit the delta directly onto #891's branch if maintainers prefer.