Friday, 18 April 2025

Create your own Personal Agent


I decided to create my own Personal Agent, called “Product Guru” using several GenAI capabilities that I learned during the 5 day GenAI Intensive course by Google. The objective for this Agent is to help me answer the day to day product queries that I keep getting from various internal and external sources being a Product Manager. I wanted to save time around finding the right answers and responding quickly to all such queries..To achieve this I am planning to  leverage Agents, Retrieval Augmented Generation (RAG), and Function Calling.


Here's the 6 step approach:


Step 1: Define the Agent's Purpose and Capabilities

To begin with, my agent will be designed to answer product-related queries and provide information based on the product’s documentation.


Step 2: Implement Retrieval Augmented Generation (RAG) for Grounded Responses

To ensure the agent provides accurate and up-to-date information, I'll use Retrieval Augmented Generation (RAG). This involves retrieving relevant information from a data store and using it to ground the agent's responses, reducing hallucinations. I will do this by:


  1. Creating a data store: This is the collection of my product manuals, FAQs, and other product related documents.

  2. Generating embeddings: Process my documents and generate embeddings (numerical representations) for each chunk of text. I am planning to use Vertex AI LLM text embeddings for this.

  3. Setting up a vector store: Use a vector store (like Vertex AI Vector Search) to store these embeddings, allowing for efficient similarity search.

  4. Implementing the retrieval process: When someone asks a question, embed their query and use the vector store to retrieve the most relevant document chunks.

  5. Augmenting the prompt: Include these retrieved chunks in the prompt sent to the language model that powers my agent. This provides the model with the necessary context to answer the question accurately.


Step 3: Define and Implement Functions for Specific Actions

To extend the agent's capabilities beyond just answering questions, I will use Function Calling. This allows the agent to interact with external systems and perform actions based on the user's request.

Identify potential functions: For a Product Guru, this might include functions like:

get_compatibility_matrix(product_version): To retrieve the compatibility matrix of a specific product version


get_product_details(product_query): To fetch detailed information about a specific product related query.


Define the function signatures: Here I will describe each function to the language model, including its name, parameters, and a brief description of its purpose.

Implement the functions: I will then write the actual code for each function that interacts with my internal systems or APIs.

Integrate with the agent: The agent's orchestration layer (discussed in Step 4) will decide when and how to call these functions based on the user's input.


Step 4: Build the Agent with an Orchestration Layer

An Agent combines a language model with instructions and tools (like our RAG system and defined functions) to achieve a goal.

Choose a foundation model: I will select a suitable language model, such as one from the Gemini family available on Vertex AI.

Define the agent's instructions: Next is to provide clear instructions to the agent about its role, how it should interact with customers, and when to use its tools (RAG and functions). I am planning to use system prompting to define this role.

Implement the orchestration layer: This is the "brain" of the agent that decides what to do at each step. I am planning to use cognitive architectures like ReAct (Reasoning and Acting), where the agent reasons about the situation and then decides to either act (e.g., call a function or retrieve information) or respond to the user. You can use libraries like LangChain with the Vertex AI SDK to build this orchestration.

Tool integration: The orchestration layer will analyze the user's input and determine if it needs to retrieve information using the RAG system or call a specific function.


Step 5: Implement Gen AI Evaluation

To ensure the agent is performing effectively, I will also implement Gen AI evaluation.

Define evaluation metrics: Determine what constitutes a successful interaction. Include metrics like accuracy of answers, relevance of information retrieved, successful execution of functions, and customer satisfaction..

Create evaluation datasets: I will prepare a set of example customer queries and expected responses or actions to test the agent's performance.

Utilize Vertex AI Evaluation: Vertex AI provides tools for both ground truth-based metrics and LLM-based evaluation. I am planning to use a large model as an "autorater" to assess the quality and accuracy of the agent's responses.

Evaluate trajectory and tool use: For agents, I will also evaluate the reasoning process and how effectively the agent uses its tools.


Step 6: Consider MLOps for GenAI

To manage and deploy my Product Guru effectively, I will consider MLOps for GenAI practices.

Version control: I will manage different versions of your agent's code, prompts, function definitions, and trained models.

Continuous integration and continuous delivery (CI/CD): I will automate the process of building, testing, and deploying new versions of your agent.

Monitoring and logging: I will track the agent's performance, identify errors, and monitor its usage in production by using Cloud observability.

Governance: It is also important to implement policies and procedures to ensure responsible and ethical use of the agent. I am planning to use Vertex AI Feature Store, Model Registry, and Dataplex can help with governance of data and models.


By following these steps and leveraging the capabilities of Agents, RAG, and Function Calling within the Vertex AI platform, I am planning to build a sophisticated and helpful Product Guru.

Friday, 17 January 2025

Glimpses from 2024 Events

 

My Standup Act at Milton Keynes



Hosted Council Diwali Event



Singing at Varun Prabhakar's Show