PDF-Highlight-OA submission - Victor Huang#23
Open
vichua2006 wants to merge 16 commits into
Open
Conversation
Feat: upload pdf and embedding to cloud
Feat/search embedding
This file contains hidden or 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
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.
Setup Instructions!!
pnpm installcp .env.example .envpnpm run devImplementation 🔧
features implemented:
features not implemented 😥:
My Ideal Approach to the Challenge
Start wayyyy earlier (100% my own fault, didn't plan well for exams)
Extending existing application
Persist PDFs + embeddings on Supabase
pdfs/(public) stores raw files.text_vec= OpenAI text-embedding-3-small ( dims).Embeddings: page-level now, smaller chunks later
chunk_no = 0).chunk_no = 1, 2,...)/backfilled if needed—no schema change requiredUpload flow
pdftableembeddingtableSearch flow
search_embedding(q,k)which executesORDER BY text_vec <=> q LIMIT kusing pgvector approxinate-nearest-neighbor index.{doc_id, page_no, score}#page=nin PDF.js).Future improvements
embeddingtable) and apply weighted scoring for search query.content_hashallows deduplication and skip-processing.Challenges
pdfjsto work properly on server-side, was an annoying version issue, found solution via StackOverflow (and a looot of whacking at it with AI)Summary
I really enjoyed the challenge! It was super fun to design the db schema with extra considerations for embedding type and granularity (tho perhaps premature lol). Also finally got to use Supabse for a project, and honestly it's pretty sweet that it has its own bucket AND supports pgvectors. Would really have loved to finish the UI components & the highlighting storage but I started a bit late 😔. Overall learned a whole lot from this challenge, and would love to do more of it 😁
Testing
unfortunately semantic search didn't make it to the UI, but after uploading a couple pdfs, could be tested as such:
using Postman/curl/etc, query
http://localhost:3000/api/searchwithScreenshots
pdftable (Seven Databases in Seven Weeks successfully uploaded and indexed 🎉 ):embeddingtable:Embedding query w postman: