Git Product home page Git Product logo

generative-ai's Introduction

Generative AI with Vertex AI

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.

Table of Contents

  1. Getting Started
  2. Overview of the Stack
  3. Notebooks
    1. Blog Title Generation (Content Generation Series: Part 1)
    2. Blog Article Generation (Content Generation Series: Part 2)
    3. Blog Article Supervised Tuning (Content Generation Series: Part 3)
    4. Wikipedia-Connected ReAct Agent
    5. World Pool-Billiard Association Rule Book Chat Bot (PDF source)
    6. Valorant (Riot Games) FAQ and News Question-Answering (custom search engine)
    7. YouTube Presentation Question-Answering (transcript API)
    8. YouTube Presentation Question-Answering Chat Bot (transcript API)
    9. Competitive Analysis Question-Answering (Selenium)
    10. Engineering Incident Response Question-Answering (Slack export)
    11. Repository-Aware Code Generation from Local Repo
    12. Repository-Aware Code Generation from Remote GitHub Repo
  4. Documentation
    1. Repository Structure
    2. Development Environment Overview
    3. Getting Started
    4. Deploying the Cloud Run App

Getting Started

I recommend following the comprehensive guide in docs/developer-guide/02_getting_started.md to get started.

TLDR for running locally

  1. Create a new GCP Project manually
  2. Add the GCP project ID to the .env
  3. Run make gcloud_init to initialize a gcloud config for your local machine
  4. Run make gcloud_login to authenticate your local machine with your GCP project and configure Docker to use your GCP project's container registry
  5. Run make terraform_apply to create the cloud resources needed to run the examples
  6. 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

TLDR for deploying the chat bot example

  1. Run the react-zero-shot-youtube-transcript-chat.ipynb notebook to generate an embeddings database (will be saved to data/chromadb/youtube_transcripts)
  2. Run make build_chatbot to build the chat bot container image and push it to your GCP project's container registry
  3. 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

Overview of the Stack

  1. 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.
  2. 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.
  3. 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.
  4. Vertex AI is Google's enterprise-ready generative AI solution. Models used include textembedding-gecko, text-bison, chat-bison, and code-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.
  5. 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.
  6. 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.
  7. 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.

Notebooks

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.

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.

This example uses LangChain's Selenium document loader to gather content from a marketing page and answer questions about plans and pricing.

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.

generative-ai's People

Contributors

stevenaldinger avatar

Stargazers

 avatar Jeff Beard avatar Maksim Pecherskiy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.