Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
← Certified Racket AI Expert · Lesson 7 of 8

Module Six

📖 Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
7
Module 6 · Racket AI Specialist – Generative AI

✨ Module Six · Generative AI – Creating New Things

Certified Racket AI Specialist · The Creative Side of AI

📖 Module Introduction

Hello, young creator! 👋 So far, we've taught computers to do math, make decisions, and organise data. Now we will teach them something truly magical: how to create new things.

Think about a painter who mixes colours to make a new shade, or a musician who combines notes to make a new song. AI can do this too! We call this Generative AI — AI that creates new content like stories, poems, pictures, and even music.

In this module, we will learn the basics of how AI creates things. We'll use Racket to build our own simple generators — programs that produce new text, new lists, and even new structures. You'll become an AI artist!

🎨 Fun fact: Generative AI can now create paintings that sell for millions of dollars, and music that sounds like it was made by famous composers!

🎯 Learning Objectives

After this module, you will be able to:

  • ✔️ Understand what Generative AI is and why it's exciting.
  • ✔️ Use randomness to create unpredictable outputs.
  • ✔️ Build a text generator that creates new sentences.
  • ✔️ Build a pattern generator that creates art.
  • ✔️ Use combinations to create new things from existing parts.
  • ✔️ Understand how AI can "imagine" new things.
  • ✔️ Build your own simple story generator.

📚 Warm-up Story · The Magical Chef

Imagine you have a magical chef. Instead of following a recipe, this chef can invent new dishes. You give it some ingredients — rice, chicken, spices — and it creates a brand new meal that nobody has ever eaten before!

Generative AI works the same way. You give it examples (like words or pictures), and it learns the patterns. Then it uses those patterns to make something new.

Today, we'll build our own "magical chefs" using Racket. They won't be as smart as the ones in big companies, but they will create things that are new and fun!

   Ingredients (data)  →  AI learns patterns  →  Creates new things
      "cat", "dog", "bird"  →  "cog", "bat", "dird"  (new invented words!)
  

🧩 Main Lessons

Lesson 1 · What is Generative AI?

Definition: Generative AI is a type of AI that creates new content — like text, images, music, or code — instead of just analysing or classifying.

Why important: Generative AI is used to create art, write stories, help with design, and even discover new medicines!

Simple explanation: It's like a robot that can paint a new picture instead of just telling you about an existing one.

Real-life: ChatGPT writes new stories. DALL-E creates new images.

School: Imagine a computer that can write a new essay for you on any topic.

Home: A smart speaker that can make up a new bedtime story.

Nigerian: An AI that creates new African-inspired fashion designs.

Illustration:

   +-------------------+      +-------------------+
   |  Examples (data)  | ---> |  Generative AI    | --->  New creation
   +-------------------+      +-------------------+
         cats, dogs              "cog" (new animal)
         jazz, blues             new music style
  
📌 Mini summary: Generative AI creates new things from patterns it learns.

Lesson 2 · Randomness – The Spark of Creativity

Definition: Randomness is when something happens by chance, without a fixed order.

Why important: AI uses randomness to create variety. Without randomness, everything would be the same.

Simple explanation: It's like rolling a dice. You never know what number you'll get.

Real-life: A lottery draw uses randomness.

School: A teacher randomly picking a student to answer a question.

Home: Picking a random movie to watch.

Nigerian: Using a lucky draw at a carnival.

Illustration:

   (define (roll-dice) (random 6))
   (roll-dice) → 3
   (roll-dice) → 5
   (roll-dice) → 2
  
📌 Mini summary: Randomness makes outputs unpredictable and creative.

Lesson 3 · Picking Random Items from a List

