>> G'day. I'm Lachie Evenson.
>> And I'm Francesc Campoy.
>> And this is the Open Source Show.
I'm Lachlan Evenson, and I'm a Program Manager at Azure.
>> I am Francesc Campoy,
the VP of Developer Relations at Source{d}.
>> Today, we're going to be talking about ML,
ML all the things.
>> Yes.
>> But specifically, I want to dig into
this new term that you coined ML on code.
Now, I know you're using machine
learning to analyze source code over at Source{d}.
Can you tell us a little bit about what you're doing there?
>> So, what we're trying to do is applying
techniques from like Natural Language Processing, NLP,
applying those techniques to
source code to predict whether the name is
good and provide better opportunities to make something better,
like that's your API, right?
It is really important. You need a human so far.
What if you didn't?
If you had a machine that was able to tell you, "Well,
actually you call this find,
but it should be contains." Or things like this.
>> So, I know a little about machine learning,
but I know enough to know that
this is going to need a lot of data.
You're going to need a lot of data to train these models so that
they can infer what and what is not going to work.
How are you making that easy at Source{d} to get these datasets?
>> So, first of all,
we need that data ourselves.
Right. Like what we're trying to do is,
we're trying to build applications
on the realm of ML on code,
machine learning on source code.
In order to get there,
we need to be able to create
those datasets that you use to train a model.
So, we create a bunch of different tools that allows you
to just get all of that code from many different repositories,
put it down together, clean it a little bit,
remove duplicates or all of these things that you always
need to do for basically any kind of data.
But for us the data is Git repositories.
Something we've done, which we're very proud of is,
we got all of GitHub in a Zip file.
Not really but like kind of.
So, every single repository,
with 50 stars or more on GitHub.
We download the whole thing, we clean the whole thing,
and we made it available as public dataset,
which is called Public Git Archive.
The whole idea is everything we do is open source.
>> Tell me one problem you've seen solved
yourself by using ML on code,
that's been a revelation to you,
and made you a better programmer.
>> In there's a lot of things like,
specifically related to naming or
sometimes like detecting bad copy-pasting,
which I thought like you cannot do this.
Apparently, like many people will get some line of code,
copy-paste it, and then when they check
like whether that pointer is null or not,
they forget to change it.
So, they're actually taking the same thing twice,
and the second one was never checked.
That happens in all my code, how sends all the time.
So, yeah like that, you can actually do
a detector for that that recognizes it quite easily.
But for me, my favorite one is one that I'm developing now,
that is an attention model.
So, I'm sure you know what attention models are for ML.
What we're doing is that attention model
for reviewers, for human reviewers.
>> So, when we do this ML on code thing,
what am I going to have from it as a developer?
>> You can imagine a little bit like the same idea,
all of the things we've been building on top
of natural language processing,
or image processing, or videos,
you have things like, "Well,
you can describe an image and you find it, right?
Or you get an image, and you find a description.
Imagine if you could do same thing for source code, right?
So, you could say, "Hey,
I'm looking for something that stores stuff",
and it just finds the code that this is like,
''The function you want to use.''
We're working on one really cool project
that still doesn't have a name.
So far we call it a Lookout,
that is a kinda attention model for code reviewers.
So, most of the things will be automated,
and you are responsible for the things are actually important.
>> Let's take a massive open
source community project like Kubernetes.
What would I expect the outcome to be if we do this ML on code
to actually have an effect on
maybe the code review process for a massive community,
with a massive amount of PR's like Kubernetes.
>> So, when you have a massive community
with a massive amount of PR's,
you also get one thing,
which is a tiny group of maintainers.
Right. That happens all the time.
So, the amount of maintenance you
have versus the amount of PR's you receive,
it's not even to the same scale.
So, what we're trying to do is,
call it assisted code review for now,
because it's not automated.
We'll allow the reviewer to have confidence on doing those code
reviews way faster by identifying many things that are wrong.
So, kind of like a Linter,
but like way smarter Linter.
All right.
On top of that, pointing to the pieces of codes that
are more interesting or unexpected.
We can call it. Right. Then, that's
where the human needs to look at it,
because we don't say that we're able
to just like review the code 100 percent correctly,
but if we do 90 percent, that's a really really good.
>> So, practically speaking,
how has ML on code actually affected you.
>> I think that the thing that really blew my mind
when I was learning about machine learning on source code was,
I have been learning machine learning for quite awhile,
and there was embeddings and things
like this that are pretty useful.
So, the traditional example of embedding is word2vec,
that basically allows you to do metaphors and things like this.
So, I was like, it allows you to know
that man is to woman as king is to queen, things this.
You can actually use that same knowledge with source code,
and we've done it, it's called code2vec, instead of word2vec.
It allows us to do things that are like analysis,
where you can have found like, "Well,
if open is to close as whatever read is to write,
then these two should be paired somehow,
and you can do higher level of analysis.
That blew my mind.
Like the fact that you are able to have
those concepts that are even hard for me to explain.
Just work for you,
while you're writing code. That's amazing. Yeah.
>> Oh fantastic. Well, you got me excited.
So how do I actually go and find more
about ML on code or even ML in general?
Do you have any places I can take a look?
>> Sourced.tech is where it's at.
But also, we have a GitHub repo that is super cool.
It is called - super long name,
awesome-machine-learning-on-source-code.
I think. The whole thing with dashes.
We'll have link down there.
Basically, what we've done is,
go through all the research that had been going on,
and just putting everything together.
So, people can go, read it,
they're also rated by whether they're
welcoming for beginners or not.
So, it's a great place to start learning.
>> Thanks for joining us today Francesc.
>> Thank you. It's just a pleasure to be here.
>> You can go to opensource.microsoft.com for more information,
and all the links will be in this video at the bottom.
Please subscribe for more great content,
and thanks for joining the Open Source show.
[MUSIC]