InvestRock: Your AI-Powered Assistant for Smart Mutual Fund Investments

Introduction

Investing in mutual funds can be daunting, especially for individual investors overwhelmed by the vast amount of available data and the complexity of making informed decisions. InvestRock is an AI Assistant designed to simplify mutual fund investments using advanced Retrieval-Augmented Generation (RAG) technology. InvestRock offers personalized solutions to help investors select the most suitable mutual funds for their portfolios, enhancing decision-making and overall investment experience.

Problem Statement

Individual investors often face several challenges:

  1. Information Overload: The sheer volume of data on mutual funds makes it difficult to find relevant information.

  2. Complex Decision-Making: Selecting the right investment involves analyzing multiple fund characteristics, which can be overwhelming.

  3. Educational Gap: Many investors lack the financial literacy to understand investment strategies and make informed decisions.

  4. Portfolio Diversification: Building a well-diversified portfolio is often misunderstood and challenging.

  5. Personalization Need: Generic financial advice fails to meet individual investors' unique financial goals and risk preferences.

Solution

InvestRock addresses these challenges through a comprehensive AI-driven approach:

  1. Utilizing RAG Technology:

    • InvestRock uses RAG technology to effectively filter and deliver the most relevant mutual fund information.
  2. Personalized Recommendations:

    • InvestRock analyzes user inputs to recommend mutual funds that align with the investor’s specific financial goals and risk tolerance.
  3. Educational Support:

    • InvestRock provides contextual educational content about mutual funds and investment strategies, enhancing financial literacy.
  4. Customized Investment Strategies:

    • The AI assistant generates personalized investment strategies based on individual risk profiles and objectives.
  5. Portfolio Diversification Assistance:

    • InvestRock helps users construct diversified portfolios tailored to manage risk and enhance returns.

Technology Used

InvestRock leverages cutting-edge AI technologies to deliver its services:

  • Retrieval-Augmented Generation (RAG): Retrieval-augmented generation (RAG) is the process of optimizing the output of a large language model so it references an authoritative knowledge base outside of its training data sources before generating a response. Large Language Models (LLMs) are trained on vast volumes of data and use billions of parameters to generate original output for tasks like answering questions, translating languages, and completing sentences. RAG extends the already powerful capabilities of LLMs to specific domains or an organization's internal knowledge base, all without the need to retrain the model. It is a cost-effective approach to improving LLM output so it remains relevant, accurate, and useful in various contexts.

  • Amazon Bedrock: Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models and a broad set of capabilities to build generative AI applications while simplifying development and maintaining privacy and security. With knowledge bases for Amazon Bedrock, you can connect FMs to your data sources for RAG in just a few clicks. Vector conversions, retrievals, and improved output generation are all handled automatically.

  • Amazon S3 and Open Search: These tools store and retrieve large volumes of financial data.

  • Streamlit: Streamlit is an open-source Python framework used by data scientists and AI/ML engineers to deliver dynamic data apps with only a few lines of code.

💡
you will incur costs associated with the AWS resources and services used. It's important to review the pricing information for Amazon Bedrock and any other AWS services utilized.

Architecture

InvestRock's architecture integrates several components to function seamlessly:

  1. User Interface: The Streamlit web application where users interact with InvestRock.

  2. Bedrock Assistant Agent: Processes user queries using large language models and provides context for the search.

  3. Knowledge Base: Powered by Amazon Bedrock, it stores and retrieves relevant information.

  4. Amazon Open Search: This service retrieves necessary data by connecting to various data feeds, including mutual funds documents stored in Amazon S3.

  5. Response Generation: Combines retrieved data to generate personalized responses for the users.

Steps

💡Creating Data Source

Created an Amazon S3 bucket, our data source, and uploaded the mutual funds' pdf file into that bucket.

💡Activating Model Access

For this use case, I have activated the models Anthropic> Claude 3 sonnet and Cohere Embed model in the Amazon Bedrock console.

Refer to this official document to enable access to specific models. https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html

💡Creating a Knowledge Base

