-
Notifications
You must be signed in to change notification settings - Fork 5
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
Related articles with OpenAI embeddings on SQLite vectors #280
Merged
Conversation
This file contains 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
sqlpkg install raised a checksum error so I‘m using the gem distribution instead
Codecov ReportAttention: Patch coverage is
|
It’s not likely published posts will change signficantly after publishing so we‘ll only batch the embedding jobs for published posts without an embedding already created. This way we don‘t incur redundant API calls for every post on every deploy.
Cheaper and better according to the docs
rossta
force-pushed
the
feat/embeddings
branch
from
November 17, 2024 22:18
c386bc2
to
71b588f
Compare
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.
Articles now display related articles.
In this PR, we explore the using of "embeddings" for similarity search. Embeddings are "a measure of the relatedness of text strings" [as described in the OpenAI docs](OpenAI’s text embeddings measure the relatedness of text strings). We’re using OpenAI to generate embeddings for each article, storing embeddings as vectors in SQLite using the sqlite-vec extension, and querying for related articles based on embedding "distance" (similarity) across articles.
Helpful resources
sqlite-vec
: https://alexgarcia.xyz/sqlite-vec/Though Aaron‘s video uses PHP and libsql (a SQLite fork that has its own vector support), the concepts are similar and serve as inspiration to what we accomplish here.
This builds on #273 where we implemented Page topics including content analysis with OpenAI to associate articles with topics.