Lessons from “GenAI for developers” course by Google

I just finished the Google Cloud Skills path called “Generative AI for developers” and I wanted to write down some of the main lessons and impressions I had.

Overall I think the lessons were well-thought out, aimed at an intermediate audience like me, and I learned a lot about the various Google tools (here’s my cert). However there were also some technology snags along the way that detracted from the experience.

Main topics of the course

The topics in the course are the following:

  1. Introduction to Image Generation – with an Intro video + quiz re: how diffusion models are used for image generation
  2. Attention Mechanism – Intro video + quiz re: how attention mechanisms work, and can be used for a variety of tasks from text summarization to translation
  3. Encoder – Decoder Architecture – Intro video, Jupyter Lab (Python code) walkthrough + quiz re: how encoder – decoder works, and can be used in sequence to sequence tasks such as text summarization, Q&A, translation etc
  4. Transformer models and BERT – Intro video, Jupyter Lab walkthrough + quiz re: main components of the Transformer architecture and the self-attention mechanism
  5. Create Image Captioning models – Intro video, Jupyter Lab walkthrough + quiz re: how do use deep learning to create Image captions
  6. Introduction to Generative AI Studio – Intro video + quiz regarding Vertex AI for customizing and prototyping Generative AI models.
  7. Generative AI explorer – A set of labs using Jupyter Notebooks to explore different GenAI models, and try out prompting tools and various parameters (see below)
  8. Explore and Evaluate Models using Model Garden – Using Vertex AI to try out different Foundation Models, tools and parameters (see below)
  9. Prompt Design using Palm – How to design good prompts, setting restrictions and interacting with Palm 2, that has detailed reasoning, language and coding capabilities (see below).

Generative AI explorer – with Vertex AI

The lessons that I liked the most were using different examples to teach how to use the models in different use cases. Everything was run on Google  Vertex AI – which is a unified AI platform, that allows you to:

  • Select from 100+ foundation models in the Model Garden
  • Try out code snippets with JupyterLab in the Workbench
  • Access every model with a simple API call
  • Train and deploy models to Production

Text generation examples

You can test any of the Text generation models by selecting the model in the top right dropdown. You specify the context (prompt) for the model, and provide input/ output examples if you prefer. Giving no examples is called zero-shot prompting, giving a few examples is called few shot prompting, which for most use cases is the better alternative.

Pressing the ‘Get code’ button also top right gives you the code snippets you need to connect to the selected model in your Google Cloud project:

Chat model examples

Under the Language models you can customize & test the foundation models e.g for customer service or support use cases. Some key parameters include:

  • Temperature: A lower temperature of say 0, 0.1 are better when factual, true or false responses are required. A higher temperature say 0.6 to 1 will give more imaginative answers, but will also increase the risk of the model hallucinating.
  • Token limit: Determines the maximum number of text output from one prompt, with one token equal to roughly four characters.
  • Safety Settings: You can define how strict the model responses are regarding potentially harmful content, such as hate speech, sexual content or harassment.

Codey – code generation, chat and completion

You can select between different code engines based on your use case:

  • Codey for Code Generation (6k or 32k token limit). Takes your natural language input and generates the requested code – example below:
  • Codey for Code Chat (6k or 32k token limit) – model chatbot fine tuned for helping with code related questions.
  • Codey for  Code Completion – model fine tuned to suggest code based on the context, code already written. 

Exploring the Model Garden

In the Model Garden you can try out different Foundation models such as:

  • Gemini Pro – e.g. for text summarization, text generation, entity recognition, sentiment analysis and more.
  • Gemini Pro Vision (Multimodal) – e.g. for visual understanding, classification, summarization and processing visual inputs such as photos, video, documents, infographics etc.
  • Claude 2: a leading LLM from Anthropic – similar to Gemini Pro
  • Llama 2: Open Source LLM released by Facebook / Meta that is fine-tunable to your use case/ domain.

There are over 100+ models to date, however the main drawback of note is that the Fine Tunable models (except for LLAMA2 and Falcon) are mostly just related to classification or vision detection/ classification.

Prompt Design

Some of the prompting lessons here:

  • Be concise
  • Be specific and well-defined
  • Ask for one task at a time 
  • Improve response quality by including examples (few shot)
  • Use a Dare prompt  – Determine Appropriate Response (DARE) prompt, which uses the LLM itself to decide whether it should answer a question based on what its mission is. Meaning that you send the regular prompt / context first, followed by the Dare prompt to verify that the output generated matches the mission.

Most of the example Jupyter Notebooks in the course can be found on Github here.

Conclusion

Overall I think the course teaches the material well – I liked the hands on Jupyter Notebooks better than the video + quiz sections as it’s easier to learn with concrete examples.

I’m most impressed by is the completeness of the Google Vertex AI platform, and I feel that I have a good basis to use the platform independently today.

Health test Q3 2023

It was July 2023 and I wanted to perform a comprehensive Health test that I would be trying every quarter. My bodyweight at the time was about #185 (86kg) and I’m a 49 year old male. 

Here’s the outline and the results of the test:

