Coding my own Financial Advisor

As an AI Agent to eventually augment real financial advisors

Nicholas Kwan
4 min readAug 30, 2022
Photo by micheile dot com on Unsplash

Purpose

I have set out to create an agent that would provide financial advice. The goal is to see if I can provide others with tailored financial advice based on their financial situation.

It is unlikely that we can develop anything to replace a real human soon in the service industry, although it’s not for the lack of trying. In my experience the best AI agents in the NLP space are still far from replacing humans, but can help solve common recurring problems. This will not be a chatbot, although it will have some infrastructure and tools that are often associated with building chatbots.

Instead, the goal of this is to determine how promising the advice I can get an AI agent to provide for people to meet their financial goals. A secondary goal is to convince users to go through with the advice. The internet is full of great resources for learning about personal finance, but it often falls on deaf ears because people cannot apply said advice for reasons ranging from lack of understanding or discipline.

Why do this? Why now?

My technical background primarily focuses on the backend, from application code to deployment. This includes common tools such as k8s, docker, and terraform as well as languages such as Java and Python. I will have a slight preference for tools that I have used or will likely use at my job.

However, in a true agile fashion, I will deploy the bare components to answer basic questions and then fine-tune and expand the solution as I go. The bare minimum to get this started would be to create a Python program that takes in questions via the command line and spit out an answer.

I will update the process as I progress. You, the reader, and I can reflect on the choices we’ve made along the way. The articles will be written as more components are made.

At a high level, this is what we are dealing with.

v1 Architecture

I will have several background processes that grab articles online, clean them, and train the model. This will be manual at first, and the model will be deployed ad hoc. This will greatly reduce the complexity of fine-tuning, testing, and reviewing the performance that is difficult to automate. The application should will be a passthrough at first, and the users will talk directly to the NLP model, which can be base RASA or BERT. I will determine what makes the most sense when I dig a bit deeper.

If we are adding other ways to determine the response, such as adding a search component for comparison, I will add that later. I will do experiments to determine the outcome of adding tf-idf/BM25 search (ie ElasticSearch) and vector based (ie FAISS/Milvus) and determine if they are suitable candidates for our use case.

Why I am doing this:

  • Share learnings about the latest in NLP and recommendations/search with concrete examples and business goals
  • I don’t code in my day-to-day anymore; this is a way for me to learn specific technologies that my team is using
  • Showcase (especially to new developers) that even the designs with the best intentions often need to be updated and re-architected

Who knows, maybe I’ll even reach my ambitious goal of providing financial advice to myself in the future once I have the training pipeline automated. How cool would that be! At that point, I will turn this into a start-up. For this reason, I will not make this open-source but will supply snippets of code as needed to demonstrate my findings.

Some initial direction

Below are some technologies that I will be investigating. I have worked with most of these in the past, so I have a rough idea of what type of results I should expect:

  • Similarity search to determine the type of financial situation and expected advice
  • BERT with a fine-tuned layer to determine the feasibility
  • Automatically finding and scrapping new resources online and putting them into a training data pipeline and model generation
  • Leverage RASA to create a conversational agent

To keep this more focused, I will limit training data on Canadian investment vehicles such as TFSA and RRSP and advice applicable in Canada. However, I think most of these will transfer to the US as well, as they have 401k and Roth RSA accounts with similar benefits and drawbacks.

Stay tuned as I build this agent! I have already started building out a few components, and I can’t wait to write new articles for each major component or improvement. When appropriate, I will make a business plan along with some product direction.

--

--

Nicholas Kwan

My passion is building useful software products by leading software teams. I write mainly on growing within software organizations.