0% found this document useful (0 votes)
57 views

Generative AI Tutorial

The document is a comprehensive tutorial on Applied Generative AI, covering Python fundamentals, generative AI concepts, and advanced applications including LLMs and image generation. It includes practical examples and code snippets for using tools like ChatGPT, LangChain, and Stable Diffusion. The tutorial also addresses AI ethics and governance challenges, culminating in a capstone project for skill application.

Uploaded by

Jhon Kevin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Generative AI Tutorial

The document is a comprehensive tutorial on Applied Generative AI, covering Python fundamentals, generative AI concepts, and advanced applications including LLMs and image generation. It includes practical examples and code snippets for using tools like ChatGPT, LangChain, and Stable Diffusion. The tutorial also addresses AI ethics and governance challenges, culminating in a capstone project for skill application.

Uploaded by

Jhon Kevin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Applied Generative AI Specialization - Comprehensive Tutorial

# 1. Python Fundamentals for Generative AI

## Python and IDE Installation


- Install Python from the official website: python.org

- Recommended IDEs: Jupyter Notebook, VS Code, PyCharm

## Jupyter Notebook Usage


- Launch Jupyter Notebook using:

jupyter notebook

- Create and execute code cells

- Use Markdown for documentation

## Core Python Concepts

### Identifiers, Indentation, and Comments


- Variables must begin with a letter or underscore

- Use `#` for comments

- Proper indentation is crucial in Python

### Example:
```python

# This is a comment
my_variable = 10 # Assigning a value

print(my_variable) # Printing output

```
# 2. Essentials of Generative AI, Prompt Engineering & ChatGPT

## Understanding Generative AI
- How Large Language Models (LLMs) generate content

- Use cases in business, healthcare, and finance

### Example: Using ChatGPT API


```python

import openai

response = openai.ChatCompletion.create(

model="gpt-4",

messages=[{"role": "user", "content": "What is Generative AI?"}]

print(response["choices"][0]["message"]["content"])

```

# 3. Advanced Generative AI - Models and Architectures

## Large Language Model (LLM) Architecture


- Understanding transformers

- Key components: self-attention, embeddings, and multi-head attention

### Example: Loading GPT Model


```python

from transformers import GPT2LMHeadModel, GPT2Tokenizer


model = GPT2LMHeadModel.from_pretrained("gpt2")

tokenizer = GPT2Tokenizer.from_pretrained("gpt2")

input_text = "Once upon a time"

input_ids = tokenizer.encode(input_text, return_tensors="pt")

output = model.generate(input_ids, max_length=50)

print(tokenizer.decode(output[0]))

```

# 4. Advanced Generative AI - Building LLM Applications

## LangChain and Workflow Design


- Using LangChain for LLM-powered applications

### Example: Creating a Simple Chatbot with LangChain


```python

from langchain.llms import OpenAI

llm = OpenAI(model_name="text-davinci-003")

response = llm.predict("What is AI?")

print(response)

```

# 5. Advanced Generative AI - Image Generation

## Stable Diffusion
- How diffusion models create realistic images
- Experiment with Stable Diffusion

### Example: Generating Images with Stable Diffusion


```python

from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")

image = pipe("A futuristic cityscape").images[0]

image.show()

```

# 6. Generative AI Governance

## AI Ethics & Governance Challenges


- Handling AI bias, misinformation, and hallucinations

- Legal and regulatory considerations

# 7. Capstone Project
- Apply your skills to build a working AI application

- Develop a portfolio-worthy project

# Electives: Microsoft Azure AI Fundamentals

## Deploying GPT Model on Azure


```python

import azure.openai as azure_ai

client = azure_ai.AzureOpenAIClient("your-api-key")

response = client.Completions.create(
engine="text-davinci-003",

prompt="Write an AI-generated poem",

max_tokens=50

print(response.choices[0].text)

```

## Conclusion
This tutorial provides a structured learning roadmap to master Generative AI and build real-world applicatio

You might also like