ComponentType Test dayExercisesResult
Upper body, pullStrengthMondayChin-up with Bodyweight + #706 reps
Upper body, pushStrengthMonday Standing Press #125 6 reps
RunCardioTuesday1.1 mile7.35(about 7 min mile)
Lower body, pullStrengthWednesdayDead-lift 2x Bodyweight (#370)2 reps
Upper body, pushStrengthFridayBench press bodyweight (#185)6 reps

Looking back at the test I realize I could have added some more long-form Cardio into the mix as well. There were a few lifts I had expected to lift more in – but that’s the score as it was then 🙂

Lessons from two weeks with a CGM

I received a CGM (Continuous Glucose Monitor) about two weeks ago via the Levels start-up. The package arrived a few days after ordering, and the initial setup was relatively easy and painless. I was able to easily export the data from the Levels website.

So how do the results look? The easiest way I can think of to show you the results are using Python (pandas, matplotlib, seaborn libraries) so here we go: (I’m skipping some data wrangling bits here..)

Glucose level distribution as a histogram

Glucose Level Time Series with rolling statistics

Honestly this data has me a bit worried because generally doctors, Peter Attia MD and the Levels program all suggest that fasting glucose should be less than 100/mg/dl…

Also, I wanted to correlate the glucose readings with the time of day, so we can do that eg with a heatmap:

Glucose Levels by Day, Hour in a Heatmap

This chart is really interesting to me because here a number of things stand out to me:

  • I was in Austin from April 26th to April 28th for a conference, and those days I did a light workout in the morning, and had a light lunch. So clearly a lighter lunch, moving around in the afternoon leads to lower fasting glucose.
  • I slept really badly Fri-28th-Sat 29th due to a late flight, and clearly a bad night sleep results in a bad fasting glucose.
  • I generally workout in the afternoon – between 4PM and 6PM, and so higher readings there are not alarming to me. 
  • What strikes me as odd is the differences in the morning fasting glucose -say 5AM to 10AM – varies between 66 mg/dl to 120 mg/dl…The mean is still around 100 mg/dl (which is not great), but I’m surprised about the high variability.
  • Since I do intermittent fasting (lunch is my first meal) I had generally thought that my morning glucose would be lower. 
  • There is a missing block on May 2nd as I switched the old sensor to the new one – as you have to do that every 10 days. The most painful thing was tearing the Levels patch off my hairy arms 🙂

All in all I’m very happy to have all this data from the CGM/Levels to explore, giving a lot of actionable intelligence – so I will try some life-style, diet modifications soon.

How I train in 2023

This post is an outline, a template of how I train in 2023.

Disclaimer: I’m a middle-aged male, 6ft 2 in, just under 200 lbs, and my goals are mainly to keep myself healthy for the long-term, and to have energy, vitality for all daily interactions. You can adapt this template to your own needs and always listen to your doctor 🙂

The basic training blocks are focused on either strength or cardio-vascular health, with each training day geared towards adaptions in either one. I train most days, with Sundays being ‘off’. This is a template, and so smaller changes can be made according to how I feel, my shorter-term goals and my schedule etc. Exercises marked e.g. 2A and 2B means they are super-setted, meaning you do one set of A, then one set of B.

Monday – strength focus

FocusExerciseDurationSetsReps% 1 RM
Speed1. Front Squat15 minutes5260%-70%
Strength2 A) Standing Press25 minutes3-43-580%-90%
Strength2 B) Weighted Chins25 minutes3-43-580%-90%
HIIT3. Chins, Dips and Run (done as fast as possible)15 minutes31260%-70% – HR 140-160 BPM

Tuesday – cardio focus

Exercise# roundsDurationComment
A – Assault Bike38 minKeep HR in Zone 2 (about 13o BMP for me)
B – Jog38 minKeep HR in Zone 2 (about 13o BMP for me)
TotalAbout 45-50 minFollowed by light stretching

Wednesday – strength focus

FocusExerciseDurationSetsReps%1 RM
SpeedExplosive push-ups & long jumps15 minutes33N/A
StrengthTrap Bar Deadlift20 minutes3-43-575%-90%
StrengthBulgarian Squat (or RFESS)15 minutes31070%

Thursday – cardio focus (alt. yoga, alt. rest)

Exercise# roundsDurationComment
A – Assault bike38 MinutesKeep HR in Zone 2 (about 13o BMP for me)
B – Jog38 MinutesKeep HR in Zone 2 (about 13o BMP for me)
TotalAbout 45-50 minutesFollowed by light stretching.

Friday – strength focus

FocusExerciseDurationSetsReps% 1 RM
Speed1. Power Clean15 minutes5260-70%
Strength2A Bench press25 minutes3-43-575-90%
Strength2B Weighted Inverted Row25 minutes48-1265-75%
Assistance3A Bicep Curl15 minutes2-38-1265-75%
Assistance3B Lying tricep extension15 minutes2-38-1265-75%
Assistance3C Face pulls15 minutes2-38-1265-75%

Saturday – cardio focus

Exercise# roundsDurationComment
1A – Assault bike28 minutesKeep HR in Zone 2 (about 13o BMP for me)
1B – Jog28 minutesKeep HR in Zone 2 (about 13o BMP for me)
2 – Sprinting4-615 minutesVary shorter and longer sprints, with good amount of rest in between rounds.
TotalAbout 50 minutesFollowed by light stretching.

Hopefully this gave you some ideas or inspiration how to plan your own training, let me know in the comments if you have any questions.

Thanks for reading,

Oskar