This repository contains a practical collection of generative AI applications for various things as well as an example of fine-tuning an existing model using Vertex AI and Google Cloud Platform.
HEADS UP!!! Running the examples will cost money, but Google should give you a $300 free trial the first time you sign up. The cost of running the supervised-learning example can be $50+. The cost of running the other examples is relatively small, where if you spent all day messing with things you'd probably still be under a few dollars.
There is a single-command setup for starting up the development environment, and a separate single-command setup for setting up your Google Cloud project and any cloud resources needed for running examples. You need to set the GCP_PROJECT
variable manually in the .env after creating a project, and optionally a GITHUB_TOKEN
and GOOGLE_CSE_ID
(Programmable Search Engine) depending on the notebooks you intend to run. All other variables will be set automatically if you follow the instructions.
NOTE: windows is not supported. if you run docker on windows and want to try getting it to work, the NB_UID
and NB_USER
environment variables in the docker-compose.yml, and any volume mounts in any docker-compose.yml
files are what I'd expect to fail.
- Getting Started
- Overview of the Stack
- Notebooks
- Blog Title Generation (Content Generation Series: Part 1)
- Blog Article Generation (Content Generation Series: Part 2)
- Blog Article Supervised Tuning (Content Generation Series: Part 3)
- Wikipedia-Connected ReAct Agent
- World Pool-Billiard Association Rule Book Chat Bot (PDF source)
- Valorant (Riot Games) FAQ and News Question-Answering (custom search engine)
- YouTube Presentation Question-Answering (transcript API)
- YouTube Presentation Question-Answering Chat Bot (transcript API)
- Competitive Analysis Question-Answering (Selenium)
- Engineering Incident Response Question-Answering (Slack export)
- Repository-Aware Code Generation from Local Repo
- Repository-Aware Code Generation from Remote GitHub Repo
- Documentation
I recommend following the comprehensive guide in docs/developer-guide/02_getting_started.md to get started.
- Create a new GCP Project manually
- Add the GCP project ID to the .env
- Run
make gcloud_init
to initialize agcloud
config for your local machine - Run
make gcloud_login
to authenticate your local machine with your GCP project and configure Docker to use your GCP project's container registry - Run
make terraform_apply
to create the cloud resources needed to run the examples - Run
make start
to start the development environment- Run
make start firefox=true
to start the development environment and automatically open Firefox to the Jupyter notebook environment when it's ready
- Run
- Run the react-zero-shot-youtube-transcript-chat.ipynb notebook to generate an embeddings database (will be saved to
data/chromadb/youtube_transcripts
) - Run
make build_chatbot
to build the chat bot container image and push it to your GCP project's container registry - Run
make terraform_apply
to create the chat bot's service account and deploy the chat bot to Google Cloud Run with a publicly accessible URL
- Docker (❤️) lets us package up an operating system and all of the dependencies our code needs to function in a way where everything "just works" on anyone's computer. This is the only tool you'll need to install, but I recommend VS Code as a code editor as well if you're really going to tinker.
- Terraform is an infrastructure-as-code (IaC) tool used for automatically enabling the Google Cloud APIs you need in order to run the examples, creating (and cleaning up when you're done) a service account and storage bucket for fine-tuning job pipelines, creating a minimally-scoped API key for a custom search engine example, and deploying a chatbot example to Google Cloud Run.
- Jupyter Notebook is a super clever tool that combine executable code (like Python) and supporting Markdown documentation into a single file (like this example), which is a great way to explain coding concepts step-by-step. It lets you save output of the code after it executes, so people can see the behavior of the code in their browser without running their own development environment.
- Vertex AI is Google's enterprise-ready generative AI solution. Models used include
textembedding-gecko
,text-bison
,chat-bison
, andcode-bison
. If you want to play with the new Gemini model and see for yourself how much Google may or may not have been stretching the truth with their marketing video, the environment used for these examples is fully ready for you to drop Gemini code into as well. - LangChain gives us some high level tools for working with generative AI. It has simple interfaces for working with embeddings, vector stores, and large language models (LLM) that we'll make frequent use of, as well as implementations of various common chains.
- ChromaDB is an open source embeddings/vector database and lets us work with larger content than will fit in a typical prompt. It also lets us persist the embeddings in between development sessions, and bake the database into a container image to be deployed as a demo.
- Make is part of the GNU project, comes preinstalled in MacOS and commonly in Linux, and allows hiding the complexity of logic being run behind a simple command that will look like
make some-target
. This is the only tool you need to directly interface with to use the repository.
This is part 1/3 for the blog article content generation and supervised tuning series.
It's a super basic example of using Google's text-bison model to generate blog titles based on a configured list.
This is part 2/3 for the blog article content generation and supervised tuning series.
It's a similar example to the blog title generator, using Google's text-bison model to generate blog articles based on the blog titles generated in the Blog Title Generation notebook.
This is part 3/3 for the blog article content generation and supervised tuning series.
It's an example of fine-tuning Google's text-bison model to generate blog articles in a specific format based on a minimal prompt.
This is an example of using LangChain to build a ReAct agent that can answer questions by pulling from Wikipedia articles.
This example uses Google's Programmable Search Engine to gather content from specific online sources to answer questions about Valorant.
World Pool-Billiard Association Rule Book Chat Bot (PDF source)
This examples demonstrates reading in a PDF rule book to augment the generated responses of a chat bot.
This examples demonstrates reading in a transcript from a YouTube video to create a question-answering agent.
It also shows how to use Gradio to easily create a user interface for the agent.
This example is identical to the other YouTube example except it has a chat bot interface.
Competitive Analysis Question-Answering (Selenium)
This example uses LangChain's Selenium document loader to gather content from a marketing page and answer questions about plans and pricing.
Engineering Incident Response Question-Answering (Slack export)
This example uses LangChain's Slack document loader to gather content from a Slack export of on-call channels and answer questions about incident response.
This example reads in files from a local repository, generates embeddings, and generates code based on the repository contents.
This example is the same as the local repository example except it reads in files from a remote GitHub repository.
Both public and private repositories can be read in.