From the course: Generative AI: Introduction to Diffusion Models for Text Generation
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Building a basic text diffusion model - Gemini Tutorial
From the course: Generative AI: Introduction to Diffusion Models for Text Generation
Building a basic text diffusion model
- [Instructor] We have discussed the fundamentals and process of diffusion models for text generation. Now let's build a basic text diffusion model. We'll write the code in Python using a Colab notebook. So go to colab.research.google.com. First, change the Runtime to GPU. We will now go ahead and input the necessary libraries, from transformers input AutoTokenizer and AutoModelForMaskedLM from diffusers import DDPMScheduler import torch and from torch import nn. The next step is for us to load the tokenizer and Masked Language Model. We are going to use BERT for encoding and decoding the text. So now let's do tokenizer, and let's accept the suggestion. We want bert-base-uncased and bert-base-uncased. And let's set the model to evaluation mode, text_encoder. Let's name this text_encoder because that is what the model is doing here for us, and text_encoder.eval(). So this is going to download bert-base-uncased to our workspace, and it's downloading that from the Transformers library…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.