Inspiration

I wanted a quick way to know what a web page is about. Since we don't have access to semantic embeddings using on-device AI, I stumbled on the BM25 ranking algorithm that fit the use case of finding relevant paragraphs on a page and squeezing it in the max token size of Gemini Nano.

What it does

This Chrome Extension allows the user to ask natural language questions about a web page's content.

How I built it

The Readability SAX parser implementation allows for a simple way to extract the content of a web page. BM25 finds the relevant paragraph for the query. Gemini Nano receives only the relevant content and the query, the message of which we can pass back to the popup.

Challenges we ran into

My initial idea was to extract keywords and use that to inform the user about the subtext of a page, which could then be highlighted and the user could filter only the most important concepts on the page. That turned out to be a bit tricky, as Gemini Nano does not handle structured outputs that well, so I had difficulty normalizing the keywords. Besides that, I could not find a way to use the keywords to highlight the most relevant parts of the page.

Accomplishments that I'm proud of

The Chrome Extension scales well when I use it on Wikipedia or Hacker News comments. And the extension is privacy focused, so the user can use AI local-first.

What I learned

I wanted to implement RAG for a while to satisfy my curiosity, and thought the only existing implementation was based on semantic embeddings, but it turns out BM25 is suitable for retrieval.

What's next for RAGnificent

If the new Web APIs are published, I would like to publish this to the Chrome Webstore. Some features that come to mind are other retrieval algorithms and retrieval of the sources.

Share this project:

Updates