Hello world it's Siraj and AI in marketing.
That's the topic for today's video
I want to start off this video with a demo and what this is is an AI Writer.
what it does is it takes in as input a keyword in my case,
I'll say it's gonna be wine, okay
So I want to write an article about red wine I'm gonna send it to my email address
It's gonna use an AI to then generate an article based on that it might take a few minutes
It might take a few hours
But luckily I already have the output right here for us what it does is it because it's gonna generate text
Based on that keyword and it's gonna use its sources are going to be the internet so it's going to
Search the internet for other related articles on the topic
It's gonna take all that text and compile it into one giant
Text data set, it's gonna feed that into its AI model which is likely an LS TM neural network.
Don't worry if you don't understand that, I'll talk about that later in the video
And then it's going to output an article that we see here. This could be a very compressed article low compression
It could be a very medium or a high compression article and they can get pretty good, okay
Pretty damn good, so good in fact that it's very likely that you've already read an article or seen some kind of data
That was created entirely by an AI and you didn't even know it
Very famous brands from Fox to Yahoo to The Associated Press all use AI to generate content
And that's just one of the ways that AI can be used in both marketing advertising and the entire
marketing funnel the pipeline so in this video
I'm going to talk about ways we can do that and at the very end we're going to look at some code for different
Architectures that we can use to do this ok, so let's start off with
The ways that AI can be used in marketing, right so one way is through audience
targeting right so if you have some startup a company a brand you have an audience of
Customers right and if you have some new product you want to target the specific
subset of your customers they're going to be most
willing to convert into sales
You don't want to waste your time your energy your money your resources on customers who won't convert right and so
How do you target those exact customers that would be most likely to convert?
This is a perfect use case for AI and we'll talk about that in a bit
The second part is content creation right if you've already
Targeted those users that are most likely to convert to sales for your product
How are then you? How are you supposed to generate content?
That would be best suited for them the ideal, the easy way is to get a human to do it
But could you get an AI to do it is the question and the answer of course, is yes
And we'll talk about that as well. Now real time optimization is another strategy using AI
Let's say you have some marketing campaign
let's say it's an email campaign, right and you're constantly setting ads out to your users to see how they feel about the product and
You're getting feedback from them. Whether they like it or not
how do you optimize that content or route in real-time so that you're learning from what your users like and what they don't like and
This has been happening like I said for a very very long time and we're gonna learn how in this video
So some b2b marketers were asked. What are these metrics that indicate
successful return on AI investments and across the board that the number one way with
59% of respondents saying this was that it gives them better close rates for sales
so sales equates to revenue and revenue is the lifeblood of any company right,
you can't have a company if you don't have revenue.
Okay, so if I didn't have revenue. I couldn't hire people. I couldn't make videos for you
I couldn't live I've got revenue, okay
So and I am using AI to help target my content
So I myself in and mitting that I'm using AI to help target, and you know make sure my content is as
Targeted as possible
And they say in the end if you have some product that you're selling it's going to then help close the rates for sales
Right for me for me. That was my decentralized applications course
That was my only paid offering up to this point, and I targeted it very well, and it resulted in some good sales
We're just gonna help me grow the business later on
So AI can be used for that as well
So let's talk about some startups in the space that are helping to move this field forward right so
Appier is one example. This is a Taiwan based company and
What they do is they predict what audience members are likely to do next right so if you have some products right you're some ecommerce
Website and you're selling shoes, and you're selling all sorts of clothing
Let's say if a customer buys shoes, then it is likely that the customer won't buy another pair of shoes
But it is likely that they'll buy a pair of socks to complement those shoes
How can you predict what the customer is going to do next and what they do is they provide AI as a service to companies?
To allow them to predict, what customers are going to do next?
Another example is drawbridge, right?
so
users switch devices all the time right so they can be on mobile they can be on a desktop they can be on a
ps4 and
ideally we can talk we can target the type of
Content to the specific device that they're on at the time, and so that's what drawbridge does it predicts
What times that a user is going to be on a specific platform?
And then it allows a brand to create content base on that platform
another example is insidesales.com
Right so if you have a lot of prospective sales
You can't just target all of them because you're gonna be wasting time and energy and money on targeting this giant segment of users
When it turns out that the the customers that are most likely to convert are probably only 20%
And that's what Inside Sales does is it helps you find that 20%?
of your customer base that are gonna be the most likely to convert to the sales for your product that you're pushing
and there's one more. I want to talk about it's called Persado and what they do is they will
Help you create content
It will help you find the phrases and the words that's going to drive the greatest action for your audience that convert into sales
So you could say you know a text message in this way
But if you say it in this way you reword it a little bit
It's going to increase sales by this much
And this is something that we humans try to do we use our intuition right so you know Don Draper from Mad Men
He comes into the boardroom. He's like this is gonna work, and then it works, and it's beautiful
That's not how it works anymore if you don't have a database decision. What are you doing right so?
Really, good marketers and really good. You know sales people an advertiser, not sales advertiser's tells people as well
But not in this case use AI to make decisions. Okay. It's not just about intuition alone. You've got to use it
You've got a base your decision on the data. If you don't got the data. You don't got sh...
anything right so shit so anyway, so
Let's start with audience targeting right so how do we target some segment of the audience?
That is gonna be most likely to convert for a given ad and then focus all of our time and energy on that segment
So we could think about this as a recommender system problem right so a bunch of sites use recommender systems Amazon Netflix
You know everybody uses it these days and one very common way to build recommender systems is to use matrix factorization
Okay, so here's how it works if you have some product and in this case we're talking about marketing so our product is going to
be a an ad right so you have a bunch of ads you've tried out and the users rated all of those ads on a
Scale of one to ten and what this turns out is you have a giant
matrix of
users and
Ads and their ratings for all of those ads so it turns out that those users aren't going to rate all of those ads
They're only going to rate some of them
So what we do for matrix mean factorization is we decompose this giant matrix into two different matrices
One is going to be how a user's rates certain features of an ad the other is going to be how?
Certain features are rated by users for a specific
ad
so two different
matrices
the process of decomposing this matrix into a two different feature matrices is a
Type of machine learning using neural networks or SVD is but I've talked about that before
If you search Siraj recommender system on youtube you'll find a bunch of videos there, but I want to give you a high-level
Explanation here once. We've decomposed that giant matrix into these two smaller matrices
We then use the dot product to combine them again in such a way that all of those blank spaces are filled right so what?
We're trying to do is we're trying to find those blank spaces
If a user has rated a certain ad this way and another ad this way
How would they rate this ad and so this is a prediction, this is what the AI is doing using me factorization?
And so a popular library to do this has been LightFM
I've made a video on that before where it takes it generates user and item representations by functioning as a factorization machines and
Learning the linear embeddings for each feature it then takes a dot products of each of these two representation vector and gets a score
But with deep neural networks
We can improve on this by creating more meaningful
Representations right deep neural networks outperform all other machine learning models when it comes to learning
features, ok so when it comes to learning features deep neural nets blow everything else out of the water if we have enough data and
computing power and so TensorRec is a
Library that has a lot of developer activity and I highly recommend it built on top of tensor flow
That does this, it allows us to use tensor flow to build deep neural networks for
Recommendation engines this could be to recommend the optimal ads for your users to recommend products to recommend whatever it is
Now ideally if you're a brand if you're a company you've got some data
Set that shows
How users feel about certain ads you've done in the past and based on that you can create new ads that a certain user would
be likely to convert on so you have to make sure you have that data
If you don't have that data your startup you want to build a service for brands than just Google data set
For data set ad campaign and then test it out from there
But the idea is that going beyond matrix factorization we can build neural networks to do this
Right and so the process is very similar in that we are learning to matrices
And then we're performing a dot product between those two matrices
To create predicted scores for a given user and then we just read off of that matrix to predict
what a certain user would score a particular ad and then if we have some threshold like if a user scores would score above an
Eight out of ten for this ad then deploy this ad to them if it's under that then deployed this ad to them okay
So it's kind of like that so there are four steps in this process
The first one is to transform our input data into feature tensors for easy embedding right we have some input data
That's a giant matrix, and then we use Pandas say to then convert that into a data frame object
And once we do that we convert them to feature tensors
using an algorithm like Word 2 Vec which we could use in one line of code or
Several other ones and then once we have that we transform the user item feature tensors into user item representations
we transform that pair into a prediction and then transform that prediction and truth value into a loss
Value for a loss function minimize that using gradient descent until we have reached a minimum minimal loss function value
And then we can use that model to predict
what a certain user would like so here is a very simple programmatic example of us using TensorRec to
Recommend users a specific type of data
This could be ads it could be anything right so we build the model in a single line
That's all we imported. We generate some dummy data. We fit them up model on that data. We predict
What the scores would be would be based on the given data, and then we use a percentage recall as a
Evaluation metric to see how good it's doing on testing data set that's it. TensorRec check it out
Now, once we have targeted a specific subset of our users that we know exactly
We've automated that part of the pipeline now. We can use humans to create content that is perfectly well suited for them or
We could automate the entire pipeline where it's not just
Us targeting the users using a I will generate content for those users using AI so the entire process
Is automated right, so this video is content this video could be automated
Who knows if I'm real or not right you have no idea unless you met me in real life
But even then who knows maybe I was a hologram anyway content creation right so LSTM
Networks are the way to do this for text, okay, so
If you search LSTM Network Siraj you'll find a great video on me explaining how they work in depth
But I'll give you a high-level overview
right now so
Recurrent networks are really good at predicting sequences of of text right so normal feed-forward networks, right?
Normal feed-forward networks are not about predicting sequences
They're about predicting what an output would be for a given input it learns the mapping
But when it comes to a sequence what happened before?
Matters to what happens now what the words that you had previously like I like recording videos
About AI because I love you know maybe it's tensorflow
But predict what that word is you got to know about the word AI you got to know about the word video
You can't just know you know
Use the previous word you got to use the whole sequence right so what we're current at works, too
Is that every time step, It's not just the next data point. That's fed into the network. It's also the previous hidden layer
That's learned over time. That's fed into the time step and so at every time step
Not just a new data point, but the previous hidden layer
That was learned is fed into the network so it's learning
not just the next data point
But it's learning based on what it already learned before if that makes sense and that's why it's called a recurrent Network
Because there is this recurrence or feedback loop. That's happening and what's there's a problem though in that
for recurrent networks if the sequence is
Too long then there's gonna be a problem called the vanishing gradient problem
So during optimization back propagation we use the gradient
Which is the difference between the real output and the predicted output we use the gradient to then update all of those layers beforehand?
but what happens in recurrent networks is that the gradient gets smaller and smaller and smaller the further back we go in the network and
So how do we preserve that gradient so all the layers are updated accordingly?
Well, we need to trap that gradient somehow into what are called long short-term memory cell,
cells that consist of gates values and these gates
Trap the gradients in such a way that the vanishing gradient goes away
And this allows a network to remember very very very long term sequences of data like an entire
essay right so they lets us then write an entire essay or article and
So you might be thinking how do I build this very complex thing and the answer is Keras, Keras is a machine learning library,
Built on top of Tensorflow that lets you build very complex
Deep neural networks in just a few lines of code and AI marketers can use this to automatically generate
Content best suited for a particular subset of their audience so the idea is that if you have images or video
Then you want to use generative adversarial networks that generates content if you want to generate audio you use wavenet
And if you wanted used if you want to generate text, you use
LSTM current networks like I'm talking about here and remember. I have videos for all of these models
Just search my name and the model
So here's a very simple example of us using Keras in
Under a hundred lines of code to generate an essay in the style of Neitzche
So the text is Neitzche writing and then what it does is it takes that input data. It's formats that data
It feeds it into a model built in Keras where every line of code
Corresponds to a single layer in the network, so it's very readable code, and it's only three layers long
We optimize it using rmsprop
Which is a type of gradient descent search which activation function should I use Siraj on
Youtube to find a great video on all the differences between all of the different activation functions out there
You know I also have a video on which optimization function should you use as well?
but anyway once we do that we minimize it using a loss function and
That's it and then it what it's going to do is it's going to predict every word
that that neech a would have said based on what it's learned in the past and
So we can use this for the entire pipeline whether we're targeting users
And then once we've targeted them generating content for them and we can do this for the entire marketing pipeline
there's a huge huge space for startups to come into this space and
Create services for big brands for consumers to help them optimize to save time to save money to save resources
Using the latest technologies and look even though I said that there are some startups out there that do this currently
There's a giant massive opportunity for new players in this space, and there's a huge need for it as well
So I hope you found this video useful
Please subscribe for more programming videos and for now I've got a B nai so thanks for watching