We can use random and list-ref to pick a random item from a list.

   (define fruits '("apple" "banana" "orange" "mango"))
   (define (pick-random lst) (list-ref lst (random (length lst))))
   (pick-random fruits) → "banana"
  

This is the simplest generative technique!

📌 Mini summary: We can pick random items to create new combinations.

Lesson 4 · Building a Simple Word Generator

We can combine random pieces to make new words.

   (define starters '("b" "c" "d" "f" "g"))
   (define middles '("a" "e" "i" "o" "u"))
   (define endings '("t" "n" "p" "m"))
   (define (new-word)
     (string-append (pick-random starters) (pick-random middles) (pick-random endings)))
   (new-word) → "bim"
   (new-word) → "gan"
  

We just created a word generator!

📌 Mini summary: Randomly combining pieces creates new words.

Lesson 5 · Building a Story Generator

We can use the same idea to create simple stories.

   (define characters '("Ade" "Bola" "Chidi" "Dara"))
   (define actions '("ran" "jumped" "sang" "danced"))
   (define places '("market" "school" "beach" "village"))
   (define (story)
     (string-append (pick-random characters) " " (pick-random actions) " to the " (pick-random places)))
   (story) → "Bola sang to the beach"
  
📌 Mini summary: Combining random parts creates new stories.

Lesson 6 · Using Templates for Better Stories

We can use a template to make stories more interesting.

   (define templates
     '("The ~a loved to ~a in the ~a"
       "Every day, ~a would ~a at the ~a"
       "~a went to the ~a to ~a"))
   (define (better-story)
     (format (pick-random templates)
             (pick-random characters)
             (pick-random actions)
             (pick-random places)))
  
📌 Mini summary: Templates make generated text more meaningful.

Lesson 7 · Creating Art with Text

We can generate simple ASCII art using random choices.

   (define shapes '("  *  " " *** " "*****"))
   (define (make-art)
     (string-join (list (pick-random shapes) (pick-random shapes) (pick-random shapes)) "\n"))
   (make-art)
   →   *
      ***
     *****
  
📌 Mini summary: We can generate simple visual patterns.

Lesson 8 · Generative Lists

We can generate lists of random numbers or items.

   (define (random-list n)
     (if (= n 0)
         '()
         (cons (random 10) (random-list (- n 1)))))
   (random-list 5) → '(3 7 1 8 4)
  
📌 Mini summary: We can generate lists of any length with random values.

Lesson 9 · Generating Structured Data

We can generate structs with random fields.

   (struct person (name age))
   (define (random-person)
     (person (pick-random names) (+ 5 (random 15))))
   (random-person) → (person "Ade" 12)
  
📌 Mini summary: We can generate complex data structures.

Lesson 10 · Combining Patterns – The Power of Mixing

Generative AI works by learning patterns and mixing them. We can mix different categories.

   (define animals '("lion" "tiger" "bear"))
   (define colors '("red" "blue" "golden"))
   (define (new-animal) (string-append (pick-random colors) " " (pick-random animals)))
   (new-animal) → "red tiger"
  
📌 Mini summary: Mixing patterns creates novel combinations.

Lesson 11 · Building a Recipe Generator

We can generate new recipes by combining ingredients.

   (define meats '("chicken" "beef" "fish"))
   (define spices '("pepper" "ginger" "garlic"))
   (define veggies '("onions" "tomatoes" "peppers"))
   (define (recipe)
     (string-append "Cook " (pick-random meats) " with " (pick-random spices) " and " (pick-random veggies)))
  
📌 Mini summary: We can generate creative recipes!

Lesson 12 · Putting It All Together – A Complete Generator

Let's build a program that generates a full story with a character, setting, and plot.

   (define (full-story)
     (string-append
       "Once upon a time, " (pick-random characters)
       " lived in " (pick-random places)
       ". One day, they " (pick-random actions)
       " and found a " (pick-random animals)
       ". They became friends!"))
   (full-story)
   → "Once upon a time, Chidi lived in school. One day, they danced and found a tiger. They became friends!"
  

You just built a Generative AI system!

📌 Mini summary: We combined all techniques to build a complete story generator.

📖 Key Vocabulary

  • Generative AI: AI that creates new content.
  • Randomness: Something that happens by chance.
  • Template: A pattern with blanks to fill in.
  • Combination: Mixing different elements together.
  • Pattern: A repeated way of doing something.
  • Generator: A program that creates new things.

🧠 Important Concepts

  • Pattern recognition: AI learns patterns from examples.
  • Randomness: Adds variety and creativity.
  • Combination: New things come from mixing existing things.
  • Template filling: A common generative technique.

📘 Step-by-Step Explanations

How to build a generator:

  1. Decide what you want to generate (words, stories, art).
  2. Gather examples and break them into pieces.
  3. Create lists of each type of piece.
  4. Write a function that randomly picks pieces and combines them.
  5. Test it many times to see the variety.
  6. Add templates to make the output better.

🌍 Real-life Examples

  • ChatGPT: generates text responses.
  • DALL-E: generates images from text.
  • Music AI: generates new songs.

🇳🇬 Nigerian Examples

  • AI that generates new Ankara patterns.
  • AI that writes new Nigerian folktales.
  • AI that creates new recipes for Nigerian dishes.

🎈 Fun Examples

  • Generate new ice cream flavours.
  • Generate new superhero names.
  • Generate new holiday destinations.

🏠 Everyday Examples

  • Making a new sandwich from available ingredients.
  • Choosing a random outfit.
  • Inventing a new game with existing rules.

🧑‍🏫 Teacher Notes

Encourage creativity. Let students build generators for anything they like. Emphasise that generative AI starts with simple techniques. Use the "mix and match" concept. Show how big AI uses these same ideas on a massive scale.

👪 Parent Tips

Ask your child to generate stories for you. Use the generators to create fun family activities — like a new recipe for dinner or a new bedtime story. Celebrate the creativity!

🌟 Interesting Facts

  • Some AI-generated art has been sold for over $400,000.
  • Generative AI can create new drug molecules for medicine.
  • AI can generate new levels in video games.

🤔 Did You Know?

The first generative AI programs in the 1960s could generate simple poetry. Today, they can write entire novels!

🧾 Remember This

  • Generative AI creates new things.
  • Randomness is important for creativity.
  • We combine pieces to make new things.
  • Templates make outputs better.
  • You can build your own generators!

⚠️ Common Mistakes

  • Forgetting to use random for variety.
  • Using lists that are too small — not enough variety.
  • Not testing the generator enough times.
  • Making templates too strict — no creativity.

✅ Best Practices

  • Use large lists for more variety.
  • Use templates for better structure.
  • Test your generator many times.
  • Combine different types of data.

📊 ASCII Illustrations

   Generator flow:
   Lists of pieces  →  Random pick  →  Combine  →  New creation

   Example:
   [Ade, Bola, Chidi] + [ran, sang] + [market, school]
   → "Chidi sang at school"
  
   Tree of combinations:
       Start
         |
         V
    Choose character
         |
         V
    Choose action
         |
         V
    Choose place
         |
         V
    Combine all → story!
  

📋 Comparison Table

TechniqueHow it worksExample
Random pickPick random item(pick-random names)
CombinationMix multiple picks(string-append name action place)
TemplateFill in blanks"The ~a ~a in the ~a"

📌 End-of-Module Summary

You've unlocked the creative side of AI! You learned about generative AI, used randomness, combined pieces to create new things, and built story generators and more. These are the same techniques used by big AI companies, just on a smaller scale. You are now an AI creator!

❓ Frequently Asked Questions (10)

  1. What is Generative AI? — AI that creates new content.
  2. Why use randomness? — To make outputs varied and creative.
  3. What is a template? — A pattern with blanks to fill.
  4. Can AI create art? — Yes, many AI systems create art.
  5. How do we combine pieces? — Using functions like string-append.
  6. What is a generator? — A program that creates new things.
  7. Can AI write stories? — Yes, some AI writes stories.
  8. Why is combination important? — New things come from mixing.
  9. How can I make my generator better? — Use more data and better templates.
  10. Is this really AI? — Yes, this is how many generative AI systems start!

📝 Review Questions (15)

  1. What is Generative AI?
  2. Why do we use randomness?
  3. How do you pick a random item from a list?
  4. Write a function that picks a random word from a list.
  5. What is a template?
  6. How can you make a story generator?
  7. What is combination in generative AI?
  8. Write a function that generates a random sentence.
  9. How can you generate a random number?
  10. Why are templates useful?
  11. What is a generator?
  12. Give an example of a real generative AI.
  13. How can you generate a random list?
  14. What is the difference between random and fixed?
  15. How do you combine strings in Racket?

✏️ Fill-in-the-Blank

  1. ______ AI creates new content.
  2. ______ adds variety to generated content.
  3. A ______ is a pattern with blanks to fill.
  4. We use ______ to combine pieces.
  5. A ______ is a program that creates new things.

✅ True or False

  1. Generative AI only analyses data. (False)
  2. Randomness is important for creativity. (True)
  3. Templates make outputs less interesting. (False)
  4. Combining pieces is a generative technique. (True)
  5. AI cannot generate new images. (False)

🔘 Multiple Choice (15)

  1. What is Generative AI? A) creates new content B) sorts data C) adds numbers D) deletes files → A
  2. Why use randomness? A) for variety B) to slow down C) to delete data D) to sort → A
  3. How do you pick a random item? A) list-ref + random B) first C) rest D) filter → A
  4. What is a template? A) a pattern B) a list C) a number D) a string → A
  5. What does (string-append "hi" " there") do? A) combines strings B) adds numbers C) sorts D) filters → A
  6. What is a generator? A) creates new things B) deletes things C) sorts things D) counts things → A
  7. Which is an example of generative AI? A) ChatGPT B) Calculator C) Database D) Spreadsheet → A
  8. What does (pick-random lst) do? A) picks random item B) sorts list C) deletes list D) adds to list → A
  9. How can we make a story generator? A) combine random parts B) only use one part C) no randomness D) use fixed text → A
  10. What is combination? A) mixing things B) deleting things C) sorting things D) counting things → A
  11. What does (random 10) return? A) number 0-9 B) 10 C) list D) string → A
  12. Why are templates useful? A) make output structured B) add randomness C) delete data D) sort lists → A
  13. Can AI generate music? A) yes B) no C) only if told D) never → A
  14. What is the first step in building a generator? A) gather pieces B) delete data C) sort list D) add numbers → A
  15. What does (length lst) do? A) returns length B) picks random C) sorts D) deletes → A

