Skip to content

Instantly share code, notes, and snippets.

View SaschaHeyer's full-sized avatar
👨‍🚀

Sascha Heyer SaschaHeyer

👨‍🚀
View GitHub Profile
@SaschaHeyer
SaschaHeyer / gemini-code-assist-question1.md
Created July 30, 2024 06:35
gemini-code-assist-question1.md

Question: How can I create text embeddings with google cloud?

Answer: You can create text embeddings with Google Cloud using the Text Embeddings API on Vertex AI. This API allows you to generate numerical representations of text, which can be used for various tasks like:

Semantic Search: Finding documents similar in meaning to a given query. Recommendation Systems: Suggesting relevant content based on user preferences. Clustering: Grouping similar documents together. Question Answering: Finding answers to questions based on a knowledge base.

@SaschaHeyer
SaschaHeyer / compare.py
Last active December 18, 2023 11:55
gen-ai-vs-translation-api
import vertexai
from vertexai.language_models import TextGenerationModel
from google.cloud import translate_v2 as translate
vertexai.init(project="sascha-playground-doit", location="us-central1")
parameters = {
"candidate_count": 1,
"max_output_tokens": 1024,
"temperature": 0.9,
"top_p": 1
@SaschaHeyer
SaschaHeyer / query.py
Last active February 8, 2023 09:42
Vertex AI Matching Engine Query
response = index_endpoint.match(
deployed_index_id="similar_text_deployed",
queries=[embedding[0]],
num_neighbors=5
)
@SaschaHeyer
SaschaHeyer / response.json
Created January 28, 2023 16:31
response.json
{
"predictions": [
{
"confidence": 0.9409326314926147,
"sentiment": "POSITIVE"
}
]
}
@SaschaHeyer
SaschaHeyer / start_execution.py
Last active November 16, 2022 19:35
Vertex AI Experiments
training_data_artifact = aiplatform.Artifact.create(
schema_title='system.Dataset',
uri='gs://doit-vertex-demo/higgs/training.csv',
display_name='data')
with aiplatform.start_execution(
schema_title="system.ContainerExecution",
display_name='training'
) as execution:
@SaschaHeyer
SaschaHeyer / get_experiment_run_data.py
Created November 14, 2022 20:26
Vertex AI Experiments
experiment_run = aiplatform.ExperimentRun(
run_name='run-1668456760',
experiment='experiment-demo',
)
print(experiment_run.get_artifacts())
print(experiment_run.get_metrics())
print(experiment_run.get_params())
print(experiment_run.get_time_series_data_frame())
print(experiment_run.get_classification_metrics())
@SaschaHeyer
SaschaHeyer / compare.py
Created November 14, 2022 20:23
Vertex AI Endpoints
experiment_df = aiplatform.get_experiment_df()
experiment_df = experiment_df[experiment_df.experiment_name == 'experiment-demo']
experiment_df
@SaschaHeyer
SaschaHeyer / init_tensorboard.py
Last active November 14, 2022 16:22
Vertex AI Experiment
aiplatform.init(
project='sascha-playground-doit',
location='us-central1',
experiment='experiment-sample',
experiment_tensorboard='projects/sascha-playground-doit/locations/us-central1/tensorboards/6382621018774568960'
)
@SaschaHeyer
SaschaHeyer / tensorboard_instance.py
Created November 11, 2022 14:34
Vertex AI Experiments
experiment_tensorboard = vertex_ai.Tensorboard.create()
@SaschaHeyer
SaschaHeyer / artifact.py
Created November 11, 2022 09:51
Vertex AI Experiment
training_data_artifact = aiplatform.Artifact.create(
schema_title='system.Dataset',
uri='gs://doit-vertex-demo/higgs/training.csv',
display_name='training data')