Hello, guys, and welcome to this ZTM project.
We will build together, step -by -step,
line -by -line, an LLM -powered question -answering application for custom or
private documents.
Before we get started with Lanchain,
Pinecon, OpenAI, and all these amazing technologies, I'd like to show you a demo
of what they can do as we progress.
We'll be following a learning -by -doing
approach, and what you see next is what we'll be doing together throughout this project.
We won't jump directly into the project, because I also want you to build a strong
foundation in Lanchain so that you can create custom LLM applications.
After a short introduction to Lanchain, we'll dive into its main components.
We'll talk about LLM wrappers, chains, and agents, and how to combine them with
the Pinecon Vector Datastore and with OpenAI's models.
After this big section, we'll move on to the actual question -answering project.
Let's take a look at a short preview of what we'll build.
Let's imagine that you want to start a business in the EU.
All EU business entities must follow the GDPR regulation, which was implemented by
the European Union to protect the privacy and personal data of EU citizens.
It standardizes data protection laws across all EU member states and imposes
strict rules on controlling and processing personally identifiable information.
If you don't comply, you could be fined hundreds of thousands of euros, and your
business could be closed.
This is not a joke.
Here is the GDPR website.
As you can see, there are tens of
chapters, and the PDF file is 88 pages long.
You could probably spend a few full days
reading and understanding it, or you could hire a specialized lawyer to
explain it to you.
And that's not a cheap job.
Alternatively, you could build an LLM application that learns the content of
this document so that you can ask it questions about anything related to it.
It's like having that expensive lawyer in front of you, but for free.
I used this example because it's something that's well known and of
interest in Europe.
But you could use any other private
document, instruction manuals, legal or accounting documents, medical studies,
treatment plans, and so on.
The AI model was not trained on this set
of data because it's not public or is too recent.
Once you build the application, you can
use it with any other document.
I'm loading the 88 -page PDF into a
Lanchain document.
I'm running the code in this cell.
It's loading the file.
Now I'm splitting it into smaller chunks.
There are 856 chunks.
Next, I'll embed the chunks into numeric
vectors and insert them into a Pinecon index.
I'm running the code.
It's embedding the chunks, creating the Pinecon index, and inserting both the
chunks and the embeddings into the Pinecon index.
It takes some time, so I'm pausing the video until it's done.
It is done, and the embeddings are now in the Pinecon index.
The vector embeddings.
Let's ask a few questions.
I'm running this piece of code.
And the first question will be, what are
the main points described in the document?
And I've got the answer.
Ok.
Let's ask what is GDPR?
What is GDPR?
And it says that GDPR stands for General
Data Protection Regulation. And that it is an EU law.
Very good.
The next question.
Tell me more about the requirement for consent, please.
Very good.
And the last question.
What about the right to be forgotten?
This is something very interesting.
This is the answer.
All the answers were given only based on
the content of that document.
You can use any other document in any
format instead.
This is amazing, and in my opinion, this
opens up an infinite number of use cases.
We'll probably add the application, a
fancy web interface, and that's it.
Great.
Now we'll move on and dive into LangShare.
Let's get started.