Using OpenAI's APIs (embeddings and GPT-3), we can search through large PDFs and ask questions about them.
The results remind me of The Librarian from Snow Crash - an AI-powered super-machine that lives in a library capable of accessing and summarising large quantities of text.
Try it out here
First, you need to generate embeddings for your PDF.
-
cd scripts
-
Create and fill in
.environment.rb
using.environment.rb.sample
as an example -
Install Ruby if you haven't done so already
-
Install the needed gems:
bundle install
- Turn your PDF into embeddings for GPT-3:
ruby pdf_to_embeddings.rb
Note: Make sure to cd
into the scripts
directory before running the script.
The backend accepts a question and returns the answer. It's a serverless lambda that runs on AWS.
- Install the Serverless Framework
If you haven't already, you'll need to set up your AWS credentials.
- Deploy the API:
cd backend
npm run deploy
The frontend is written with React and Next.js. You can host it anywhere you like. I prefer Vercel.
To run locally, cd frontend
and:
- Fetch dependencies:
yarn or npm install
- Run the development server:
yarn dev or npm run dev