Gen AI Tutorial menu

Gen AI Introduction and Text Generation

Generative AI is AI that produces new content in answer to a prompt.

Predictive AI vs Generative AI

Predictive (older) AIGenerative AI
Main jobLabel or predictCreate something new
Example inputA photo"Draw a rickshaw at sunset"
Example output"This is a cat"A brand-new image
Typical useSpam filters, fraud checksWriting, design, voice-overs, code

Both learn from data. The difference is the output: a label or number, or brand-new content.

Types of Generative AI

  • Text: answers, essays, emails, summaries, translations and code
  • Images: pictures, logo ideas, product mock-ups
  • Audio: speech in many voices, music, sound effects
  • Video: short clips from a text description or an image
  • Multimodal: models that can read and produce several types at once, such as reading a photo and answering in text

Text Generation

Text is the most widely used kind of Gen AI. Chat assistants like ChatGPT, Gemini and Claude are built on large language models (LLMs). You type a message, and the model writes a reply.

Here is a typical study prompt:

Example

text
I am a first-year student. Explain the difference between
RAM and storage using an example of a school bag and a cupboard.
Keep it under 80 words.

And a typical work prompt:

Example

text
Rewrite this message to sound polite and professional:
"send me the invoice today, it is late already"

What Text Generators Are Good At

TaskExample
Explaining"Explain photosynthesis simply"
Summarising"Summarise this 5-page notice in 5 bullet points"
Drafting"Write a leave application to my principal"
Rewriting"Make this paragraph shorter and clearer"
Translating"Translate this into simple Urdu"
Coding"Write a Python function that checks if a number is even"
Brainstorming"Give 10 names for a home bakery in Lahore"

Using Text AI from Code

Programmers can also call text models from their own programs through an API. You will learn this in the Chatbots tutorial. The idea in Python looks like this (the request is sent to the AI company's server, and the reply comes back as text):

Example

python
def build_request(question):
    return {
        "messages": [
            {"role": "system", "content": "You are a helpful tutor."},
            {"role": "user", "content": question},
        ]
    }

request = build_request("What is a variable?")
print(request["messages"][1]["content"])
Output
What is a variable?

This code only builds the message; sending it needs an API key and an internet connection.

Where Text AI Fails

  • It can invent facts, quotes and references (called hallucinations).
  • It may not know recent events unless it can search the web.
  • It can sound confident even when unsure.
  • It may misunderstand vague prompts.

The more specific your prompt (who you are, what you need, how long, what format), the better the answer.

Exercise

Exercise

Which of these is a generative AI task?

Learn Gen AI with a teacher

Join the AI & Prompt Engineering course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp