arrow_back

Build LangChain Applications using Vertex AI: Challenge Lab

ログイン 参加
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

Build LangChain Applications using Vertex AI: Challenge Lab

Lab 1時間 30分 universal_currency_alt クレジット: 5 show_chart 中級
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

GSP516

Google Cloud self-paced labs logo

Overview

Introduction

In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure out how to complete the tasks on your own! An automated scoring system (shown on this page) will provide feedback on whether you have completed your tasks correctly.

When you take a challenge lab, you will not be taught new Google Cloud concepts. You are expected to extend your learned skills, like changing default values and reading and researching error messages to fix your own mistakes.

To score 100% you must successfully complete all tasks within the time period!

This lab is recommended for students who have enrolled in the Build LangChain Applications using Vertex AI: Challenge Lab quest. Are you ready for the challenge?

Topics tested

  • Use gemini-pro to answer questions related to PDF documents stored in a Google Cloud Storage bucket.
  • Index the documents as embeddings in a Vector Store (for simplicity Chroma is used).
  • Implement a Retrieval Augmentation Generation application using LangChain to answer questions using the documents indexed by the Vector Store to ground information.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

Challenge Scenario

As a developer at a company specializing in building Question Answering agents, you're tasked with harnessing Gemini's cutting-edge capabilities to elevate the platform's functionality. Your mission is to implement a LangChain application for Question Answering using Gemini's available models.

Your success in this challenge will not only advance the platform's functionality but also demonstrate your proficiency in implementing Retrieval Augmentation Generation to assist with answering questions posed by users looking for information, grounded by a knowledge base. Are you ready to take on the challenge?

Task 1. Load Wikipedia Articles as LangChain Documents

In this section, you are tasked with completing the python code in cells of a Jupyter notebook to load Wikipedia articles as LangChain Documents.

  1. In the Google Cloud Console, on the Navigation menu, click Vertex AI > Workbench.
  2. On the User-Managed Notebooks page, find the generative-ai-jupyterlab notebook and click on the Open JupyterLab button.
  3. Open the retrieval_augmentation_generation_challenge.ipynb file found in the left folder view.
  4. Complete the missing parts of each cell to progress to the next section. These will be denoted with INSERT and an instruction to complete.

Task 2. Use RecursiveTextSplitter to split Documents

In this section, you are tasked with using a LangChain RecursiveTextSplitter to split the documents loaded from Wikipedia in Task 1 in preparation for indexing in a Vector Store.

  1. Remain in Vertex AI Workbench and proceed to the section Task 2: Use RecursiveTextSplitter to split Documents.

  2. Complete the required sections of the notebook retrieval_augmentation_generation_challenge.ipynb under Task 2.

Task 3. Index Documents as embeddings in Chroma DB Vector Store

In this section, you are tasked with using the Gemini embedding model to embed the documents loaded from Wikipedia in a new Chroma DB index. The index will later be used as a knowledge base to ground responses from queries to the gemini-pro model.

  1. Remain in Vertex AI Workbench and proceed to the section Task 3: Index Documents as embeddings in Chroma DB Vector Store.

  2. Complete the required sections of the notebook retrieval_augmentation_generation_challenge.ipynb under Task 3.

Click Check my progress to verify the objective. Save the processed data in a directory named chroma_db.

Task 4. Setup a Retriever

In this section, you are tasked with setting up Chroma DB as a LangChain Retriever so that the documents indexed can be used to ground responses from a Large Language Model (LLM).

  1. Remain in Vertex AI Workbench and proceed to the section Task 4: Setup a Retriever.

  2. Complete the required sections of the notebook retrieval_augmentation_generation_challenge.ipynb under Task 4.

Note: You may need to wait for a couple of minutes to get the score for this task.

Click Check my progress to verify the objective. Retrieve relevant documents from a retriever object.

Task 5. Setup Model and Build LangChain Chain

In this section, you are tasked with initializing the model used to handle user queries and create a LangChain Chain to setup the workflow of the generative AI application.

  1. Remain in Vertex AI Workbench and proceed to the section Task 5. Setup Model and Build LangChain Chain.

  2. Complete the required sections of the notebook retrieval_augmentation_generation_challenge.ipynb under Task 5.

Note: You may need to wait for a couple of minutes to get the score for this task.

Click Check my progress to verify the objective. Create a prompt template for a language model.

Congratulations!

You have now completed the lab! Throughout this challenge, you've demonstrated your adeptness in leveraging LangChain with Gemini and Chroma DB to create a Retrieval Augmentation Generation application to produce results for user queries grounded by a private knowledge base. Well done on a job excellently executed!

Next steps

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated March 6, 2024

Lab Last Tested March 6, 2024

Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.