I built a GPT Investment Banker using this 312 PAGE document

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this is an AI agent doing financial analysis I use it to build an llm link chain app that could analyze financial statements in fact it's doing it without fine-tuning on this 300 Page banking annual report right now I'm going to teach you how to build it in five minutes I went down the rabbit hole to discover how to use your own documents to build ai-powered large language model apps with langchain and the results speak for themselves but first of all why should we even bother trying to use our own documents we've already built our own large language model Apple streamlit why they need for docos well it gives you the ultimate flexibility to leverage large language models for tasks that are specific to you provide meeting minutes and create a summary you could upload an assignment outline and have a response generated upload an annual report and have a large language model do the financial analysis for you in fact that's what we're going to be doing we're going to be building our very own personal AI powered investment banker using streamlit and our own annual report to get started we first need to install some dependencies namely Lang chain open AI streamlit tick token chroma DB Pi PDF and crypto Dome while we're at it we're going to need to get an open AI API key it's optional to use the open AI service you could substitute it out for llama CPP or one of the hugging face hosted models you want to vid on that let me know time to create app first up in a new python file called app.pi we're going to import some initial dependencies OS is going to be used to set the API key from langchain.lms will import the open AI service this will be the core llm we use we'll also bring in streamlit while we're at it once that's done we can set the API key and create the open AI Service as an llm if we wanted to we could tune the temperature depending on how creative or objective we wanted our responses we also need somewhere to pass the prompt we can use the streamlit.txt input element to do this if our user hits enter we need a way to send the prompt to the llm let's throw in an if statement here and write out the text of the screen using streamlit.write to start the app it's relatively straightforward just write streamlit run app.pi or whatever your python file is named side note all this code is going to be available in the description below so you can give it a crack yourself this gives us a baseline app and uses open AI to generate responses but there's one key issue here we haven't gone and used our own documents yet let's make except but before we do a word from our sponsors me if you'd like to get up and running with python for machine learning head over to Godot courses from Nick forward slash python where you can take my end-to-end tech fundamentals course or if you want to dive straight into the deep end you can check out my full stack machine learning course at this link here and use YouTube 50 to get 50 off right now back to the video we need to bring in some more dependencies so at the top of our script we're going to bring in pi pdfloader from langchain.document loaders and chroma from langtain dot Vector stores Pi pdfloat is used to load and pass a PDF into memory chroma is a vector store that is critical to using your own documents what actually happens as far as I know is your document is tokenized and loaded into chroma for querying later on this allows you to perform similarity search using similarity metrics like euclidean distance also similar to how Pinecone works we'll do this in a sec alright time to load up our document using the pi PDF loader class we're going to upload a banking annual report I've got the files stored in the same place as my python script so I can just pass the name of the document direct to the class if you wanted to use your own document you could sub in the name of the file here in this case go to be a PDF but there are other loaders available inside of lanechain we can then load the document into chroma using the from documents method to do this pass the pages from the PDF to the loader method and then back to that similarity search using a streamlit expander class we can search through the document in natural text and render the results of the screen say we ask about the performance of the bank chroma will return the relevant passages from the document loaded these will eventually be passed through to the langchain agent to generate a human-like response based on that context but we don't need to do this manually we can use the vector store agent from lanechang this will package it all up pretty nicely last set of imports home stretch out first up we'll import create Vector store agent Vector store toolkit and Vector store info from langchain.agents.agent toolkits the vector store info class as far as I can tell just provides context about the store aka the PDF that we're going to pass through to our llm agent you just pass through a name description and chroma store to that specific class then the magic happens we can pass the vector store info wrapper to Vector store toolkit this makes the PDF available as a tool to length similar to how we use the Wikipedia toolkit in the langchang crash course video and last but not least bring it together with the vector store agent this is the most critical part to the Adrian Creator class we'll pass through our original open AI llm service and the vector store toolkit this packages it all up nicely and will in effect give our large language model agent access to our PDF rather than just outputting responses from the llm like we had previously we can now use the agent and run the prompt through it and again write out the responses to the screen this allows us to ask things like what was the net profit of the company with the response that we're getting back from our GPT investment banker being 4706 million or 56 on the prior year which just so happens to match Note 6 on earnings per share in the notes to the financial statements what initiatives did the bank take towards sustainability our model is calling out the Net Zero asset managers initiative and the Net Zero Banking online this is pretty closely tied to the governance section in the financial statement as well and last but not least summarize the financial performance of the bank the model calls out net profit after taxes increasing by 56 compared to the prior year and EPS increasing by 51 this just so happens to match the letter from the chair of the board of the remuneration committee calling out those exact same npat and EPS numbers the document used was roughly 300 pages in length so documents can take a little while to return a response that being said in 45 lines of code we've got our very own personal investment banker not too shabby if you want to check out the lane chain crash course video I did go and click here
Info
Channel: Nicholas Renotte
Views: 157,734
Rating: undefined out of 5
Keywords: machine learning, python, ai
Id: u8vQyTzNGVY
Channel Id: undefined
Length: 5min 26sec (326 seconds)
Published: Fri May 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.