pdfGPT
Demo
-
Demo URL: https://bhaskartripathi-pdfgpt-turbo.hf.space
-
Demo Video:

Version Updates (27 July, 2023):
- Improved error handling
- PDF GPT now supports Turbo models and GPT4 including 16K and 32K token model.
- Pre-defined questions for auto-filling the input.
- Implemented Chat History feature.

Note on model performance
If you find the response for a specific question in the PDF is not good using Turbo models, then you need to understand that Turbo models such as gpt-3.5-turbo are chat completion models and will not give a good response in some cases where the embedding similarity is low. Despite the claim by OpenAI, the turbo model is not the best model for Q&A. In those specific cases, either use the good old text-DaVinci-003 or use GPT4 and above. These models invariably give you the most relevant output.
Upcoming Release Pipeline:
- Support for Falcon, Vicuna, Meta Llama
- OCR Support
- Multiple PDF file support
- OCR Support
- Node.Js based Web Application - With no trial, no API fees. 100% Open source.
Problem Description :
- When you pass a large text to Open AI, it suffers from a 4K token limit. It cannot take an entire pdf file as an input
- Open AI sometimes becomes overtly chatty and returns irrelevant response not directly related to your query. This is because Open AI uses poor embeddings.
- ChatGPT cannot directly talk to external data. Some solutions use Langchain but it is token hungry if not implemented correctly.
- There are a number of solutions like https://www.chatpdf.com, https://www.bespacific.com/chat-with-any-pdf, https://www.filechat.io they have poor content quality and are prone to hallucination problem. One good way to avoid hallucinations and improve truthfulness is to use improved embeddings. To solve this problem, I propose to improve embeddings with Universal Sentence Encoder family of algorithms (Read more here: https://tfhub.dev/google/collections/universal-sentence-encoder/1).
Solution: What is PDF GPT ?
- PDF GPT allows you to chat with an uploaded PDF file using GPT functionalities.
- The application intelligently breaks the document into smaller chunks and employs a powerful Deep Averaging Network Encoder to generate embeddings.
- A semantic search is first performed on your pdf content and the most relevant embeddings are passed to the Open AI.
- A custom logic generates precise responses. The returned response can even cite the page number in square brackets([]) where the information is located, adding credibility to the responses and helping to locate pertinent information quickly. The Responses are much better than the naive responses by Open AI.
- Andrej Karpathy mentioned in this post that KNN algorithm is most appropriate for similar problems: https://twitter.com/karpathy/status/1647025230546886658
- Enables APIs on Production using langchain-serve.
Docker
Run docker-compose -f docker-compose.yaml up
to use it with Docker compose.
Use pdfGPT
on Production using langchain-serve
Local playground
- Run
lc-serve deploy local api
on one terminal to expose the app as API using langchain-serve.
- Run
python app.py
on another terminal for a local gradio playground.
- Open
http://localhost:7860
on your browser and interact with the app.
Cloud deployment
Make pdfGPT
production ready by deploying it on Jina Cloud.
lc-serve deploy jcloud api
<details>
<summary>Show command output</summary>
╭──────────────┬──────────────────────────────────────────────────────────────────────────────────────╮
│ App ID │ langchain-3ff4ab2c9d │
├──── ──────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Phase │ Serving │
├──────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Endpoint │ https://langchain-3ff4ab2c9d.wolf.jina.ai │
├──────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ App logs │ dashboards.wolf.jina.ai │
├──────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
│ Swagger UI │ https://langchain-3ff4ab2c9d.wolf.jina.ai/docs │
├──────────────┼──────────────────────────────────────────────────────────────────────────────────────┤