[MUSIC PLAYING]
BEN MORSS: Hey there.
I'm Ben Morss.
I'm a developer advocate at Google,
where I work to make the web better for users and developers
alike.
People should be able to engage in authentic discussions
on the web without fear.
That's why the web was created.
Toxic comments and harassment shouldn't
silence people's voices, and yet unfortunately, this
can be a problem.
That's why I was so excited to discover Perspective.
Perspective is a free API that helps
you host better conversations online
by limiting toxic discourse.
I think it's good for the web, and I
want to help you get started with it.
So first, we'll talk about what Perspective API is,
and then I'll show you how to set it up.
So what is Perspective API?
Perspective was created by the Conversation AI initiative,
which is a collaboration between Jigsaw
and the Counter-Abuse Technology team at Google.
Conversation AI uses machine learning
to fight online toxicity and harassment.
Perspective uses machine learning models
to analyze online comments, guess
the impact they might have on a conversation,
and assign each a score.
It can help you keep conversations
civil on your site so you feel safe to share
your voice with the world.
The API works with languages like English, Spanish, French,
German, Portuguese, and Italian.
Perspective scores comments on a set of attributes.
These attributes determine whether a comment
might be toxic, threatening, insulting, or simply off-topic.
Toxicity is the most popular attribute.
The site defined it as a rude, disrespectful, or unreasonable
comment that is likely to make you leave a discussion.
Here's an example-- someone reads an article on your site
and makes the comment "Shut up.
You're an idiot."
Before your site publishes this comment,
it gets fed through the Perspective API.
Perspective runs it through its models and scores
it on attributes like toxicity, insults, and profanity,
returning some pretty high scores.
Toxicity is 0.99.
Insults is 1.0, the maximum.
This is a comment you're likely to reject.
Now, you're probably wondering whether Perspective
is right for you.
Here are some common use cases.
Many sites use Perspective to flag potentially harmful
comments so a moderator can check them
before they get posted.
For example, Perspective powers the tool
used by moderators at the "New York Times."
Coral by Vox Media uses Perspective in the same way
to curb online harassment in their comment sections.
And Perspective is also available in plugins
for Discourse and for WordPress.
You can also make your own Discord bot,
like Deb Markowitz did in this video.
Beyond moderation, you can also help commenters in real time
by warning them that a comment might violate your community
guidelines, or could be perceived as toxic.
Here, when I type "You're dumb," the site
warns me that this might well be toxic,
and recommends that I edit the comment.
When I change it to "You're nice," it's non-toxic.
Finally, you can let readers filter comment sections to hide
potentially harmful comments.
Perspective powers a Chrome extension
called Tune, which helps people see fewer toxic comments
across the web.
These are the most common use cases,
but people use the API in all kinds of creative ways.
For example, Audiobahn uses speech-to-text to transcribe
audio and check the transcription
for toxic contents.
While Perspective is pretty smart,
you're not going to want to use it
for fully automated moderation.
Any machine learning models can make mistakes that a human
wouldn't.
Instead, it's better to use Perspective to flag comments
for a human to review.
Think of it as a time saver.
For more information about how to use or not use Perspective,
check out the best practices and risks on the site.
Now, let's get started.
I'll walk you through the steps you'll
need to get Perspective API up and running.
Perspective runs on Google Cloud.
To use it, you need a Google account,
and you'll need to set up a Cloud project.
Google Cloud is a set of cloud computing services
that runs on Google's infrastructure.
It's a good place to host a reliable API.
To get started, make sure you've logged in with
or created a Google account, then go to the Cloud Console
page at console.cloud.google.com.
To use a Google Cloud service, you
need to enable it within a Google Cloud project.
You can choose or create a project with the dropdown
on top of the page, right near the words "Google Cloud
Platform."
If you already got a project, this dropdown
will display the project's name.
If you haven't, the dropdown will say Select a project.
In either case, click this dropdown.
You'll then see a popup showing your existing projects,
if you have any, plus a button that says New Project.
If you want to use an existing project, do that,
or to create a new project, click New Project in the popup.
Give the project whatever name you like.
Make note of the project ID that appears under the name,
as you'll need this to identify your project later on.
Now click the Create button, and there it is--
our brand new Google Cloud project.
Click View, and we're in our project.
Now that we have our project set up in Google Cloud,
we need to request access to the API.
We'll do this on the Perspective API site.
So let's fill out the form, and then we wait.
Within an hour, but probably a lot less,
you should get a confirmation email.
Look, here's my confirmation now.
Now we can enable the API.
There's two ways to do this.
Way number one-- click on the link in the email.
That'll lead you back to the API's page in the Google
Developers site.
Visit the Perspective API Overview page.
Click Enable.
Choose your project, and you're done.
Way number two-- if you like using the command line
and you've already installed the Google Cloud SDK,
type gcloud services enable commentanalyzer.googleapis.com.
Finally, we need to generate an API key to authenticate
our requests.
This key is our own private code, unique to us--
a secret token for our cloud API.
If you're already on the Credentials page, as we are,
click API Key.
On the next page, choose a name for your API key.
For security, it's best to set some application restrictions
in the interface.
Click Create, and you're done.
You could also go to the Google API Credentials page
and click Create Credentials.
Then click Choose API Key in the Credentials dropdown.
Of course, if you make requests from client-side JavaScript
on your website, people will be able to discover your API key.
So it's best to store your API key safely
on your server and proxy requests
through your own web service.
Your API key should begin working in a few minutes,
although it could take up to an hour.
Once it's ready, you can copy your API key and get to work.
To learn how to use the API itself,
go to the Perspective Developers site.
If you want to get started quickly,
the Methods page describes how to use
the two methods, AnalyzeComment and SuggestCommentScore.
By default, the API has a quota limit
of about 60 queries per 60 seconds.
This is plenty for testing and for small publishers like me--
I'm lucky if I get 60 comments in a year.
If you need more quota, request it on the Developers site.
When you do your first test, just
send one comment to be on the safe side.
As you use the API, don't batch up comments into big groups
to make your quota limits.
It may even be safest to send each comment
with a small delay, like this.
That's it.
If you missed anything, go to that Developers site,
where you'll find the Get Started instructions,
sample use cases, and you can contribute feedback
to help improve the machine learning models.
If you're concerned about data and privacy,
check out the site to see how your data is kept secure.
Thanks for listening.
We're excited to see how you use Perspective.
[MUSIC PLAYING]