Member-only story

Talking to PDFs: GPT-4 and LangChain

A step-by-step guide to interactive documentation

Ulrik Thyge Pedersen
Better Programming
5 min readMay 9, 2023

Image by Author with @MidJourney

Have you ever wanted to create a chatbot that can answer questions about PDF files?

With the help of GPT-4 and LangChain, it’s now easier than ever to create a chatbot that can do just that! In this article, we’ll guide you through the process of creating your very own PDF chatbot using GPT-4 and LangChain.

First, let’s start with some background information on GPT-4 and LangChain. GPT-4 is the latest version of the GPT (Generative Pre-trained Transformer) language model developed by OpenAI.

It’s capable of generating high-quality human-like text that can be used for a wide range of natural language processing tasks, including chatbots.

LangChain, on the other hand, is a Python library that provides an easy-to-use interface for creating chatbots powered by GPT-4. Now, let’s get started with creating our PDF chatbot using GPT-4 and LangChain!

Install Dependencies

To get started, we’ll need to install a few dependencies. First, let’s install the latest version of LangChain using pip:

pip install langchain

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Ulrik Thyge Pedersen
Ulrik Thyge Pedersen

Written by Ulrik Thyge Pedersen

Senior Data Scientist @NTT Data | From Science to Data Science | Kaggle Master | linkedin.com/in/ulrikthygepedersen | github.com/UlrikThygePedersen

Responses (3)

Mr Pedersen, I realised that you are utilizing the default constructors ( e.g "llm=OpenAI()"). I would like to know how are you setting the "gpt-4" model name. In the .env file maybe? Thank you.

5

I definitely wanna try this! I always wanted to try Langchain. Can I get back to you if I need help to do this?

1

Great article, however for newbies with little to no experience of langchain, it's sort of incomplete. I understand spoon feeding is not ideal, but it saves so much time if the complete code is provided. Still a good read though.