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