Building A PDF Summarization App with Gradio and LangChain

Automata Learning Lab · Beginner ·🧠 Large Language Models ·3y ago

Key Takeaways

This video demonstrates how to build a simple PDF summarization app using Gradio and LangChain, including setting up imports, loading a large language model from OpenAI, creating functions to summarize PDFs, and building a user-friendly app interface with Gradio.

Full Transcript

in this video you're going to learn how to build a simple PDF summarization app okay to get started let's set up our Imports so first we're going to import gradu to have the app which is going to be the framework that we're going to use to actually build the actual app then we're going to use Link Chain to do the summarization stuff here I'm importing open AI to access the large language model and the prompt template to do custom prompts for the summarization then we're going to set up a character we're going to import character splitter which we're going to use to split the text document into a PDF into text chunks then we're going to load the summarization chain from link chain and the pi PDF loader to load the PDF so now I'm going to be setting up the large language model from an open AI this is essentially charger PT and I'm setting temperature to 0 to be as precise as possible and I'm setting up the text splitter to split the document into chunks now we're going to do two functions for this one to summarize the PDF and one to do custom summaries so first we're going to be setting up the summarize PDF function which is going to take in the PDF file path and a custom prompt which is going to be an empty string if I'm not doing a custom summary but if I'm doing a custom summary this is going to carry that custom prompt then inside this function I'm going to load the PDF using the pi PDF loader class then I'm going to load and split the documents that I just I loaded the PDF with loader now I'm splitting that into chunks and I'm going to save that to a variable called Docs then I'm going to set up a summarization chain with the load some rise chain function from link chain and I'm going to set the Ching type to map reduce there are many ways to do this there's like the refine method there are a few chain types that you can experiment with but I found that this one works pretty well and then we're going to run our summarization on the document and here I'm setting up a simple if where if the custom prompt is not an empty string I'm going to do a custom summarization so that means what that means that I'm gonna get the custom prompt from the keyword argument in the function and I'm going to build my prompt template using the prompt template class from link chain I'm fitting in the prompt template that I built using the custom proc that I fed to this function and I'm setting input variable Stacks which are going to be the uh essentially is what this function is going to be taking in as the custom prompt and placing it um placing it as the text to summarize then I'm going to summarize the content and in the load summarization chain I'm going to map The Prompt that I just built to that low summarization chain function so this variable goes into here so that this thing understands that it has to do a custom summary then I'm just gonna run my custom summarization and that's it finally here if there's no custom prompt I'm just gonna set custom summary as an empty string because this function returns both a regular summary and a customized summary now essentially before I had this as a separate function like the custom summary like this but I didn't really like this approach so although it's here we're not going to be using this function and finally what I'm going to be doing is I'm going to define a main function where we're going to actually build the app which will have as a backend this function that's going to be doing all the summarization for us so to build the actual app we have to set up our inputs and outputs so the input is going to be the PDF file path as a string so I'm going to feed it to a text box in gradu then I'm going to set up an input for the custom prompt which is going to be the same thing a text boxing radio and then I'm going to set up the output as the output summary variable which is also going to be a text box where it's going to contain the actual summary and then an output custom summary which um I think I'm not going to be using this one yeah so I did this a few versions and now I'm just going through the line by line with the with the code that I built before but [Music] um now what I'm doing is I'm setting up a nice face variable which um takes in a radio interface class and then it feeds the function summarize PDF which is the function that we built here then it's setting up inputs and outputs so as inputs it's a list with the input to the PDF file path and an input to the custom prompt which is a just the text defining the custom prompt that we want and as an output we have output summary and output custom summary which are right here they're going to be the text boxes that are going to be storing the outputs from the summarize PDF remember that summarize PDF function is returning a regular summary and a custom summary if the custom prompt is fed to this function custom prompt I'm sure there are better ways to do it but this was the the way that I found worked the best then I'm going to launch my app and that's pretty much it now I'm just saying um now I'm just going to run the main function and let's test this out so I already I already tested before so it's already working here but let's test it again and see if everything is working great okay so now I click the link with the URL okay that looks good now what we're going to be doing is I'm going to get a path for a PDF this is something that before people had struggled with regarding the finding the path to the PDF so I'm just gonna seed PDF file path right here and then I'm not going to give a custom prompt I'm just going to submit this file path and now it's running so it's going to take a few seconds and once I think usually in my machine which is not exactly a super amazing machine it takes a little bit a little while but boom there we go this paper introduces video Transformer pre-trained video model that captures semantics and structure of instructional videos it's evaluated on six Downstream tasks including step classification mistake step detection etc etc now we can cross check with the actual paper and this is the paper learning and verification of test structure instructional videos video task former is the name of the model that they developed so this summary is perfectly aligned with the actual paper and that's it that's how you build a very simple PDF serverization app using radio and linking if you like this video don't forget to like And subscribe and see you next time cheers

Original Description

Learn how to build a simple PDF summarization app using Gradio and LangChain. You'll discover how to set up imports, load a large language model from OpenAI, create functions to summarize PDFs and build a user-friendly app interface with Gradio. 📚 00:01 - Introduction to the PDF Summarization App 00:30 - Setting up Imports and Loading Language Model 01:03 - Creating Functions for Summarizing PDFs 03:27 - Defining the Main Function for Building the App 04:02 - Setting up Inputs and Outputs in the Gradio Interface 05:13 - Launching the App and Testing 07:05 - Conclusion and Next Steps 🔗 - Github repository: https://github.com/EnkrateiaLucca/summarization_with_langchain - Subscribe!: https://www.youtube.com/channel/UCu8WF59Scx9f3H1N_FgZUwQ - Join Medium: https://lucas-soares.medium.com/membership - Tiktok: https://www.tiktok.com/@enkrateialucca?lang=en - Twitter: https://twitter.com/LucasEnkrateia - LinkedIn: https://www.linkedin.com/in/lucas-soares-969044167/ Don't forget to like and subscribe. Cheers! :)
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Automata Learning Lab · Automata Learning Lab · 53 of 60

1 A Quick Tutorial on NLP Basics
A Quick Tutorial on NLP Basics
Automata Learning Lab
2 Automating your Digital Morning Routine with Python
Automating your Digital Morning Routine with Python
Automata Learning Lab
3 Exploring Problem Solving with Python and Jupyter Notebook #1
Exploring Problem Solving with Python and Jupyter Notebook #1
Automata Learning Lab
4 Summarize Papers with Python and GPT-3
Summarize Papers with Python and GPT-3
Automata Learning Lab
5 An Experiment Tracking Tutorial with Mlflow and Keras
An Experiment Tracking Tutorial with Mlflow and Keras
Automata Learning Lab
6 Automating Google Forms Submissions with Python
Automating Google Forms Submissions with Python
Automata Learning Lab
7 Productivity Tracking With Python and the Notion API
Productivity Tracking With Python and the Notion API
Automata Learning Lab
8 When your Machine Learning Model Fails Do This ;p
When your Machine Learning Model Fails Do This ;p
Automata Learning Lab
9 Machine Learning Tip#1 Practical Deep Learning Course
Machine Learning Tip#1 Practical Deep Learning Course
Automata Learning Lab
10 Machine Learning Tips: Deep Learning Monitor
Machine Learning Tips: Deep Learning Monitor
Automata Learning Lab
11 Machine Learning Tips#5 MLOPs specialization in Coursera #machinelearning
Machine Learning Tips#5 MLOPs specialization in Coursera #machinelearning
Automata Learning Lab
12 Automatically Changing Desktop Wallpaper with Python and the Nasa Image API
Automatically Changing Desktop Wallpaper with Python and the Nasa Image API
Automata Learning Lab
13 Building an Image Classifier to Filter Out Unused Images From Your Photo Album with Machine Learning
Building an Image Classifier to Filter Out Unused Images From Your Photo Album with Machine Learning
Automata Learning Lab
14 Automating VS Code Snippets with Python
Automating VS Code Snippets with Python
Automata Learning Lab
15 How to Set Up a Machine Learning Environment with Conda and Pip-Tools
How to Set Up a Machine Learning Environment with Conda and Pip-Tools
Automata Learning Lab
16 9 Google Search Tips for Machine Learning
9 Google Search Tips for Machine Learning
Automata Learning Lab
17 Thinking Tools
Thinking Tools
Automata Learning Lab
18 Automating Car Search with Python and Data Science
Automating Car Search with Python and Data Science
Automata Learning Lab
19 Generating Images from Text with Stable Diffusion and Hugging Face
Generating Images from Text with Stable Diffusion and Hugging Face
Automata Learning Lab
20 A Practical Introduction to Data Science using the Spaceship Titanic Dataset from Kaggle
A Practical Introduction to Data Science using the Spaceship Titanic Dataset from Kaggle
Automata Learning Lab
21 Jiu Jitsu App with Python and Streamlit
Jiu Jitsu App with Python and Streamlit
Automata Learning Lab
22 2 Apps for Coding In The Ipad Pro
2 Apps for Coding In The Ipad Pro
Automata Learning Lab
23 From Tensorflow to Pytorch?
From Tensorflow to Pytorch?
Automata Learning Lab
24 Building an Audio Transcription App with OpenAI Whisper and Streamlit
Building an Audio Transcription App with OpenAI Whisper and Streamlit
Automata Learning Lab
25 Productivity Tracking with Python Short Summary
Productivity Tracking with Python Short Summary
Automata Learning Lab
26 Automating Expense Reports with Python
Automating Expense Reports with Python
Automata Learning Lab
27 ChatGPT, Angry Pandas and AI Code
ChatGPT, Angry Pandas and AI Code
Automata Learning Lab
28 7 Strategies To Learn Anything Using ChatGPT
7 Strategies To Learn Anything Using ChatGPT
Automata Learning Lab
29 Building a Thought Summarization App with Whisper and GPT3
Building a Thought Summarization App with Whisper and GPT3
Automata Learning Lab
30 Visualize a Neural Net Learning Polynomial Functions
Visualize a Neural Net Learning Polynomial Functions
Automata Learning Lab
31 Automating Notion with Python
Automating Notion with Python
Automata Learning Lab
32 Pose Tracking for Jiu Jitsu - Update #jiujitsu #machinelearning
Pose Tracking for Jiu Jitsu - Update #jiujitsu #machinelearning
Automata Learning Lab
33 Update to my Pose Tracking for Jiu Jitsu Project #machinelearning #jiujitsu #ai #deeplearning
Update to my Pose Tracking for Jiu Jitsu Project #machinelearning #jiujitsu #ai #deeplearning
Automata Learning Lab
34 ChatGPT API Released by OpenAI
ChatGPT API Released by OpenAI
Automata Learning Lab
35 ChatGPT API Response Format #machinelearning #ai #datascience
ChatGPT API Response Format #machinelearning #ai #datascience
Automata Learning Lab
36 Beyond Stable Diffusion with Composer | Automata Learning Lab Paper Series #1
Beyond Stable Diffusion with Composer | Automata Learning Lab Paper Series #1
Automata Learning Lab
37 Beyond Diffusion Models with Composer #machinelearning #ai
Beyond Diffusion Models with Composer #machinelearning #ai
Automata Learning Lab
38 Machine Learning for Jiu Jitsu
Machine Learning for Jiu Jitsu
Automata Learning Lab
39 Prompt Engineering Basics #machinelearning #gpt4 #chatgpt
Prompt Engineering Basics #machinelearning #gpt4 #chatgpt
Automata Learning Lab
40 Visual ChatGPT: Integrating Images with ChatGPT Paper Series#2
Visual ChatGPT: Integrating Images with ChatGPT Paper Series#2
Automata Learning Lab
41 Visual ChatGPT #machinelearning #ai #artificialintelligence
Visual ChatGPT #machinelearning #ai #artificialintelligence
Automata Learning Lab
42 LERF - Language Embeddings + NERF for Querying 3D Spaces #machinelearning #ai
LERF - Language Embeddings + NERF for Querying 3D Spaces #machinelearning #ai
Automata Learning Lab
43 Summarize Papers with Python and ChatGPT
Summarize Papers with Python and ChatGPT
Automata Learning Lab
44 Large Language Models can use Tools Now! #artificialintelligence #machinelearning #ai
Large Language Models can use Tools Now! #artificialintelligence #machinelearning #ai
Automata Learning Lab
45 Sparks of AGI in GPT4? #machinelearning #ai #agi #artificialintelligence
Sparks of AGI in GPT4? #machinelearning #ai #agi #artificialintelligence
Automata Learning Lab
46 Toolformer: LLMs can use Tools! #chatgpt #llms #gpt4 #gpt3 #artificialintelligence
Toolformer: LLMs can use Tools! #chatgpt #llms #gpt4 #gpt3 #artificialintelligence
Automata Learning Lab
47 Talking to Your Notes with LangChain #artificialintelligence #llms #gpt4 #chatgpt
Talking to Your Notes with LangChain #artificialintelligence #llms #gpt4 #chatgpt
Automata Learning Lab
48 How to Talk to a PDF using LangChain and ChatGPT
How to Talk to a PDF using LangChain and ChatGPT
Automata Learning Lab
49 Query Your Own Notes With LangChain
Query Your Own Notes With LangChain
Automata Learning Lab
50 HuggingGPT #machinelearning #artificialintelligence #huggingface #gpt4 #chatgpt
HuggingGPT #machinelearning #artificialintelligence #huggingface #gpt4 #chatgpt
Automata Learning Lab
51 Do as I Can Not as I Say Paper #artificialintelligence #llms #reinforcementlearning
Do as I Can Not as I Say Paper #artificialintelligence #llms #reinforcementlearning
Automata Learning Lab
52 Automating Anki Flashcards with OpenAI and GPT-4
Automating Anki Flashcards with OpenAI and GPT-4
Automata Learning Lab
Building A PDF Summarization App with  Gradio and LangChain
Building A PDF Summarization App with Gradio and LangChain
Automata Learning Lab
54 Auto-GPT #artificialintelligence #gpt4 #llms #autogpt
Auto-GPT #artificialintelligence #gpt4 #llms #autogpt
Automata Learning Lab
55 DocGPT - Chat with Github #artificialintelligence #gpt4 #chatgpt
DocGPT - Chat with Github #artificialintelligence #gpt4 #chatgpt
Automata Learning Lab
56 LLMs for Research and Planning #artificialintelligence #gpt4 #llms
LLMs for Research and Planning #artificialintelligence #gpt4 #llms
Automata Learning Lab
57 How I Use ChatGPT for Interactive Language Learning
How I Use ChatGPT for Interactive Language Learning
Automata Learning Lab
58 Building an Audio Transcription App with Gradio and Whisper
Building an Audio Transcription App with Gradio and Whisper
Automata Learning Lab
59 Summarizing and Querying Multiple Papers with LangChain
Summarizing and Querying Multiple Papers with LangChain
Automata Learning Lab
60 Mojo - The New AI Programming Language?
Mojo - The New AI Programming Language?
Automata Learning Lab

