Building a Summarization System with LangChain - Part 3 Using ChatGPT Turbo

Sam Witteveen · Intermediate ·🧠 Large Language Models ·3y ago

Key Takeaways

This video demonstrates how to use the ChatGPT Turbo API for summarization, building on concepts from previous videos. It shows how to use the API to summarize articles, extract key facts, and create triples.

Full Transcript

okay this video will be just a quick one to follow up how could you do the summarization with the chat GPT turbo API so I'm going to show you we've gone through two videos now of doing it with the standard one and just recapping there you could do it either through the summarization chains or you could actually just set up a large language model and pass it in so we've got the exact same article about coinbase that we had in the last video so you can see the facts there and doing the fact extraction we get that with the standard API so with the chechi BT API there are a couple of different things we need to think about one that this is built for chat the big difference with this is you now have different sort of prompts and different inputs based on whether it's the part of the system whether it's a user whether it's the ai's response that raises some interesting issues of that we need to think about okay how are we going to package this up so if you look at just doing a standard chat with this we just pass in a human message and that probably has a system message on top of that but just doing this this is an example from their docs we're passing a human message and you can see it does it quite nicely so just doing a normal summary the way I've done it is that you use the system message to set up the context of what the whole thing is about so in this case the system message is you're an expert at making strong factual summarizations take the article submitted by the user and produce a factual useful summary here we're not using the user to give any instructions the user is just going to be putting in the actual article So the instructions are coming in the system message here you can think of these as like placeholder tokens that tell the model different kinds of information so a system message token tells it setting up the context setting up the task often that kind of thing and then the human message is what you would expect to get from the user so we take this we're passing our article as the human message so we've got these messages this list of messages and if we're actually doing it in chat we would have system human AI response Etc and this messages list can get reasonably long doing this but here because we really just want to translate one thing and then get it back we're not actually setting this up as conversational chat so we can just pass in the article there and sure enough it gives us a really nice summary back just from doing that it's treated it like a I guess in some ways you could think of it maybe treating it like a conversation but it's eliminated the bits about the conversation because we've set the system to basically just take the article submitted by the user and produce a factual summary does it work for the bullet lists ones yeah you can use it for this ones again here you would change the system message your human message is going to be the article just like before but the system message here is you're an expert at making strong factual summarization so the same as before but now extract the key facts out of this text don't include opinions give each fact a number and keep them short sentences and we can see that it gives back pretty nice information not that different not hugely different than what we were getting before the thing to think about here though is that each of these models tensed a little bit of style or personality to itself so you want to play around with prompt sometimes you're going to have to change the prompt for the kind of article or the kind of documentation Etc that you're summarizing so that works what about making the triples so normally what I was doing to make the triples was I was passing in these facts but one of the cool things with this is that we can actually just pass in so we can do it like that but we can also just pass in the article Itself by passing in the article itself we can get triples and this is like doing it the old way with this is doing one way so here we're basically just passing these in but we can also do it like this where we've got so actually sorry that was just extracting the the facts out there and what I was playing around with was that you could pass this in but actually with the chat gbt it seems to get better response if you actually just pass in the full article so rather than pass the list of facts which would you can play with this you're just passing the responses dot content in here but what I've passed in is the whole article and you can see that it's giving us number for each triple it's given us the subject to predicate object for each of these so it would be pretty easy to even apps chat should be T to write a piece and python code that would extract these out into whatever format you wanted to use in your knowledge graph once we've got them in this kind of format it makes it very easy to do and looking at it it seems to have done quite a nice job of doing it like this which seems different than the previous one was doing it's cut off a little bit at the end this because of the number of Max tokens that I've set so that's something that you could play around with so as always if you've got any questions please put them in the comments if this was useful to you please click and subscribe and I'll see you in the next video

Original Description

Colab Code Notebook: https://drp.li/FWph5 This video looks at how to use the latest ChatGPT ('gpt-3.5-turbo') API from OpenAI for summarization. It builds on concepts from the previous 2 videos on summarization. My Links: Twitter - https://twitter.com/Sam_Witteveen Linkedin - https://www.linkedin.com/in/samwitteveen/ Github: https://github.com/samwit/langchain-tutorials https://github.com/samwit/llm-tutorials #LangChain #BuildingAppswithLLMs
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Sam Witteveen · Sam Witteveen · 12 of 60

