generative-ai-for-beginners
18 Lessons, Get Started Building with Generative AI 🔗 https://microsoft.github.io/generative-ai-for-beginners/
Top Related Projects
Examples and guides for using the OpenAI API
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
A minimal PyTorch re-implementation of the OpenAI GPT (Generative Pretrained Transformer) training
TensorFlow code and pre-trained models for BERT
Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
This repository contains implementations and illustrative code to accompany DeepMind publications
Quick Overview
The Microsoft/generative-ai-for-beginners repository is a collection of tutorials and resources for learning about generative AI models, such as GPT-3 and DALL-E. The repository aims to provide a beginner-friendly introduction to the world of generative AI and its applications.
Pros
- Comprehensive Tutorials: The repository offers a wide range of tutorials covering various aspects of generative AI, from model architecture to practical use cases.
- Beginner-Friendly: The content is designed to be accessible to those new to the field of generative AI, making it a great starting point for learners.
- Diverse Examples: The tutorials include examples across different domains, such as text generation, image creation, and code generation, showcasing the versatility of generative AI.
- Active Maintenance: The repository is actively maintained by the Microsoft team, ensuring that the content remains up-to-date and relevant.
Cons
- Limited Hands-on Exercises: While the tutorials provide a good theoretical foundation, there could be more hands-on exercises or interactive elements to reinforce the learning.
- Specific to Microsoft Tools: The repository primarily focuses on Microsoft-specific tools and services, which may limit its applicability for users who prefer other platforms or frameworks.
- Lack of Advanced Topics: The content is geared towards beginners, so it may not cover more advanced or specialized topics in generative AI.
- Potential Bias: As the repository is maintained by Microsoft, there may be a potential bias towards Microsoft's products and services.
Code Examples
Since this repository is primarily a collection of tutorials and resources, it does not contain a code library. However, the tutorials do provide code snippets and examples to illustrate the concepts being taught.
Getting Started
As this is not a code library, there are no specific getting started instructions. However, the repository provides a clear structure and navigation to help users find the relevant tutorials and resources they need to get started with generative AI.
Competitor Comparisons
Examples and guides for using the OpenAI API
Pros of openai-cookbook
- Focuses specifically on OpenAI's APIs and models, providing in-depth examples and best practices
- Regularly updated with new techniques and features as OpenAI releases them
- Includes a wide range of practical use cases and code snippets for various tasks
Cons of openai-cookbook
- Limited to OpenAI's ecosystem, not covering other AI platforms or general AI concepts
- May be more advanced for absolute beginners, assuming some prior knowledge
- Less structured as a comprehensive learning path compared to generative-ai-for-beginners
Code Comparison
openai-cookbook:
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello, how are you?"}]
)
generative-ai-for-beginners:
from transformers import pipeline
generator = pipeline('text-generation', model='gpt2')
response = generator("Hello, how are you?", max_length=30)
Both repositories provide valuable resources for learning about generative AI, with openai-cookbook offering more specialized content for OpenAI's tools, while generative-ai-for-beginners provides a broader introduction to generative AI concepts and techniques across multiple platforms.
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
Pros of transformers
- Comprehensive library with a wide range of pre-trained models and architectures
- Extensive documentation and community support
- Regularly updated with state-of-the-art models and techniques
Cons of transformers
- Steeper learning curve for beginners
- Requires more in-depth understanding of machine learning concepts
- Less focused on step-by-step tutorials for newcomers
Code comparison
transformers:
from transformers import pipeline
classifier = pipeline("sentiment-analysis")
result = classifier("I love this product!")[0]
print(f"Label: {result['label']}, Score: {result['score']:.4f}")
generative-ai-for-beginners:
import openai
openai.api_key = "your-api-key"
response = openai.Completion.create(engine="text-davinci-002", prompt="Translate 'Hello' to French:")
print(response.choices[0].text.strip())
The transformers example demonstrates using a pre-trained model for sentiment analysis, while the generative-ai-for-beginners example shows how to use OpenAI's API for text generation. The transformers code is more focused on utilizing specific models, while generative-ai-for-beginners provides a higher-level interface for AI tasks.
A minimal PyTorch re-implementation of the OpenAI GPT (Generative Pretrained Transformer) training
Pros of minGPT
- Focused on a single, lightweight implementation of GPT
- Excellent for learning the core concepts of transformer-based language models
- Clean, well-commented code that's easy to understand and modify
Cons of minGPT
- Limited in scope compared to the broader AI curriculum in generative-ai-for-beginners
- Less comprehensive documentation and learning resources
- Lacks practical applications and real-world use cases
Code Comparison
minGPT:
class GPT(nn.Module):
def __init__(self, config):
super().__init__()
self.tok_emb = nn.Embedding(config.vocab_size, config.n_embd)
self.pos_emb = nn.Parameter(torch.zeros(1, config.block_size, config.n_embd))
self.drop = nn.Dropout(config.embd_pdrop)
self.blocks = nn.Sequential(*[Block(config) for _ in range(config.n_layer)])
self.ln_f = nn.LayerNorm(config.n_embd)
self.head = nn.Linear(config.n_embd, config.vocab_size, bias=False)
generative-ai-for-beginners:
class SimpleTransformer(nn.Module):
def __init__(self, vocab_size, d_model, nhead, num_encoder_layers):
super(SimpleTransformer, self).__init__()
self.embedding = nn.Embedding(vocab_size, d_model)
self.transformer = nn.Transformer(d_model, nhead, num_encoder_layers)
self.fc = nn.Linear(d_model, vocab_size)
TensorFlow code and pre-trained models for BERT
Pros of BERT
- Established and widely adopted in NLP research and applications
- Extensive documentation and academic papers available
- Proven performance on various language understanding tasks
Cons of BERT
- Focused primarily on natural language processing tasks
- Steeper learning curve for beginners
- Less emphasis on practical implementation for non-researchers
Code Comparison
BERT (PyTorch implementation):
from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertModel.from_pretrained('bert-base-uncased')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
Generative AI for Beginners (example using OpenAI API):
import openai
openai.api_key = "your-api-key"
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Translate the following English text to French: 'Hello, how are you?'"
)
The BERT repository focuses on a specific NLP model, while Generative AI for Beginners covers a broader range of generative AI topics and practical applications. BERT is more suitable for researchers and advanced practitioners, whereas Generative AI for Beginners is designed for newcomers to the field, offering a more accessible entry point to various generative AI concepts and technologies.
Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
Pros of fairseq
- More comprehensive and feature-rich for advanced NLP tasks
- Supports a wider range of models and architectures
- Better suited for research and production-level applications
Cons of fairseq
- Steeper learning curve for beginners
- Less focus on educational content and tutorials
- Requires more in-depth knowledge of NLP concepts
Code Comparison
fairseq:
from fairseq.models.transformer import TransformerModel
en2de = TransformerModel.from_pretrained(
'/path/to/model',
checkpoint_file='model.pt',
data_name_or_path='data-bin/wmt14_en_de'
)
generative-ai-for-beginners:
from transformers import pipeline
generator = pipeline('text-generation', model='gpt2')
generated_text = generator("Hello, I'm a language model,", max_length=30)
The fairseq example demonstrates loading a pre-trained Transformer model for translation, while the generative-ai-for-beginners example shows a simpler approach using Hugging Face's transformers library for text generation. This highlights fairseq's more advanced capabilities and generative-ai-for-beginners' focus on accessibility for beginners.
This repository contains implementations and illustrative code to accompany DeepMind publications
Pros of deepmind-research
- Covers a wide range of advanced AI research topics
- Provides implementations of cutting-edge algorithms and models
- Offers in-depth technical content for experienced researchers
Cons of deepmind-research
- Less beginner-friendly, assumes advanced knowledge
- Lacks structured learning path or tutorials
- May not focus specifically on generative AI techniques
Code Comparison
deepmind-research (from alphafold/model/folding.py):
def apply_to_batch(batch, f):
return jax.vmap(f)(batch)
def squared_difference(x, y):
return jnp.square(x - y)
generative-ai-for-beginners (from 01-introduction-to-genai/notebook.ipynb):
import openai
openai.api_key = "YOUR_API_KEY"
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Translate the following English text to French: 'Hello, how are you?'"
)
The deepmind-research code snippet shows low-level mathematical operations, while the generative-ai-for-beginners example demonstrates a simple API call to generate text, reflecting the different focus and complexity levels of the two repositories.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
18 Lessons teaching everything you need to know to start building Generative AI applications
Generative AI for Beginners (Version 2) - A Course
Learn the fundamentals of building Generative AI applications with our 18-lesson comprehensive course by Microsoft Cloud Advocates.
ð± Getting Started
This course has 18 lessons. Each lesson covers its own topic so start wherever you like!
Lessons are labeled either "Learn" lessons explaining a Generative AI concept or "Build" lessons that explain a concept and code examples in both Python and TypeScript when possible.
Each lesson also includes a "Keep Learning" section with additional learning tools.
What You Need
- Access to the Azure OpenAI Service OR OpenAI API OR GitHub Marketplace Model Catalog - Only required to complete coding lessons
- Basic knowledge of Python or TypeScript is helpful - *For absolute beginners check out these Python and TypeScript courses.
- A GitHub account to fork this entire repo to your own GitHub account
We have created a Course Setup lesson to help you with setting up your development environment.
Don't forget to star (ð) this repo to find it easier later.
ð§ Ready to Deploy?
If you are looking for more advanced code samples, check out our collection of Generative AI Code Samples in both Python and TypeScript.
ð£ï¸ Meet Other Learners, Get Support
Join our official AI Discord server to meet and network with other learners taking this course and get support.
ð Building a Startup?
Sign up for Microsoft for Startups Founders Hub to receive free OpenAI credits and up to $150k towards Azure credits to access OpenAI models through Azure OpenAI Services.
ð Want to help?
Do you have suggestions or found spelling or code errors? Raise an issue or Create a pull request
ð Each lesson includes:
- A short video introduction to the topic
- A written lesson located in the README
- Python and TypeScript code samples supporting Azure OpenAI and OpenAI API
- Links to extra resources to continue your learning
ðï¸ Lessons
# | Lesson Link | Description | Video | Extra Learning |
---|---|---|---|---|
00 | Course Setup | Learn: How to Setup Your Development Environment | Coming Soon | Learn More |
01 | Introduction to Generative AI and LLMs | Learn: Understanding what Generative AI is and how Large Language Models (LLMs) work. | Video | Learn More |
02 | Exploring and comparing different LLMs | Learn: How to select the right model for your use case | Video | Learn More |
03 | Using Generative AI Responsibly | Learn: How to build Generative AI Applications responsibly | Video | Learn More |
04 | Understanding Prompt Engineering Fundamentals | Learn: Hands-on Prompt Engineering Best Practices | Video | Learn More |
05 | Creating Advanced Prompts | Learn: How to apply prompt engineering techniques that improve the outcome of your prompts. | Video | Learn More |
06 | Building Text Generation Applications | Build: A text generation app using Azure OpenAI / OpenAI API | Video | Learn More |
07 | Building Chat Applications | Build: Techniques for efficiently building and integrating chat applications. | Video | Learn More |
08 | Building Search Apps Vector Databases | Build: A search application that uses Embeddings to search for data. | Video | Learn More |
09 | Building Image Generation Applications | Build: A image generation application | Video | Learn More |
10 | Building Low Code AI Applications | Build: A Generative AI application using Low Code tools | Video | Learn More |
11 | Integrating External Applications with Function Calling | Build: What is function calling and its use cases for applications | Video | Learn More |
12 | Designing UX for AI Applications | Learn: How to apply UX design principles when developing Generative AI Applications | Video | Learn More |
13 | Securing Your Generative AI Applications | Learn: The threats and risks to AI systems and methods to secure these systems. | Video | Learn More |
14 | The Generative AI Application Lifecycle | Learn: The tools and metrics to manage the LLM Lifecycle and LLMOps | Video | Learn More |
15 | Retrieval Augmented Generation (RAG) and Vector Databases | Build: An application using a RAG Framework to retrieve embeddings from a Vector Databases | Video | Learn More |
16 | Open Source Models and Hugging Face | Build: An application using open source models available on Hugging Face | Video | Learn More |
17 | AI Agents | Build: An application using an AI Agent Framework | Video | Learn More |
18 | Fine-Tuning LLMs | Learn: The what, why and how of fine-tuning LLMs | Video | Learn More |
ð Special thanks
Special thanks to John Aziz for creating all of the GitHub Actions and workflows
ð Other Courses
Our team produces other courses! Check out:
Top Related Projects
Examples and guides for using the OpenAI API
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
A minimal PyTorch re-implementation of the OpenAI GPT (Generative Pretrained Transformer) training
TensorFlow code and pre-trained models for BERT
Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
This repository contains implementations and illustrative code to accompany DeepMind publications
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot