PyQuant News 🐍
PyQuant News 🐍

@pyquantnews

12 Tweets 6 reads Jul 28, 2024
The single most powerful tool for quants, traders, and coders in 2024:
LangChain
Over the past 3 months I spent 50 hours down the rabbit hole to:
• Use the internet
• Search and summarize PDFs
• Use Wikipedia data in prompts
Here's one of the most incredible examples:
This thread is based on great work by Nicholas Renotte.
By reading it, you will create an AI financial advisor:
• Get the tools installed to use the OpenAI API
• Fine tune an LLM on a PDF unseen by the model
• Ask the PDF questions and get accurate answers
Are you ready?
A quick primer on LangChain:
• Use it to access the internet, load PDFs, and more
• An integration framework to create LLM-basd apps
• Comes with access to toolkits and other language models
Here’s the step-by-step process to turn GPT into your own financial advisor:
You’ll need to install a few libraries before you start.
You can run the following command to do it.
The LangChain imports include the interface to the OpenAI API, the PDF parser, and vector storage so you can avoid the 4,000 token limit.
Now it’s time to parse the PDF and store it in the vector storage.
First, download the PDF and put it in the same directly as your code.
Then create an instance of the OpenAI LLM.
The temperature parameter lets you adjust how creative the model responses are.
Parse the PDF, split it into pages, and load the document pages into vector storage.
Next, convert the document vector store into something LangChain can read.
Using the store you created above, create a vector metadata repo.
Next create the VectorStoreToolkit.
The toolkit takes the vector metadata and feeds it into a LangChain agent.
When executed, you’ll see a text box for you to enter your prompt. Here are a few questions you can ask:
• What were net sales in greater china for the 3 months ending April 1, 2023?
• What is the year over year percentage change in net income for the three months ended march 26, 2022 and April 1, 2023?
• What was the total depreciation and amortization for the six months ended April 1, 2023?
The agent_executor knows about the LLM and the PDF and is trained on its contents.
You’ll see LangChain running the commands and correctly answering the questions.
You can now use state-of-the-art technology to parse and quickly get information of out PDFs.
You created an AI financial advisor that can answer anything from financial statements:
• Financial results
• Risks in footnotes
• The CEO's private jet allowance
No where left to hide.
Looking to start using Python for market data analysis?
Here's a free Ultimate Guide with everything you need to get started.
Join the 1,000s of people who finally started with Python after reading it:
links.pyquantnews.com

Loading suggestions...