Introduction

Hi folks! Welcome to an another exciting blog at Gamaka AI. This article basically deals with the use of Python with Gen AI using Google Colab. The advantage of using Google Colab is that it allows you to write and execute Python code directly in your browser without any setup or installation. It is a cloud-based Jupyter Notebook environment provided by Google. Here, we will be considering Gemini – a family of Gen AI created by Google DeepMind known for its multimodality and seamless reasonability across text, code, audio and images. A dynamic, general purpose programming language such as Python can then be leveraged with Gen AI which has a huge potential to generate excellent results.

Models​

Input

– Gemini 1.5 Pro (Preview only)
– Gemini 1.0 Pro
– Gemini 1.0 Pro Vision
Text and Images
Test
Text and Images

Follow This 5 Simple Steps To Get Started With Gemini Pro

In this article, we’ll be dealing with Gemini Pro that services text and chat by taking text as an input. So let’s get started with these 5 simple steps .

Step 1 – Obtain an API key to use Gemini API:
APIs are necessary for smooth data sharing among the applications involved. But before that, we need to get an API key. So, visit the Google AI Studio, create an API key and just copy it. For security purpose, the key has to be kept secret and should not be shared publicly.


Step 2 – Save the API key:

Open Google Colab and click on the Secrets tab. 


Paste the copied API key under the Value tab and assign a name under the Name tab. Here, we have named it as ‘Google_Studio’.

This is how we will interact with the API using Google Colab.


Step 3 – In order to use Gemini, install the required libraries and setup the model: 


Step 4 –Check the list of models from Google AI Studio:


Step 5 – Model configuration using Gemini Pro:




Notice the model selected here from the available list of models. It is ‘gemini-pro’. After that, we have given a sample prompt to the model asking ‘how many months are there in a year?’ to which it generates the correct factual output as ‘12’ since there are 12 months in a year. 
So far, we have seen a single prompt response. What if we want to start a whole new chat wherein several Qs will be asked during the chat seeking respective response for them? Possible! Here’s how…

Let’s start a chat using Gen AI:



In case you just want to check how the chat has been between the user and the model..



Here’s another way the chat can be done:


Finally, it is important to note that the more specific and exact the prompt given is, the more satisfying the result will be. Following example substantiates this.



It’s all about giving the exact prompts to get the most right output. However, one must keep in mind that GeminiAI is prone to the following limitations:

1. Bias

2. Hallucination

3. Inconsistency

In the evolving world of GenAI, it becomes imperative to maintain the prompts and output that are privacy driven, ethical, fair, rational, reliable and free from any biases.

More AI coding features like code completions, natural language to code generation and even a code-assisting chatbot are on the way from Colab. Colab will use Codey, a family of code models built on PaLM, as it was fine-tuned on a large dataset of high quality and permissively licensed code from external sources to improve performance on coding tasks. These Codey versions have been customized especially for Python and for Colab-specific uses. 

Tasks like generating larger blocks of code, writing whole functions from comments or prompts can be achieved from the Natural Language through code generation. This will reduce the need for writing repetitive code, so that you can focus on the more interesting parts of programming and data science. As of now, a new “Generate” button will be available in the notebook for the unsubscribed users for a limited time allowing them to enter any text prompt to generate code.



Soon, you’ll be able to ask questions directly in Colab like, “How do I import data from Google Sheets?” or “How do I filter a Pandas DataFrame?  The chatbot developed will enable this facility. As of now, Colab AI is available for a limited time for unsubscribed users.





Auto-complete suggestions are made available for the eligible paid users.


Interesting..right?  The Codey models inside Colab will help increase programming speed, quality, and comprehension. Initial features will majorly focus on code generation.