-
Notifications
You must be signed in to change notification settings - Fork 602
Add movie recommendation example using IMap and similarity search [AI-298] #710
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
Add movie recommendation example using IMap and similarity search [AI-298] #710
Conversation
TomaszGaweda
left a comment
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.
Two nits, overall good job :)
| // transform user input to vector | ||
| float[] query = embeddingModel.embed(userInput).content().vector(); | ||
|
|
||
| // find & output top 10 similar matches of plot summary to given text |
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.
maybe we could do 2 in 1 (via some flag etc), so code wouldn't be commented?
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.
VectorPredicates.nearestNeighbours is not yet available even in 6.0-SNAPSHOT, so the example would not compile
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.
ok, then for now it's better to remove the commented code, as someone may try to use it
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.
ok, that will be probably less confusing: a82b3b5
...e-recommendation/src/main/java/com/hazelcast/samples/ai/movies/TextSimilaritySearchImap.java
Outdated
Show resolved
Hide resolved
…/movies/TextSimilaritySearchImap.java Co-authored-by: Tomasz Gawęda <[email protected]>
…for embedding entry processor
TomaszGaweda
left a comment
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.
Few comments, but I don't think re-review will be need, so approving in advance :) Good job!
| // transform user input to vector | ||
| float[] query = embeddingModel.embed(userInput).content().vector(); | ||
|
|
||
| // find & output top 10 similar matches of plot summary to given text |
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.
ok, then for now it's better to remove the commented code, as someone may try to use it
| + "took " + Timer.secondsElapsed(start) + " seconds"); | ||
| } | ||
|
|
||
| public static class MovieMetadata implements Serializable { |
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.
record?
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.
vector field is mutable. this could be avoided, in this case it is more a matter of taste. both solutions would be equally simple
| TextSimilaritySearchImap.offloaded = false; | ||
| TextSimilaritySearchImap.main(new String[]{"200% cars " + System.lineSeparator()}); | ||
| } | ||
| } No newline at end of file |
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.
nit, line endings:
| } | |
| } | |
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.
| */ | ||
| public class TextSimilaritySearchImap { | ||
|
|
||
| static boolean offloaded = true; |
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.
can you write a quick comment what it means "offloaded" in this particular case? Will be easier to understand for people.
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.
First from a series of AI related examples. This example demonstrates the idea of similarity search implemented in a straight-forward, simple but not the most efficient way. This is example code for an upcoming blog post.
Fixes https://hazelcast.atlassian.net/browse/AI-298
Note to reviewers: the PR contains quite large files (~80MB) - movie data.
Checklist: