Basic concepts of generative AI

avatar Diya Nayak

Published on May 30, 2024

4 min read

How often do you come across the term “Gen AI”? Well, in today’s world, it has become more than just a term, and almost a necessity. Gen AI or Generative AI is a type of artificial intelligence that creates new texts, images, music, audio, or video based contents.

So, how does it work?

The way Gen AI operates is by using an ML model like Markov Chains or Recurrent Neural Networks (RNNs) and, more recently, Transformers to train itself on the existing dataset created by humans and then applying the patterns it has learned to create new content.

How to enhance its quality?

It is nevertheless possible to regulate the creativity of your text through what is known as ‘temperature’. Temperature determines how creative or how ordered the AI will be in generating its output. The temperature range lies between 0 to 2. Lower temperature makes the output definite, and increase in temperature increases the creativity. Low Temperature for e.g 0. 2 can be utilized for a technical article on ‘Quantum Computing Basics’ that would provide clear and accurate information whereas High Temperature (e. g. , 0. 8) can be useful for a story writing idea such as ‘A Futuristic City’.

However, can you imagine how it will be if the AI model has never been trained for the specific prompt that you gave? So, to deal with this problem, we can use one-shot prompting. In one-shot prompting, the model is given a single example related to the task to help it understand what is expected.

Let's underdstand this by an example:-

Prompt: “Please prepare a recipe for vanilla cupcakes by taking the following example- chocolate chip cookies Recipe: Ingredients: butter, sugar, eggs, flour, chocolate chips. Preparation: Preheat the oven to 350°F. Cream butter and sugar…”

Now, the AI model will come up with a recipe that follows the format of the recipe provided.

Generated Recipe: "1 ½ cups all-purpose flour,1 ½ teaspoons baking powder, ¼ teaspoon salt,½ cup unsalted butter,.... Instructions: Preheat oven to 350°F (175°C). Line a 12-cup muffin pan with cupcake liners. Mix dry ingredients: In a medium bowl, whisk together the flour, baking powder, and salt…"
(“...” indicates that there are several other ingredients and instructions respectively)

Hence, by providing a clear example in the one-shot prompt, the model has a specific reference to guide its task, which can lead to more consistent and accurate outputs compared to the zero-shot approach. Zero-shot prompting is genereally the way a user gives prompts to AI i.e. not giving any specific example related to the task and therefore AI is asked to perform the task based on its general knowledge.

This brings us to the third prompt of Keywords and Phrases that are an essential part of a good prompt. This is particularly important for Search Engine Optimization (SEO) since the expressions it targets are selected in a way that makes sure they appear in the content. For example: SEO Keywords: For a website article on "Healthy Eating" will be Balanced Diet, Healthy Recipes, Nutritional Eating and Healthy Foods.

Now let’s use these techniques to make an image of a street.

Need: As a new artist you want to generate a “two-point perspective” image of a street as a reference of your new artwork.

Case 1: “Create an image of a street”.
Output:

Case 2: “Generate an image of a street in two-point perspective. Use the below given example and take temperature=0.5”

Output:

Therefore, by regulating temperature settings, using one-shot prompting and including the targeted keywords, you can enhance content quality and relevance.


Maybe even subscribe to our newsletter

Previous Post

Generate AI images in your Flutter apps with Cloudflare Workers AI

Next Post

JVM: Java's Magic Engine

Find Us Here!