1 LangChain Basics Tutorial #1 - LLMs & PromptTemplates with Colab
LangChain Basics Tutorial #1 - LLMs & PromptTemplates with Colab
Sam Witteveen
2 LangChain Basics Tutorial #2 Tools and Chains
LangChain Basics Tutorial #2 Tools and Chains
Sam Witteveen
3 ChatGPT API Announcement & Code Walkthrough with LangChain
ChatGPT API Announcement & Code Walkthrough with LangChain
Sam Witteveen
4 Trying Out Flan 20B with UL2 - Working in Colab with 8Bit Inference
Trying Out Flan 20B with UL2 - Working in Colab with 8Bit Inference
Sam Witteveen
5 LangChain - Conversations with Memory (explanation & code walkthrough)
LangChain - Conversations with Memory (explanation & code walkthrough)
Sam Witteveen
6 LangChain Chat with Flan20B
LangChain Chat with Flan20B
Sam Witteveen
7 LangChain - Using Hugging Face Models locally (code walkthrough)
LangChain - Using Hugging Face Models locally (code walkthrough)
Sam Witteveen
8 PAL : Program-aided Language Models with LangChain code
PAL : Program-aided Language Models with LangChain code
Sam Witteveen
9 Building a Summarization System with LangChain and GPT-3 - Part 1
Building a Summarization System with LangChain and GPT-3 - Part 1
Sam Witteveen
10 Building a Summarization System with LangChain and GPT-3 - Part 2
Building a Summarization System with LangChain and GPT-3 - Part 2
Sam Witteveen
11 Microsoft's Visual ChatGPT using LangChain
Microsoft's Visual ChatGPT using LangChain
Sam Witteveen
Building a Summarization System with LangChain - Part 3 Using ChatGPT Turbo
Building a Summarization System with LangChain - Part 3 Using ChatGPT Turbo
Sam Witteveen
13 LangChain Agents - Joining Tools and Chains with Decisions
LangChain Agents - Joining Tools and Chains with Decisions
Sam Witteveen
14 Investigating Alpaca 7B - Finetuned LLaMa LLM
Investigating Alpaca 7B - Finetuned LLaMa LLM
Sam Witteveen
15 Comparing LLMs with LangChain
Comparing LLMs with LangChain
Sam Witteveen
16 Running Alpaca7B in Colab
Running Alpaca7B in Colab
Sam Witteveen
17 How to finetune your own Alpaca 7B
How to finetune your own Alpaca 7B
Sam Witteveen
18 How to make a custom dataset like Alpaca7B
How to make a custom dataset like Alpaca7B
Sam Witteveen
19 Understanding Constitutional AI - the paper and key concepts
Understanding Constitutional AI - the paper and key concepts
Sam Witteveen
20 Using Constitutional AI in LangChain
Using Constitutional AI in LangChain
Sam Witteveen
21 Talking to Alpaca with LangChain - Creating an Alpaca Chatbot
Talking to Alpaca with LangChain - Creating an Alpaca Chatbot
Sam Witteveen
22 Text-to-video-synthesis with Diffusers and Colab
Text-to-video-synthesis with Diffusers and Colab
Sam Witteveen
23 Meet Dolly the new Alpaca model
Meet Dolly the new Alpaca model
Sam Witteveen
24 Checking out the Cerebras-GPT family of models
Checking out the Cerebras-GPT family of models
Sam Witteveen
25 A Step-by-Step Guide to Fine-Tuning Your Dolly Model (tutorial)
A Step-by-Step Guide to Fine-Tuning Your Dolly Model (tutorial)
Sam Witteveen
26 Is GPT4All your new personal ChatGPT?
Is GPT4All your new personal ChatGPT?
Sam Witteveen
27 Raven - RWKV-7B RNN's LLM Strikes Back
Raven - RWKV-7B RNN's LLM Strikes Back
Sam Witteveen
28 Talk to your CSV & Excel with LangChain
Talk to your CSV & Excel with LangChain
Sam Witteveen
29 Vicuna - 90% of ChatGPT quality by using a new dataset?
Vicuna - 90% of ChatGPT quality by using a new dataset?
Sam Witteveen
30 Koala Revealed: The ChatGPT Alternative You Need to Know! 🔍
Koala Revealed: The ChatGPT Alternative You Need to Know! 🔍
Sam Witteveen
31 Running Koala for free in Colab. Your own personal ChatGPT? (tutorial)
Running Koala for free in Colab. Your own personal ChatGPT? (tutorial)
Sam Witteveen
32 BabyAGI: Discover the Power of Task-Driven Autonomous Agents!
BabyAGI: Discover the Power of Task-Driven Autonomous Agents!
Sam Witteveen
33 Auto-GPT - How to Automate a Task Based AI with GPT-4
Auto-GPT - How to Automate a Task Based AI with GPT-4
Sam Witteveen
34 Improve your BabyAGI with LangChain
Improve your BabyAGI with LangChain
Sam Witteveen
35 Generative Agents - Deep Dive and GPT-4 Recreation
Generative Agents - Deep Dive and GPT-4 Recreation
Sam Witteveen
36 GPT4ALLv2: The Improvements and Drawbacks You Need to Know!
GPT4ALLv2: The Improvements and Drawbacks You Need to Know!
Sam Witteveen
37 Dolly 2.0 by Databricks: Open for Business but is it  Ready to Impress!
Dolly 2.0 by Databricks: Open for Business but is it Ready to Impress!
Sam Witteveen
38 Red Pajama - Operation: Freeing LLaMA
Red Pajama - Operation: Freeing LLaMA
Sam Witteveen
39 Investigating Open Assistant - Models, Datasets and Addons
Investigating Open Assistant - Models, Datasets and Addons
Sam Witteveen
40 Investigating MiniGPT-4 - The Secret behind GPT-V?
Investigating MiniGPT-4 - The Secret behind GPT-V?
Sam Witteveen
41 Stable LM 3B - The new tiny kid on the block.
Stable LM 3B - The new tiny kid on the block.
Sam Witteveen
42 Bard can now code and put that code in Colab for you.
Bard can now code and put that code in Colab for you.
Sam Witteveen
43 Checking out Bark: a Text to Speech system by Suno AI
Checking out Bark: a Text to Speech system by Suno AI
Sam Witteveen
44 Fine-tuning LLMs with PEFT and LoRA
Fine-tuning LLMs with PEFT and LoRA
Sam Witteveen
45 Master PDF Chat with LangChain - Your essential guide to queries on documents
Master PDF Chat with LangChain - Your essential guide to queries on documents
Sam Witteveen
46 Using LangChain with DuckDuckGO Wikipedia & PythonREPL Tools
Using LangChain with DuckDuckGO Wikipedia & PythonREPL Tools
Sam Witteveen
47 Building Custom Tools and Agents with LangChain (gpt-3.5-turbo)
Building Custom Tools and Agents with LangChain (gpt-3.5-turbo)
Sam Witteveen
48 StableVicuna: The New King of Open ChatGPTs?
StableVicuna: The New King of Open ChatGPTs?
Sam Witteveen
49 WizardLM: Evolving Instruction Datasets to Create a Better Model
WizardLM: Evolving Instruction Datasets to Create a Better Model
Sam Witteveen
50 LaMini-LM - Mini Models Maxi Data!
LaMini-LM - Mini Models Maxi Data!
Sam Witteveen
51 Finding the Best Free ChatGPT
Finding the Best Free ChatGPT
Sam Witteveen
52 MPT-7B - The First Commercially Usable Fully Trained LLaMA Style Model
MPT-7B - The First Commercially Usable Fully Trained LLaMA Style Model
Sam Witteveen
53 LangChain Retrieval QA Over Multiple Files with ChromaDB
LangChain Retrieval QA Over Multiple Files with ChromaDB
Sam Witteveen
54 LangChain Retrieval QA with Instructor Embeddings & ChromaDB for PDFs
LangChain Retrieval QA with Instructor Embeddings & ChromaDB for PDFs
Sam Witteveen
55 LangChain + Retrieval Local LLMs for Retrieval QA - No OpenAI!!!
LangChain + Retrieval Local LLMs for Retrieval QA - No OpenAI!!!
Sam Witteveen
56 Transformers Agent - Is this Hugging Face's LangChain Competitor?
Transformers Agent - Is this Hugging Face's LangChain Competitor?
Sam Witteveen
57 StarCoder - The LLM to make you a coding star?
StarCoder - The LLM to make you a coding star?
Sam Witteveen
58 Testing Starcoder for Reasoning with PAL
Testing Starcoder for Reasoning with PAL
Sam Witteveen
59 The New Wizards - Unfiltered & Unaligned
The New Wizards - Unfiltered & Unaligned
Sam Witteveen
60 Camel + LangChain for Synthetic Data & Market Research
Camel + LangChain for Synthetic Data & Market Research
Sam Witteveen

This video teaches how to use the ChatGPT Turbo API to build a summarization system, including how to summarize articles, extract key facts, and create triples. It covers the basics of using the API, including setting up system messages and human messages, and provides examples of how to use the API in practice.

Key Takeaways
  1. Set up a Colab Code Notebook
  2. Import the necessary libraries and install the LangChain library
  3. Use the ChatGPT Turbo API to summarize an article
  4. Extract key facts from the article using the API
  5. Create triples from the article using the API
  6. Experiment with different prompts and system messages to improve results
💡 The ChatGPT Turbo API can be used to build a powerful summarization system, and by experimenting with different prompts and system messages, you can improve the accuracy and effectiveness of the system.

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
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →