The purpose of this site is to share some experiences and thoughts about teaching MBA students how generative AI can and is being used in the finance industry and how they can leverage it to be more efficient in the workplace. We are all learning this on the fly, and of course things are evolving very quickly, so I’m hoping that sharing will be useful. I invite everyone to share in the comments section below.
I teach a six-week 18-contact-hour course to first year MBAs in the last part of their first year. For the most part, I do not teach new financial concepts in the course, because we have other courses for those. However, I try to reinforce students’ understanding of concepts they have already seen by approaching them with a different tool (AI + coding). The course caps a first-year sequence consisting of a one-semester core course in the fall followed by an ‘Applied Finance’ course in the first part of the spring that goes deeper into some of the topcs covered in the core course and develops spreadsheet modeling skills, and then my course in the last part of the spring that covers the same topics again, but using AI + coding instead of spreadsheets. I will describe that course in particular, but many of the observations below should apply to courses in other formats and to courses for different student groups.
In addition to conducting financial analysis directly with AI + coding, the course uses AI + coding to develop tools for financial analysis. The basic structure, as is described in more detail below, is \[\text{Chatbots} \; \rightarrow \; \text{Coding} \; \rightarrow \; \text{Apps} \; \rightarrow \; \text{Custom Chatbots} \; \rightarrow \; \text{AI Agents}\] In each step, we use examples from finance, but this same structure would apply to any domain.
Tools for the Course
Students can use any chatbot for the first part of the course. Then, the course switches to using Google Colab, which is a free Python environment in the cloud that has built-in Google Gemini assistance. There is no software to install, so there is no set-up required. I prepared some materials to show students how to use Google Colab, which I cover when we get to that point.
Previously, I used Julius.ai instead of Google Colab. Julius is a bit more straightforward to use, because it is a simple chatbot interface rather than a Jupyter notebook - see my blog post about Julius. Julius also provides access to models from OpenAI and Anthropic, whereas Colab only offers Google Gemini. However, while Anthropic’s Claude is still the best coding model, Gemini has caught up considerably and is now a solid choice. Furthermore, Colab offers several advantages: it is free, it produces Jupyter notebooks that are portable, and it can deploy apps to the cloud.
Main Topics
The course covers the following topics:
- Prompt engineering
- Corporate implementations of AI
- Using AI to write code for financial analysis, visualization, and report generation
- Using AI to create apps to automate the above
- Creating custom chatbots for the above
- Creating AI agents for the above
- In-depth study of using AI for DCF valuation of companies
1. Prompt Engineering
A good demonstration at the start of a course on Finance with AI is to upload a company’s annual report to ChatGPT (or a different chatbot) and ask it for an investment analysis in the form of a Word document. You can ask the chatbot to include the following:
- a summary of the annual report
- a comparison of the firm to peer firms
- a two-stage DCF analysis formed by extrapolating trends
- a sensitivity analysis focused on the items for which extrapolation might be most unreasonable
- a buy/hold/sell recommendation
This example illustrates the power of AI ‘out of the box’ for financial analysis. It also explains why we are seeing so many stories about the potential demise of junior financial analysts. Of course, the AI is not perfect. We should engage our students in a discussion of how the report can be improved.
Compile the responses to build a more detailed prompt than the original prompt, start a new chatbot session (so the model will have no memory of the original prompt and response1), and submit the new prompt. Compare the results. Get students to discuss how they might further improve the new prompt. Then, point out that the eventual prompt that they form through this iterative process can be saved as a text file and uploaded each time they want to generate this type of report. This is prompt engineering.
1 Large language models do not actually remember past prompts and responses in a session. Instead the record of past prompts and responses in a session is sent by a chatbot to the model along with each new prompt, so that the model can use the record of past prompts and responses when generating a new response.
2. Corporate Implementations of AI
The HBS case about Implementing AI at Deloitte is a good foundation for a class discussion of AI implementation. It covers the issues of data privacy, compliance, client trust, reliability, biases, and employee buy-in. It also describes how Deloitte set up a custom chatbot.
This widely cited MIT Study is also must-reading. It has been described in the media as reporting that 95% of corporate AI implementations fail. What it actually says is that only 5% of corporate AI pilots reach production, which is not quite the same thing. The reasons that most pilots are abandoned and the characteristics of successful pilots are informative. Also key is this passage: “workers from over 90% of the companies we surveyed reported regular use of personal AI tools for work tasks. In fact, almost every single person used an LLM in some form for their work.” So, AI is being widely used, despite the difficulties companies have faced in designing and implementing company-specific AI solutions.
Another very interesting item is this study about the use of AI in corporate teams. The study is described by one of the authors here. They conclude that, instead of thinking of AI as a tool, it should be regarded as a teammate. They find that one person working with AI is at least as efficient as two people working in a team without AI. The most effective combination is naturally a team with AI. Interestingly, they find that AI enables workers and teams to break functional silos, performing like teams composed of individuals with diverse functional knowledge.
3. AI-Generated Code
Two good exercises for seeing how AI-generated code can be used to perform financial analysis are mean-variance analysis and CAPM cost of capital calculations. I demo the first and assign the second as a group project. AI can write code to get data from Yahoo Finance, calculate returns, and perform the analyses, assuming we are willing to trust sample moments in mean-variance analysis. We could also input risk and risk premia assumptions directly for mean-variance analysis rather than calculating sample moments. See my blog posts about getting data from Yahoo Finance, mean-variance analysis, and calculating the cost of capital.
There are natural visualization components to both exercises, namely the plot of the mean-variance frontier and the CAPM scatter plot and regression line. AI can write Python code to create the visualizations and to produce Word docs and/or PowerPoint decks containing the analyses and visualizations. See this post about generating Word docs and PowerPoint decks and this post about visualization.
There is a lot that could be done on option pricing if students have seen options already. As remarked above, I teach a first-year class, and I can’t preempt what will be taught to second-year students. Except for that issue, I would certainly spend some time on options.
4. Building Apps
Whatever code an LLM (large language model) writes for financial analysis can be encapsulated in an app and made broadly available, so people can use the code without needing to go to Julius or Colab or any other Python platform. The Python Streamlit library makes app construction easy. The same is true of the Gradio library apparently, but I only have experience with Streamlit. See my blog post about creating apps. Again, I demo mean-variance analysis and assign cost of capital calculations as a group project.
Streamlit apps can be deployed to the cloud from Google Colab using the ngrok service. Students will need to create free accounts at ngrok and get authorization tokens. They should save their authorization tokens as secret keys in Google Colab (they can ask Gemini how to do that). Then, they can tell Gemini to deploy apps using ngrok.
At this point in the course, students have seen enough to compare the following ways to perform a financial analysis:
- Using Excel
- Asking a chatbot
- Using AI + coding via Google Colab
- Creating and using an app
This provides the foundation for an informative class discussion about the relative merits of each approach and the circumstances in which one approach is better than another.
5. Custom Chatbots
Custom chatbots involve
- A user interface
- An API connection to an LLM, which has possibly been fine-tuned
- A system prompt
- Possible retrieval of documents
- Possible use of tools
Creating a user interface is a variation of building an app and has already been covered essentially. Creating an API connection to an LLM is similar to setting up ngrok as covered in the second topic. Finally, the prompt that was saved as a text file in the course introduction can easily be used to create an example of a system prompt. So, a simple custom chatbot of user interface + API connection + system prompt requires only techniques that students have already seen at this point.
Students can get API keys from OpenAI even with free accounts, or they can get API keys from Anthropic or Google. They can ask any chatbot how to do it. They should save their API keys as secret keys in Google Colab in the same way they saved their ngrok keys. They will be charged on a per-usage basis, but the charges will be trivial for the experimentation that is done in the course. They could also get free API keys from Open Router and use free open source LLMS from Hugging Face.
Once an API key is installed on Colab, students can ask Gemini to connect to the LLM and send a prompt and get a response. Gemini will import the openai Python package even for using other LLMs, because the OpenAI API has become the standard. The code that Gemini has to write to use the openai package is extremely simple and transparent, and it is useful for students to see it.
As a next step, students can ask Gemini to create a custom chatbot using Streamlit and ngrok. A good example for a system prompt is to ask the LLM to respond in a foreign language, so we can see that the system prompt actually works. It is important that Gemini build a loop in the app that collects all past prompts and responses and sends them together with the system prompt with each new prompt. If the chatbot does not seem to be remembering past prompts during a session, it is because the loop was not constructed. Students should ask Gemini to add the loop if this occurs.
6. AI Agents
An AI agent is a chatbot that can use tools to complete tasks. Unlike regular chatbots that only generate text, agents can call functions, access APIs, and run applications to get things done.
Students are prepared to learn about AI agents after having seen app development and custom chatbot development. We can configure the mean-variance and cost-of-capital apps as tools that can be called, and we can create a custom chatbot that can call them. All of this can be done by Gemini in Google Colab.
If we connect multiple tools to a chatbot, then a user can, within a single chatbot session, perform a variety of specialized tasks. For example, a user can retrieve data, possibly from multiple sources, and perform multiple types of analyses, all while interacting with the same chatbot using natural language prompts. This really unleashes the power of AI.
7. AI-Assisted DCF Valuation
We start the course by asking a chatbot to do a DCF analysis. We can return to the same question now with new tools in our toolbox. A good question to pose is: How can we best build a chatbot to assist us in valuing a company? At least a week and perhaps two weeks should be dedicated to this question.
I like the HBS case Valuing Walmart 2010. The approach that the case guides students to use is too simplistic, so I mostly ignore it. I like the case because all students will have some understanding of where Walmart’s value comes from, and we can have meaningful discussions about possible future growth rates.
I start this part of the course by sketching a valuation analysis on the board with student input and discussion. We have to decide what ratios and growth rates we will use to generate pro forma statements and what assumptions we will make about them. This provides a leveling-up experience for students and provides focus to the ensuing discussions.
After working through the issues by hand, I upload the financial statements in the case to ChatGPT and ask it for a DCF valuation. Then, I read the statements into Google Colab and ask Gemini to assist with a valuation in Python. At this point, students are prepared to discuss whether and how we can create a useful valuation assistant using an app or custom chatbot.
To use the app or custom chatbot, we will need to have a data source. It is easy to get data from Yahoo Finance. Alternatively, users can be asked to upload data. It may also be possible to use other data sources, if there are available sources with APIs that can be used by the chatbot.
I assign the creation of a valuation assistant chatbot as the final group project for the course, worth 50% of the total grade. I require the chatbots to include a facility for uploading financial statements.
Extras
Introduction to Python
Students need to have some understanding of what they are seeing when an LLM generates code. I provide an optional pre-course workshop on using Jupyter notebooks in Google Colab, basic elements of Python, and pandas, numpy, and visualization libraries.
User Interfaces of Apps
Streamlit is a convenient way to build apps, but it provides limited flexibility in the design of the user interface. LLMs can write code in many languages other than Python. Replit is an easy-to-use platform for creating apps. It codes in Python, JavaScript, HTML, and CSS to create professional user interfaces. I don’t ask students to subscribe to Replit, but I do provide an in-class demonstration.
Database Chatbots
An example of a useful custom chatbot is one that converts natural language prompts into database queries and returns data. To demonstrate this, we first need to store a database online. We can use CRSP and/or Compustat data or other data for this example. An easy way to create an online database is to create an account at MotherDuck and use the MotherDuck CLI (command line interface) to upload csv files. ChatGPT or Gemini can tell you how to do this, or, there are agentic chatbots that can do it for you (see below). Then, we can ask Gemini (or Replit) to create a chatbot that (i) sends a user prompt to an LLM, (ii) receives a response in the form of SQL code, (iii) sends the SQL code to MotherDuck to retrieve data, and (iv) returns the data to the user. The key to this is the duckdb Python library, which can execute SQL queries against csv files just as if a SQL database had been set up. To create the chatbot, a system prompt must be created that adequately describes the csv files to the LLM. This requires testing and iteration, like creating the system prompt for the forecasting and valuation chatbot.
App Deployment
To permanently deploy an app, we need an account at a host. Koyeb is a good choice. Render is similar. A relatively simple way to deploy is to create a GitHub account. Then, we can
- Initialize a GitHub repository
- Push our code to GitHub
- Add a new Koyeb or Render service
- Connect the service to the GitHub repository
- Click ‘Deploy’ on Koyeb or Render
Gemini or another chatbot can walk students through each step.
Local Installation of AI + Coding
The simplest way for students to install Python plus some of the packages they need is to use the Anaconda distribution. It is free and easy to install.
To create a local version of Google Colab with Gemini, it is hard to beat Cursor.2 Cursor is offering students a free year of its Cursor Pro account. Students can use their OpenAI API keys - or API keys from Anthropic or Google, etc. - to configure the AI. There will be charges based on usage, which again will be small for the amount of usage done in the course.
2 Actually, my favorite setup at the moment is to use Claude Code with Cursor’s Claude Code Extension. This setup adds extra cost, but it enables replacement of Cursor’s chat feature with Claude Code, which seems to have a better system prompt.
Cursor has auto-complete and chat just like Google Colab. It can also execute terminal commands. Using the terminal, it can implement the steps described above for permanent deployment of apps - creating a Github repo, pushing to Github, integrating with Koyeb or Render, and deploying. It can also the the MotherDuck CLI to create the online database described above.
Cursor can also code in languages other than Python. In particular, it can use JavaScript, etc. to create professional user interfaces, as discussed above for Replit.
© Kerry Back
J. Howard Creekmore Professor of Finance and Professor of Economics
Rice University
kerryback.com
Discussions
Please share your thoughts, experiences, or questions about teaching AI-assisted finance in the comments below.