Skip to content

Commit

Permalink
tested and updated genai tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
zbyosufzai committed Apr 5, 2024
1 parent e2a92f9 commit dac89f5
Show file tree
Hide file tree
Showing 10 changed files with 424 additions and 1,777 deletions.
Binary file modified images/GCPGenStudio2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/GCPGenStudio3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/GCPGenStudio4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,380 changes: 111 additions & 1,269 deletions notebooks/GenAI/GCP_GenAI_Huggingface.ipynb

Large diffs are not rendered by default.

348 changes: 55 additions & 293 deletions notebooks/GenAI/Gemini_Intro.ipynb

Large diffs are not rendered by default.

221 changes: 138 additions & 83 deletions notebooks/GenAI/Pubmed_RAG_chatbot.ipynb

Large diffs are not rendered by default.

27 changes: 15 additions & 12 deletions notebooks/GenAI/VertexAIStudioGCP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Go to the Generative AI Studio console [here](https://console.cloud.google.com/vertex-ai/generative/language?_ga=2.182664366.923116401.1692009977-1042353744.1691708677).\n",
"Go to the Vertex AI Studio console by navigating to Vertex AI via the search bar on the console. On the left side menu scroll down to Vertex AI Studio, click **Language**.\n",
"\n",
"Scroll down to **Summarization** and click on the model **Article Summary**. You will see a prompt session were you will need to enter in the contents of your article as the console does not allow you to upload files. For this tutorial this article is about how gut microbiota affects Alzeheimer's disease because of the gut-brain-microbiota axis network [here](https://www.aging-us.com/article/102930/pdf).\n",
" <img src=\"../../images/Gemini_2.png\" width=\"500\" height=\"500\">\n",
"\n",
" <img src=\"../../../images/GCPGenStudio2.png\" width=\"500\" height=\"500\">\n",
"\n",
"To the left you can control the parameters that we have been using before this is a great way to test what each parameter does and how they effect each other. Once you are done click **submit**, you should have a similar output as below. For explainations on the parameters **temperature, token limit max, top p, and top k** see the following article [here](https://cloud.google.com/vertex-ai/docs/generative-ai/text/test-text-prompts#generative-ai-test-text-prompt-drest).\n",
"Scroll down **\"Prompt examples\"** then to **Summarization** and click **\"Open\"** on **Article Summary**. You will see a prompt session were you will need to enter in the contents of your article as the console does not allow you to upload files. For this tutorial this article is about how gut microbiota affects Alzeheimer's disease because of the gut-brain-microbiota axis network [here](https://www.aging-us.com/article/102930/pdf).\n",
"\n",
" <img src=\"../../../images/GCPGenStudio3.png\" width=\"600\" height=\"600\">\n",
" <img src=\"../../images/GCPGenStudio2.png\" width=\"500\" height=\"500\">\n",
"\n",
"To the right you can control the parameters that we have been using before this is a great way to test what each parameter does and how they effect each other. Once you are done click **submit**, you should have a similar output as below. For explainations on the parameters **temperature, Output token limit, top p, and top k** see the following article [here](https://cloud.google.com/vertex-ai/docs/generative-ai/text/test-text-prompts#generative-ai-test-text-prompt-drest).\n",
"\n",
" <img src=\"../../images/GCPGenStudio3.png\" width=\"600\" height=\"600\">\n",
" \n"
]
},
Expand All @@ -79,7 +82,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"../../../images/GCPGenStudio4.png\" width=\"600\" height=\"600\">"
"<img src=\"../../images/GCPGenStudio4.png\" width=\"600\" height=\"600\">"
]
},
{
Expand Down Expand Up @@ -125,15 +128,15 @@
"toc_visible": true
},
"environment": {
"kernel": "python3",
"name": "tf2-gpu.2-11.m108",
"kernel": "conda-root-py",
"name": "workbench-notebooks.m119",
"type": "gcloud",
"uri": "gcr.io/deeplearning-platform-release/tf2-gpu.2-11:m108"
"uri": "us-docker.pkg.dev/deeplearning-platform-release/gcr.io/workbench-notebooks:m119"
},
"kernelspec": {
"display_name": "Python (Local)",
"display_name": "Python 3 (ipykernel) (Local)",
"language": "python",
"name": "local-base"
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -145,7 +148,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from langchain.retrievers import PubMedRetriever
from langchain_community.retrievers import PubMedRetriever
from langchain.chains import ConversationalRetrievalChain
from langchain.prompts import PromptTemplate
#from langchain.llms import VertexAIModelGarden
from langchain.llms import VertexAI
from langchain_google_vertexai import ChatVertexAI
import sys
import json
import os
Expand Down Expand Up @@ -30,7 +30,7 @@ def build_chain():
#llm = VertexAIModelGarden(project=PROJECT_ID, endpoint_id=ENDPOINT_ID, location=LOCATION_ID)

llm = VertexAI(
model_name="text-bison@001",
model_name="chat-bison@002",
max_output_tokens=1024,
temperature=0.2,
top_p=0.8,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from langchain.chains import ConversationalRetrievalChain
from langchain.prompts import PromptTemplate
#from langchain.llms import VertexAIModelGarden
from langchain.embeddings import VertexAIEmbeddings
from langchain.vectorstores import MatchingEngine
from langchain.llms import VertexAI
#from langchain_google_vertexai import VertexAIModelGarden
from langchain_google_vertexai import VertexAIEmbeddings
from langchain_google_vertexai import VectorSearchVectorStore
from langchain_google_vertexai import ChatVertexAI
import sys
import json
import os
Expand Down Expand Up @@ -35,23 +35,24 @@ def build_chain():

#llm = VertexAIModelGarden(project=PROJECT_ID, endpoint_id=ENDPOINT_ID, location=LOCATION_ID)
llm = VertexAI(
model_name="text-bison@001",
model_name="chat-bison@002",
max_output_tokens=1024,
temperature=0.2,
top_p=0.8,
top_k=40,
verbose=True,
)
embeddings = VertexAIEmbeddings()
embeddings = VertexAIEmbeddings(model_name="textembedding-gecko@003")

vector_store = MatchingEngine.from_components(
vector_store = VectorSearchVectorStore.from_components(
project_id=PROJECT_ID,
region=LOCATION_ID,
gcs_bucket_name=BUCKET,
embedding=embeddings,
index_id=VC_INDEX_ID,
endpoint_id=VC_ENDPOINT_ID
)


retriever = vector_store.as_retriever(
search_type="similarity",
Expand Down
Loading

0 comments on commit dac89f5

Please sign in to comment.