This video teaches how to build a simple PDF summarization app using Gradio and LangChain, covering setting up imports, loading a large language model, creating functions to summarize PDFs, and building a user-friendly app interface.

Key Takeaways
  1. Set up imports for Gradio, LangChain, and OpenAI
  2. Load a large language model from OpenAI
  3. Create a function to summarize PDFs using LangChain
  4. Build a user-friendly app interface with Gradio
  5. Test the app with a sample PDF
💡 Using LangChain and Gradio, you can build a simple PDF summarization app that leverages a large language model from OpenAI to generate accurate summaries.

Related AI Lessons

Claude AI vs ChatGPT: Which One Is Actually Better in 2026?
Compare Claude AI and ChatGPT based on real-world usage and benchmarking to determine which one is better in 2026
Medium · AI
Claude AI vs ChatGPT: Which One Is Actually Better in 2026?
Compare Claude AI and ChatGPT to determine which AI model is better for your needs in 2026
Medium · Programming
IntelliBooks: Classic RAG vs Graph RAG vs Agentic RAG – Choosing the Right AI Retrieval Architecture for Enterprise AI
Learn to choose the right AI retrieval architecture for enterprise AI between Classic RAG, Graph RAG, and Agentic RAG
Dev.to AI
Fluid, natural voice translation with Gemini 3.5 Live Translate
Learn about Gemini 3.5 Live Translate, a new voice translation technology that enables fluid and natural conversations across languages
Dev.to AI

Chapters (7)

0:01 Introduction to the PDF Summarization App
0:30 Setting up Imports and Loading Language Model
1:03 Creating Functions for Summarizing PDFs
3:27 Defining the Main Function for Building the App
4:02 Setting up Inputs and Outputs in the Gradio Interface
5:13 Launching the App and Testing
7:05 Conclusion and Next Steps
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →