Fundamental Analysis Using Large Language Models and Retrieval Augmented Generation — A Use Case for Tesla Reports Analysis

M. Baddar
BetaFlow
Published in
5 min readSep 19, 2023
image source : https://www.pinterest.de/pin/553520610443653962/

Contents

  1. Why Question Answering is Important in Financial Analysis
  2. How can LLM + RAG help do Documents QA
  3. Demo using our AnswerMe LLM API

Disclaimer : I am not a financial expert and this article about how to use LLM a TOOL for developing financial recommendation software. For any financial advisors consult your financial advisor.

Why Documents QA is important for Financial Analysis ?

As in any problem, asking the right question worth solving more than half of it. In that context, I’d say that searching “trustworthy” source for the answer can account for one more quarter of the solution, and last quarter would be the solution itself !

When it comes to financial fundamental analysis, it is all about asking the right question to the right “experts” or search “trustworthy” source for the answer .

Before investing in any company, the investor should ask a set of questions like:

  • Is the company growing consistently?
  • Is the company profitable?
  • Who are the company’s competitors?
  • What is the company’s strategy to sustain growth in the future?

And for many other question you check these links

  1. Fundamental Analysis article by University of California, Riverside, Business School
  2. 15 questions you need to ask about the fundamentals of any stock

How can LLM + RAG help do Documents QA ?

Now we have got an idea how to know the right question, the next question is : How we can answer them

First we need to find a trustworthy information source. If you are investing in company Y you can read dozens of blogs and news articles about its performance. But by doing so, you are missing an importance source of information : The company Quarter / Half-Year and Yearly report.

While these reports can be daunting for many people, it is a must to understand for any novice or experienced investor. Furthermore, any developer who builds investment applications that helps investors in decision making must support these document understanding.

So, how LLM + RAG can help , simply they work together in the following sequence :

  1. User enters a free text complex question
  2. LLM model understand the question by creating an internal representation for the question, call it question-embedding
  3. The document is cut into overlapping chunks
  4. Each chunk is embedded into a chunk-embedding-vector model
  5. The question-embedding and chunk-embedding-vectors are matched via some vector similarity measure
  6. The final answer is generated is based on the matched chunks

For more details about how LLM +RAG works, check our article here

Demo : LLM for simple Fundamental Analysis over Tesla Reports

In our demo we use Q2–2023 Tesla report. You can download it here :

The question we want to answer is :

How was the Tesla Growth in Q2 2023

We have asked ChatGPT ( 3.5, the free version) the same question. Here’s the answer

One of the limitation of the free version of ChatGPT (version 3.5) is that it’s latest training data are of Sep. 2021 (source). We can go around this problem by running LLM + RAG over recent, trustworthy documents of our choice.

We have asked AnswerMe , our LLM+RAG API the same question and received a different, useful answer !!

And here is a text dump for the answer :

In Q2 2023, Tesla experienced significant growth in certain areas. Energy storage deployments increased by 222% compared to the previous year, reaching 3.7 GWh. This growth was attributed to the ongoing ramp-up of Tesla’s first dedicated Megapack factory in Lathrop, CA. The factory, with a capacity of 40 GWh, has been successful and is expected to reach full capacity in the future.

On the other hand, solar deployments remained relatively flat sequentially at 66 MW and declined compared to the previous year. This decline was primarily due to a high interest rate environment, which caused a postponement of solar purchasing industry-wide.

In terms of services and other business, Q2 2023 was highlighted by the adoption of NACS, a charging standard developed by Tesla over a decade ago, by several major companies including Ford, GM, Mercedes, Nissan, Polestar, Rivian, Volvo, and Electrify America. This adoption of NACS by other companies will further open Tesla’s charging network in 2024, facilitating faster market conversion from combustion vehicles to electric vehicles and accelerating the growth of Tesla’s charging network.

Overall, while there was growth in energy storage deployments, the solar sector faced challenges due to the interest rate environment. However, the adoption of Tesla’s charging standard by other companies indicates positive developments in the services and other business segment.

How can you reproduce the results of this example :

You can validate the answers yourself from the document.

One thing you can note that the question is “precise” : we ask specific question “How was the growth” , for a specific company “Tesla” over a specific recent period of time “Q2 2023” . This is the type of questions that are crucial to business and where LLM+RAG beats ChatGPT 3.5

In upcoming set of articles, I will illustrate a systematic method to evaluate LLM+RAG answers.

If you have any comments or issues running the API let us know or drop us a message at “info at betaflow dot ai”

For AI & LLM development , training and support , send us an email at “info at betaflow dot ai”

Also follow us on twitter and LinkedIn

--

--

M. Baddar
BetaFlow

AI/ML Engineer, with focus on Generative Modeling. The Mission is enabling individuals and SMEs applying this technology to solve real-life problems.