In the AWS console, Go to Amazon Bedrock console.

  1. Select Knowledge base from the left navigation pane under Orchestration.

  2. In the Knowledge bases section, select Create knowledge base.

  3. On the Provide knowledge base details page, set up the following configurations:

    a. In the Knowledge base details section, provide a name or description for your knowledge base or use default.

    b. In the IAM permissions section, choose Create and use a new service role, and Service role name will have an IAM role that starts with AmazonBedrockExecutionRoleForKnowledgeBase

    c. Select Next.

  4. On the Set up data source page, provide the information for the data source to add to the knowledge base:

    a. Provide URI or browse S3 to navigate to the Amazon S3 folder you created earlier.

    b. Under Advanced Settings, select Use default KMS key and select Default chunking for Chunking strategy.

    Default chunking—By default, Amazon Bedrock automatically splits your source data into chunks, each containing a maximum of 300 tokens. If a document contains less than 300 tokens, it is not split further.

    c. Select Next.

  5. In the Embeddings model section, choose Embed English by Cohere embeddings model to convert the knowledge base from your data into an embedding.

  6. In the Vector database section, choose Quick create a new vector store in the following options.

    Quick create a new vector store – Amazon Bedrock creates an Amazon OpenSearch Serverless vector search collection, automatically configures the settings for embedding your data sources, and manages the collection for you.

  7. Select Next.

  8. On the Review and create page, check the configuration and details of your knowledge base. Select Edit in any section that you need to modify. When you are satisfied, select Create knowledge base.

  9. The knowledge base creation process begins, and the Status of the source becomes In progress. The time it takes to create the knowledge base depends on the amount of data you provide. When the knowledge base is finished being created, a green success banner will appear, and the status of the knowledge base will change to Ready.

  10. Select Sync your data source in the knowledge base. It takes a minute or two.

💡Creating an Amazon Bedrock agent

  1. In Amazon Bedrock console, select Agents from the left navigation pane under Orchestration.

  2. In the Agents section, choose Create Agent.

  3. On the Provide Agent details, set up the following configurations:

    • For the Agent name section, enter the agent name and an optional description.

    • Choose Create and use a new service role for the Agent Resource role section. This lets Amazon Bedrock create the service role and set up the required permissions on your behalf.

    • For Select model, choose Anthropic model provider and then choose Claude 3 Sonnet model in the dropdown menu.

    • In Instructions for the Agent, enter details to tell the agent what it should do and how it should interact with users.

    • For the rest, leave it as default.

  4. On the Agent builder page, click Add under the Knowledge base section to associate Knowledge bases to your agents.

  5. On the Add knowledge bases page, associate knowledge bases with your agent.

    1. Choose the knowledge base you created in the previous section from the dropdown menu.

    2. Enter instructions describing how the agent should use the knowledge base in the Knowledge base instructions for the agent.

  1. You have now finished configuring your agent. Select Save and exit on the top right corner to return to the Agent Details page.

  2. On the Test window on the right plane, select Prepare.

  3. To test the agent, enter a message and choose Run.

💡Configuring the Project environment

Prerequisites

  1. Create a project directory.

  2. Create a python environment.

python -m venv <environment-name>
  1. Activate the environment(In windows)
.\<environment-name>\Scripts\activate.ps1
  1. Clone the GitHub repo.
git clone https://github.com/Sudarkodi-Muthiah-repo/amazon-bedrock-agent-test-ui
  1. Install dependencies.
pip install -r requirements
  1. Set the following environment variables:

    • BEDROCK_AGENT_ID - The ID of the agent

    • BEDROCK_AGENT_ALIAS_ID - The ID of the agent alias. The default TSTALIASID will be used if it is not set.

    • The AWS environment variables provide the credentials to your account. The principal must have the necessary permissions to invoke the Bedrock agent.

  2. Run the following command to start the Streamlit app.

streamlit run app.py --server.port=8080 --server.address=localhost

We successfully created the InvestRock AI Assistant.

  1. Clean-up the AWS resources:

    1. Follow the steps below to delete your Agent.

      • In the Amazon Bedrock console, select Agents from the left navigation pane.

      • To delete an agent, choose the option button next to the agent you want to delete.

      • A dialog box appears, warning you about the consequences of deletion. To confirm that you want to delete the agent, enter delete in the input field and then select Delete.

      • When deletion is complete, a success banner appears.

    2. Follow the steps below to delete your Knowledge base.

      • In Amazon Bedrock console, select Knowledge Base from the left navigation pane.

      • Choose a knowledge base or select the radio button next to a knowledge base. Then choose Delete.

      • Review the warnings for deleting a knowledge base. If you accept these conditions, enter delete in the input box and select Delete to confirm.

      • To fully delete the vector embeddings for your knowledge base, you must delete the vector index containing the data embeddings.

Real-Time Applications

InvestRock can be applied in various real-time scenarios:

  1. Investment Assistance Companies: Enhancing services by providing clients with personalized investment recommendations and real-time market analysis.

  2. Mutual Fund Advisors: Offering tailored advice and detailed fund comparisons to clients.

  3. Mutual Fund Customer Support: Acting as a customer support chatbot to answer inquiries and guide investment strategies.

  4. Bank Customer Support: Assisting clients with investment-related queries and offering real-time responses and personalized recommendations.

Conclusion

InvestRock revolutionizes the way individual investors approach mutual fund investments. Leveraging advanced AI technologies provides personalized, accurate, and educational support, making it easier for investors to navigate the complexities of mutual funds and achieve their financial goals.

5
Subscribe to my newsletter

Read articles from Sudarkodi Muthiah directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sudarkodi Muthiah
Sudarkodi Muthiah