🔗 Matching

TermMatch
1. GenerativeA. creates new things
2. RandomB. by chance
3. TemplateC. pattern with blanks

Answers: 1-A, 2-B, 3-C

📝 Short Answer

  1. Explain how randomness helps AI create new things.
  2. What is a template and why is it useful?
  3. Write a function that generates a random sentence with a subject, verb, and object.

📖 Scenario-based Exercises

Scenario: You are building an AI that generates new superhero names. You have lists of adjectives (e.g., "mighty", "shadow") and nouns (e.g., "tiger", "dragon"). How would you build the generator?

Answer: Use random pick from adjectives and nouns, combine with string-append.

👥 Group Activity

Each group builds a generator for a topic of their choice (e.g., new ice cream flavours, new sports names, new holiday destinations). Share and compare outputs.

🧑‍💻 Individual Activity

Build a generator that creates new pet names by combining syllables.

💬 Classroom Discussion Questions

  • How is generative AI different from other AI?
  • Can a generator ever run out of new ideas?
  • How could you make your generator even more creative?

🛠️ Mini Project

Build a "magic spell" generator. Create lists of words that sound magical and combine them to create new spells with "powers".

📋 Practical Assignment

Build a generator that creates new Nigerian dish descriptions. Use ingredients, cooking methods, and tasty words.

🏆 Challenge Exercise

Build a generator that creates simple poems. Use rhyme patterns and random word selection.

🔑 Quiz Answers

Multiple choice answers: 1-A, 2-A, 3-A, 4-A, 5-A, 6-A, 7-A, 8-A, 9-A, 10-A, 11-A, 12-A, 13-A, 14-A, 15-A.

🎁 Key Takeaways

  • Generative AI creates new, original content.
  • Randomness is essential for creativity.
  • Combining pieces leads to new things.
  • Templates improve the quality of generation.
  • You can build your own generative systems!

🚀 Preparation for the Next Module

In Module Seven, we'll explore Machine Learning — how computers can learn from examples instead of being told exactly what to do. We'll build a simple learning system that improves over time. Get ready to teach your computer!


🎉 You've completed Module Six · You are now a Generative AI creator! 🎉

🏆 Get Certified

🔒

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (₦2,000 or 20,000 coins), and get a verified certificate with your name on it.

🎓 Sign Up to Get Certified
🛠️ Practice Tools
Hands-on simulators & labs - subscription required.
→
🎯 Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
→