- Background & Motivation
- Problem Statement
- Stockformer
- Features
- Before Getting Started
- Getting Started
The financial and investment landscape can be daunting for newcomers due to the vast array of terminology, concepts, and investment strategies. Financial literacy and effective investment management are crucial skills in today's economy, yet many individuals struggle to navigate the complex world of finance. The abundance of financial jargon, investment options, and market volatility can be overwhelming for novice and experienced investors alike. Traditional financial advisory services are often expensive and inaccessible to the average person, creating a significant barrier to entry for those seeking to improve their financial well-being. The integration of Large Language Models (LLMs) and Machine Learning (ML) in personal finance offers a promising solution to democratize financial advice and empower individuals to make informed investment decisions.
Portfolia is an AI-powered personal investment advisor and stock forecasting assistant powered by LLM agents and Time Series Transformers. The primary objectives are:
- To create an accessible and user-friendly platform that provides personalized financial advice and education to users of all experience levels.
- To develop an accurate stock forecasting feature leveraging deep learning with time series transformers at various prediction lengths.
- To enhance financial literacy by explaining complex financial concepts in simple, understandable terms.
Given the complexity of financial data, characterized by its inherent randomness, noise, and non-stationarity, extensive research has been conducted on leveraging deep learning-based representation learning for accurate stock price prediction. A recent publication, "Transformers in Time Series: A Survey" (Wen et al., 2023), presents a case study utilizing Time Series Transformers to forecast the Bangladeshi stock market in Dhaka. Building upon this research, we have developed and trained a proprietary Time Series Transformer model specifically for the U.S. S&P 500 stocks.
To read more about our implementation, please navigate to code/stockformer or just click here.
- Agentic RAG (Retrieval Augmented Generation): Implement LLM agents for techniques to understand and respond to user queries about financial concepts and investment strategies.
- Personalization: Utilize user-specific investor personality as context for providing tailored investment advice based on individual financial situations, goals, and risk tolerance.
- Stock Forecasting: Employ Time Series Transformers pre-trained on historical S&P 500 stock data to generate accurate stock price predictions.
- User Interface: Develop an intuitive, conversational interface that allows users to interact naturally with the AI advisor.
- Scalable Back-End: Build a system which enables horizontal scalability by allowing concurrent request handling for stock forecasting during inference.
In this repository, the folder models is too large for our Git LFS limit. Please click this link to download a zip file of models which you can manually add to this cloned repository. *Note: There should be a total of 4 model checkpoint directories under models/stockformer.
The File Directory Structure of models:
┣ 📂 models
┃ ┗ 📜 .gitkeep
┃ ┣ 📂 stockformer
┃ ┃ ┗ 📂 sp500-30d-final
┃ ┃ ┃ ┗ 📜 sp500-30d-final-config.pth
┃ ┃ ┃ ┗ 📜 sp500-30d-final-state.pth
┃ ┃ ┗ 📂 sp500-90d-final
┃ ┃ ┃ ┗ 📜 sp500-90d-final-config.pth
┃ ┃ ┃ ┗ 📜 sp500-90d-final-state.pth
┃ ┃ ┗ 📂 sp500-180d-final
┃ ┃ ┃ ┗ 📜 sp500-180d-final-config.pth
┃ ┃ ┃ ┗ 📜 sp500-180d-final-state.pth
┃ ┃ ┗ 📂 sp500-360d-final
┃ ┃ ┃ ┗ 📜 sp500-360d-final-config.pth
┃ ┃ ┃ ┗ 📜 sp500-360d-final-state.pth
- Linux Kernel/OS (e.g. Ubuntu 22.04 LTS)
- NVIDIA AI Workbench should be installed
- CUDA Device Atleast 1 recognizable device (GPU)
- Git should be installed for accessing remote repositories
- Docker should be installed for container runtimes
This project was built with NVIDIA AI Workbench CLI.
We created a custom Docker image for our application's container runtime. Due to unforeseen issues with NVIDIA AI Workbench's default container not recognizing CUDA devices on our local development host, we decided to build our own image with the proper CUDA Toolkit drivers for the container's runtime.
Please follow the below steps to launch the application.
- Clone the repository
git clone https://github.com/Jarhatz/portfolia.git
cd portfolia- Build the docker image with the Dockerfile present in the root directory of this repository.
docker build -t portfolia .This may take ~5 minutes to build
- Start a container and run a simple dependency test. The following command will run the test to make sure everything went well.
docker run --rm -it --gpus all portfolia python3 code/run_test.pyYou should see:
All imports successful. No dependency conflicts.
- Start the server in a container. It will be listening on port 5000 for any incoming HTTP API requests.
docker run --rm -it -p 5000:5000 --gpus all portfolia- Start the Front-End
Once the back-end server is up and running, please go on and launch the front-end client web application. Instructions can be found in our portfolia-client repository.