HomeNewsContactAbout

Fohlarbee - BlogBuilding an AI powered chatpdf within 56hrs using Retrieval Augmented Generation

title image

Think of being able to converse with your PDF's in a more human-like manner.

As a final year student studying Computer Science at the University of Jos. Right from my 100L days I've always struggled with trying to assimilate cumbersome load of PDF's within a short period of time. As of then the current trend of various Large Language Models (LLM's) wasn't on everybody lips as of today, so majority of the work had to be done without the help from AI's.

But years later, the demand became priority, as students also became more exposed to various LLM's which helped reduce the stress of trying to assimilate large amount of reading materials.

But then there was another issue at hand. This platforms only offer limited amount of upload for their free theirs, with likes of OpenAI giving limit to upload for their various models. As students, not everyone has the financial capacity to keep up with such high subscription fees, be it one-time or re-occurring.

Then out of curiosity, I began the creation of My AI Powered SAAS software called ChatiePDF.

This takes off the weighing stress of huge sum of amount for subscriptions and offers users--students and Researchers the ability to interact with various kind of PDF materials at a lesser cost.

As a back-end developer who is keen to building scalable AI powered application for day-day use. This took me about 56hrs to develop (this doesn't include hours of debugging).
With NextJs, Vercel-AI SDK, Pinecone, Cohere-ai, Drizzle and Azure blob storage used as the major stacks.

Here's how ChatiePDF works

When a user drag or drops a PDF. Let's assume it's a two page resume. Each paragraph of the resume is then converted to separate documents themselves which in turn are converted to vector embeddings and then stored into a vector db--this is where Pinecone db comes into play.
When a user gets to prompt based on the context of the PDF, the user prompt is also converted into embeddings and a query is made to Pinecone db to retrieve the more similar to that of the prompt using a technique called Cosine Similarity.

Cosine Similarity is the measure of how similar two non-zero vectors are.

Here's the idea

Assuming you have two vectors (a straight line with a magnitude and a direction) represented by their coordinates. This two vectors tend to be similar if they head in the same direction as one another.
In the context of the ChatiePDF, the embeddings represent the semantic meaning of this text.

Soon as the query is made and the most similar embeddings has been retrieved, this then goes through a function that retrieves it's text content which is then passed to cohere AI to produce a logical response back to the user.

This was quite a fun project to work on, cause I learnt a lot about RAG, Vector embeddings and the use of Vercel-ai SDK.

ChatiePDF is a website that should be saved to your bookmarks.

Try ChatiePDF here.

Feedback's and ways of improvements are welcome. Reach me