Skip to content

Instantly share code, notes, and snippets.

View SaschaHeyer's full-sized avatar
👨‍🚀

Sascha Heyer SaschaHeyer

👨‍🚀
View GitHub Profile
import re
import time
import streamlit as st
import pandas as pd
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin, urlparse
import vertexai
from vertexai.generative_models import GenerativeModel
import vertexai.preview.generative_models as generative_models
@SaschaHeyer
SaschaHeyer / gemma_vllm_tpu.md
Last active September 2, 2024 12:15
gemma vllm TPU

gcloud config set project sascha-playground-doit export PROJECT_ID=$(gcloud config get project) export REGION=us-central1 export CLUSTER_NAME=vllm export HF_TOKEN=XXX

gcloud container clusters create-auto ${CLUSTER_NAME}
--project=${PROJECT_ID}
--region=${REGION}
--release-channel=rapid \

@SaschaHeyer
SaschaHeyer / gemini-code-assist-question2.md
Created July 30, 2024 08:39
gemini-code-assist-question2.md

Question: how can I deploy a LLM to Google cloud? The model size is around 80GB.

Answer: Deploying an 80GB LLM to Google Cloud is a great goal! It's a bit like moving a large piece of furniture - you need the right tools and plan to make it smooth. Here's a breakdown of how to do it:

  1. Choose Your Deployment Platform:

Vertex AI: This is Google Cloud's managed machine learning platform. It's designed for deploying and managing models, including large ones. Vertex AI offers:

Model Serving: You can deploy your LLM as a model endpoint, allowing you to send requests for predictions.

@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