File tree 18 files changed +31
-31
lines changed
18 files changed +31
-31
lines changed Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START generativeai_sdk_chat]
16
- from vertex_ai .preview .language_models import ChatModel , InputOutputTextPair
16
+ from vertexai .preview .language_models import ChatModel , InputOutputTextPair
17
17
18
18
19
19
def science_tutoring (temperature = .2 ):
Original file line number Diff line number Diff line change 14
14
15
15
import pytest
16
16
17
- from vertex_ai .preview .language_models import ChatModel , InputcontentputTextPair
17
+ from vertexai .preview .language_models import ChatModel , InputcontentputTextPair
18
18
19
19
import chat
20
20
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START generativeai_sdk_classify_news_items]
16
- from vertex_ai .preview .language_models import TextGenerationModel
16
+ from vertexai .preview .language_models import TextGenerationModel
17
17
18
18
19
19
def classify_news_items (temperature = 0 ):
Original file line number Diff line number Diff line change 14
14
15
15
import pytest
16
16
17
- from vertex_ai .preview .language_models import TextGenerationModel
17
+ from vertexai .preview .language_models import TextGenerationModel
18
18
19
19
import classify_news_items
20
20
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START generativeai_sdk_embedding]
16
- from vertex_ai .preview .language_models import TextEmbeddingModel
16
+ from vertexai .preview .language_models import TextEmbeddingModel
17
17
18
18
19
19
def text_embedding ():
20
20
"""Text embedding with a Large Language Model."""
21
- model = TextEmbeddingModel .from_pretrained ("textembedding -gecko@001" )
21
+ model = TextEmbeddingModel .from_pretrained ("embedding -gecko@001" )
22
22
embeddings = model .get_embeddings (["What is life?" ])
23
23
for embedding in embeddings :
24
24
vector = embedding .values
Original file line number Diff line number Diff line change 15
15
import pytest
16
16
import numpy as np
17
17
18
- from vertex_ai .preview .language_models import TextEmbeddingModel
18
+ from vertexai .preview .language_models import TextEmbeddingModel
19
19
20
20
import embedding
21
21
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START generativeai_sdk_extraction]
16
- from vertex_ai .preview .language_models import TextGenerationModel
16
+ from vertexai .preview .language_models import TextGenerationModel
17
17
18
18
19
19
def extractive_question_answering (temperature = 0 ):
20
20
"""Extractive Question Answering with a Large Language Model."""
21
- model = TextGenerationModel .from_pretrained ("google/ text-bison@001" )
21
+ model = TextGenerationModel .from_pretrained ("text-bison@001" )
22
22
response = model .predict (
23
23
'''Background: There is evidence that there have been significant changes \
24
24
in Amazon rainforest vegetation over the last 21,000 years through the Last \
Original file line number Diff line number Diff line change 14
14
15
15
import pytest
16
16
17
- from vertex_ai .preview .language_models import TextGenerationModel
17
+ from vertexai .preview .language_models import TextGenerationModel
18
18
19
19
import extraction
20
20
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START generativeai_sdk_ideation]
16
- from vertex_ai .preview .language_models import TextGenerationModel
16
+ from vertexai .preview .language_models import TextGenerationModel
17
17
18
18
19
19
def interview (temperature = .2 ):
20
20
"""Ideation example with a Large Language Model"""
21
- model = TextGenerationModel .from_pretrained ("google/ text-bison@001" )
21
+ model = TextGenerationModel .from_pretrained ("text-bison@001" )
22
22
response = model .predict (
23
23
'Give me ten interview questions for the role of program manager.' ,
24
24
temperature = temperature ,
Original file line number Diff line number Diff line change 14
14
15
15
import pytest
16
16
17
- from vertex_ai .preview .language_models import TextGenerationModel
17
+ from vertexai .preview .language_models import TextGenerationModel
18
18
19
19
import ideation
20
20
Original file line number Diff line number Diff line change 16
16
from typing import Union
17
17
import pandas as pd
18
18
19
- from vertex_ai .preview .language_models import TextGenerationModel , TextEmbeddingModel
20
- from google .cloud import aiplatform
19
+ from vertexai .preview .language_models import TextGenerationModel , TextEmbeddingModel
20
+ from google .cloud import vertexai
21
21
22
22
23
23
def list_tuned_models (project_id , location ):
24
24
"""List tuned models."""
25
- aiplatform .init (project = project_id , location = location )
26
- model = TextGenerationModel .from_pretrained ("google/ text-bison@001" )
25
+ vertexai .init (project = project_id , location = location )
26
+ model = TextGenerationModel .from_pretrained ("text-bison@001" )
27
27
tuned_model_names = model .list_tuned_model_names ()
28
28
print (tuned_model_names )
29
29
# [END generativeai_sdk_list_tuned_models]
Original file line number Diff line number Diff line change 14
14
15
15
import pytest
16
16
17
- from vertex_ai .preview .language_models import TextGenerationModel , TextEmbeddingModel
17
+ from vertexai .preview .language_models import TextGenerationModel , TextEmbeddingModel
18
18
19
19
import list_tuned_models
20
20
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START generativeai_sdk_sentiment_analysis]
16
- from vertex_ai .preview .language_models import TextGenerationModel
16
+ from vertexai .preview .language_models import TextGenerationModel
17
17
18
18
19
19
def sentiment_analysis (temperature = 0 ):
20
20
"""Sentiment analysis example with a Large Language Model."""
21
- model = TextGenerationModel .from_pretrained ("google/ text-bison@001" )
21
+ model = TextGenerationModel .from_pretrained ("text-bison@001" )
22
22
response = model .predict (
23
23
'''I had to compare two versions of Hamlet for my Shakespeare class and \
24
24
unfortunately I picked this version. Everything from the acting (the actors \
Original file line number Diff line number Diff line change 14
14
15
15
import pytest
16
16
17
- from vertex_ai .preview .language_models import TextGenerationModel
17
+ from vertexai .preview .language_models import TextGenerationModel
18
18
19
19
import sentiment_analysis
20
20
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START generativeai_sdk_summarization]
16
- from vertex_ai .preview .language_models import TextGenerationModel
16
+ from vertexai .preview .language_models import TextGenerationModel
17
17
18
18
19
19
def text_summarization (temperature = .2 ):
20
20
"""Summarization Example with a Large Language Model"""
21
- model = TextGenerationModel .from_pretrained ("google/ text-bison@001" )
21
+ model = TextGenerationModel .from_pretrained ("text-bison@001" )
22
22
response = model .predict (
23
23
'''Provide a summary with about two sentences for the following article:
24
24
The efficient-market hypothesis (EMH) is a hypothesis in financial \
Original file line number Diff line number Diff line change 14
14
15
15
import pytest
16
16
17
- from vertex_ai .preview .language_models import TextGenerationModel
17
+ from vertexai .preview .language_models import TextGenerationModel
18
18
19
19
import summarization
20
20
Original file line number Diff line number Diff line change 16
16
from typing import Union
17
17
import pandas as pd
18
18
19
- from vertex_ai .preview .language_models import TextGenerationModel , TextEmbeddingModel
20
- from google .cloud import aiplatform
19
+ from vertexai .preview .language_models import TextGenerationModel , TextEmbeddingModel
20
+ from google .cloud import vertexai
21
21
22
22
23
23
def tuning (
@@ -41,13 +41,13 @@ def tuning(
41
41
with rows for each training example.
42
42
43
43
Args:
44
- project_id: GCP Project ID, used to initialize aiplatform
45
- location: GCP Region, used to initialize aiplatform
44
+ project_id: GCP Project ID, used to initialize vertexai
45
+ location: GCP Region, used to initialize vertexai
46
46
training_data: GCS URI of training file or pandas dataframe of training data
47
47
train_steps: Number of training steps to use when tuning the model.
48
48
"""
49
- aiplatform .init (project = project_id , location = location )
50
- model = TextGenerationModel .from_pretrained ("google/ text-bison@001" )
49
+ vertexai .init (project = project_id , location = location )
50
+ model = TextGenerationModel .from_pretrained ("text-bison@001" )
51
51
52
52
model .tune_model (
53
53
training_data = training_data ,
Original file line number Diff line number Diff line change 14
14
15
15
import pytest
16
16
17
- from vertex_ai .preview .language_models import TextEmbeddingModel
17
+ from vertexai .preview .language_models import TextEmbeddingModel
18
18
19
19
import tuning
20
20
You can’t perform that action at this time.
0 commit comments