-
Notifications
You must be signed in to change notification settings - Fork 59
Recommended Content Block powered by AI embeddings #881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…Query Loop variation that is registered when using this Provider
…what it's doing. Ensure Action Scheduler is loaded only when we need it. Add framework to generate post embeddings for items that need it when feature is enabled
…n feature is turned on
…ting an embedding fails
…r query loop variation block to run a query using this data
e23ce08
to
df41475
Compare
cy.saveFeatureSettings(); | ||
} ); | ||
|
||
it.skip( 'Can add the Recommended Content block in a post', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note I'm skipping this test for now as it fails in the pipeline. Works fine for me locally but fails consistently when run here. In doing some debugging, seems the block can't be found but couldn't figure out why
Making a note here @dkotter @vikrampm1 to remind us once this is released that we'll likely want to adjust our microsite and ClassifAI overview deck with how this feature now works. Probably also worth a quick scan through the dev docs site to see if there are any updates there that are worth including in this PR. |
@vikrampm1 please open individual follow-up issues for the items that Darin called out:
|
@dkotter I'm not sure if I'm testing this incorrectly, but I'm unable to make this work. This is the ZIP of posts I'm testing with. classifai-posts.xml.zip The Recommended Block is added to the post: I have confirmed with 10% and 100% threshold, and also confirmed that post embedding meta exists for all the posts. |
Just adding my twocents here. I am thinking of content recommendation in a query loop more like a sorting than a filtering. I always want to display some posts at the bottom of an article to keep visitors in my site. Ideally those are as relevant as possible. But even when we don't find anything relevant I still want there to be some posts. |
@Sidsector9 I tested this out and did find an issue, though I think unrelated to your results. I think what you're running into is by design (though we can change this) where if no related results are found we just run a normal query. This is to ensure we always show something instead of just having this section be blank. This also matches @fabiankaegy's point:
I did find an issue though where if a post has this query block added (or any query block) the content from that is used when we generate embeddings. This can lead to unexpected matches because we have partial content from one or more posts that is used as embeddings for a different post, leading to high matches on those chunks. This has been resolved in 082f370 by stripping any Query blocks out before we render content |
As mentioned above, it does work this way right now, where it will run the default query if no relevant results are found. One thing it doesn't do (though I have a |
…to feat/default-templates
feat/886: Add Default Template global settings for Recommended Content Block
…th the default query so we always have the number of items we want
This has been added now, where we backfill the results using the default query if needed. Could look at making this a setting in the future but seems like good default behavior |
…ent with multiple chunks, we compare each chunk against each chunk of all other posts. This means we run the query to get posts multiple times and determine our threshold multiple times. Made these static variables so they only run once, irregardless of how many chunks the original content has
$backfill_query = new \WP_Query( | ||
array_merge( | ||
$new_query_vars, | ||
[ | ||
'posts_per_page' => (int) $query_vars['posts_per_page'] - $post_count, | ||
'post__not_in' => [ $post_id ], | ||
'fields' => 'ids', | ||
] | ||
) | ||
); | ||
|
||
// Add the backfilled posts to the post__in array. | ||
$post__in = array_merge( $post__in, $backfill_query->posts ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG why did I never think of doing it this way.... 🤦 I spent so much time hacking the internals of how queries are done to add backfilling support. This is so nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, and works as per description and discussion 👍
Description of the Change
We currently have a
Recommendation Service
section with a single Feature within that,Recommended Content
. At the moment, the only Provider for this is Azure AI Personalizer though that has been deprecated by Microsoft and while we have kept the code in place (for now) we don't recommend anyone uses that.We've looked into various alternatives(see #392) but haven't found a similar service to Azure AI Personalizer that we've liked. We have been using AI embeddings in other places to get content that is similar to each other (term cleanup, smart 404, classification) and I've had the idea for awhile to use that same concept to power content recommendations in a Recommended Content block. That's what this PR introduces.
Worth noting this is different from the recommendations Azure AI Personalizer provides, which are supposed to be more personalized content recommendations rather than just similar content recommendations.
This new Provider does the following:
While I see this as being a complete feature, there are additional improvements we could look to make, potentially in this PR but ideally in follow up PRs so we can ship this sooner:
Screenshots
How to test the Change
Tools > ClassifAI > Recommendation Service > Recommended Content
Changelog Entry
Credits
Props @dkotter, @fabiankaegy
Checklist: