good afternoon those of you who are on
conference time that's melbourne time
australian eastern time and good evening
to those of you from california which is
the land when comes back on nathan known
in the industry as a player slash coach
with core expertise in data science
natural language processing and cloud
computing
about 40 years of tech industry
experience ranging from bell labs to
early stage startups
he has too many accolades to list
completely but some highlights he's the
lead committer of pytech's rank and kg
lab
which he will be talking about today and
formerly he was the director of
community evangelism for databricks and
apache spark if you want to know more
about him you can find out at derwin dot
ai slash paco
this talk is about how graphs are
amazing
there's the emerging graph ml work in
deep learning
there's the rise of knowledge graphs in
industry powerful graph algorithms huge
graph databases interactive graph
visualizations and so on
but it seems like a bit daunting pack of
stock is about how you don't really need
to have like special platforms and very
specialized knowledge you can start on
graph based technologies using just
python kglab and many of the other
python technologies that you already
know and love
please give a virtual hand of applause
and show your love to paco nathan and
graph data science
thank you very kindly thank you javi i
appreciate it uh and i'm grateful to get
to present here today um the talk the
slides are online i probably err on the
side of having way too many links in my
slide decks so uh there's the link here
and it should be in the chat as well and
i'll be on chat afterwards uh but if you
want to check through the slides there's
a lot of links after primary sources and
repos and articles and whatnot
so this is about graph data science and
just briefly about me uh yeah i've been
doing this for a few years but uh you
know i had some interest in neural
networks a long long time ago i got
involved in machine learning back in the
80s
and then nobody cared so i did a lot of
work in network engineering uh i ended
up being a guinea pig for something new
that was getting launched that i found
out later was named aws
and i ended up
leading one of the first large hadoop
instances
ever running in the cloud
and then from there into spark and
working with jupiter and ray and some
other projects
so this talk is about
really about understanding how to work
with graphs because there's so much
open source that's available so i want
to lead you through a brief story
imagine here uh this is a village let's
say it's a medieval village somewhere in
the black forest
and it's it's beautiful of course
and if you want to look at it in terms
of a map there's you know a road running
through and a stream running by and and
some different cottages and businesses
and whatnot
so let's talk about who's there in the
village
we've got pat pat runs the pub
pat has a couple of friends hannah and
thomas
now hannah works the fields and produces
grain
and she's got a friend aiden
and then thomas
raises poultry produces eggs
and thomas has a friend named brenda
now if you go back to iden aiden works
the mill and takes the grain from hannah
and produces flour
ident has a friend chris
and then brenda
she takes the grain from hannah and she
works the brewery produces beer
and she's got a friend named kim
and then there's chris chris runs the
bakery produces bread
now chris is taking
products from iden the flour and eggs
from thomas
and selling the bread back to pat at the
pub so they've got some nice bakery
goods
and then kim runs a recycler she buys
organic wastes from
thomas and oh chris and all and and then
she produces fertilizer that goes back
hanna buys that to use in the fields
and the point i want to make is that
with seven nodes here seven people in a
small medieval village we already have a
definition of what we would call a
circular economy uh we have something
that's sustainable and we have this
producer consumer view of what they're
doing what their activities are we have
a friend graph
uh we also have this
product graph if you will the flows of
products going through this workflow
and so this is a graph and this is the
way you think about how a complex
intertwined
system operates
now if we were to take that very same
data and put it into
a
relational database
and do the proper things in terms of
normalization it would look most likely
very much like this
um in some ways you have to take
and dismember all those relationships
and connections that you had and put
them into tables and you know you can
kind of see this here can you understand
who's really
producing the most important goods by
looking at these numbers
that's hard
however
if you come back into a network view you
might get a better better
sense of it
uh so
when you do have complex contexts
network views
bring the data and the connections
within the data closer to the people who
can make sense of it
and this is predicated on a few things
one is acknowledging the complexity of
the kind of use case you're working with
the context
and then being able to understand can we
identify emergent patterns within these
connections and from there be able to
make informed decisions
so think about patterns whenever you're
working with graphs think about patterns
or vice versa when you're seeing complex
patterns perhaps graphs are indicated
now hannah is relatively new in this
village but she'd like to expand her
business so one question naturally she
could ask is she's noticed that one of
her customers brenda buys a lot of grain
who are the other villagers who might be
similar to brenda can we do some
lookalike analysis
and if you go across the graph and do
some some analysis there you find that
well chris also sells product to pad and
he sells waste to kim
maybe the bakery could make good use of
unmilled grain maybe they could produce
malt or something
hannah is also interested in sponsoring
a co-marketing campaign here in her
medieval village to help drive demand so
helping out her customers to to reach
more of their customers
who are the customers of hannah's grain
business
as it turns out chris pat and kim are
each a minimum of two hops away and we
can see this from graph analysis
now uh just suppose you had some tech
millionaire some elon musk type who uses
time travel to relocate back to a
medieval village in the black forest
like you do
which businesses are the most
influential if they were to you know
perhaps try to have an acquisition
target
um it turns out that if you look at this
this medieval village and the business
going on there hannah and chris are the
ones that they're really the most
central figures
and in fact if you run graph algorithms
on this exact data you find out that
hana leads the ranking in terms of using
it between a centrality measure
now also think about what happens if
somebody new comes in
mika is an old friend of kim she's just
moved to the village she has a delicious
recipe for chicken sausage that's going
to require some
poultry and some
grain um so you know think about how
would you
position mika in here how would she be
connected naturally of course she could
sell sausages off to the pub so pat
would be interested in buying those
so this type of approach is very minimal
to bringing in new data data acquisition
and and data integration i think is
probably a better way to put them
i want to bring this back to something
that isn't really about technology let's
talk about pedagogy let's talk about
learning and and teaching
um susan ambrose has a great book called
how learning works it's you know one of
the
typical kinds of textbooks in in field
of pedagogy
when people look at the cognitive
psychology of how
individuals learn
how people proceed from being a novice
into gaining more and more expertise in
a given field
well we can talk about that at first
when someone's a novice they tend to
learn relatively superficial mental
structures disconnected sets of simple
facts
and of course when we're building tests
we query for that
um and then as people become more
advanced in a practice they start
learning how to string together
different facts and they can make
associations these tend to be
represented as far as like linear kinds
of sequences of cognitive structure
but then when people become much more
practitioners
they tend to think in terms of something
quite like decision trees
and at this stage people can really get
into
you know a lot more decisions and
formulating plans and whatnot
but when people begin to show expertise
in a given field one of the first things
that they almost always do is they learn
where to break the rules those decision
trees of rules
they know which parts of those they can
rely on and which parts perhaps are
questionable
and so when you start to look at the
cognitive structure for how experts work
they organize
what they have learned in terms of
graphs and this is what the cockside
people say
ai notwithstanding
the experts look for emerging patterns
when they try to make sense now i could
go into much more detail too i'm going
to skip over this part if you've ever
heard the rather unfortunate use in the
united states of the unknown unknowns
back 20 years ago
it derived from a gentleman at ibm named
dave snowden who had the connection
framework uh talking about how leaders
make decisions and in this there's a
sense of simple context where you follow
best practices you have facts that are
established you follow the rules done
and done but then when you get
confronted with a more complicated kind
of of
problem you typically have to bring in
some experts and they do some analysis
and that leads to decision making about
trade-offs
but then you get into a complex place
and this is where
you reach the infamous unknown unknowns
determining cause and effect just
doesn't work so instead you have to look
for emergent patterns
again we see this over and over again in
business in terms of how do we approach
management when you hit complex business
problems you're looking at merchant
patterns you're dealing with uncertainty
and for global business today this is
where we're at
so i just want to make the sense that
relational data and data warehouses are
really great if you're operating at the
level of say a novice or an advanced
beginner
when you proceed into more of the
complicated
competent practitioner type
yeah okay maybe some of the analytic
warehouse approaches that's good that's
where data science tends to live but
when you get into the expert parts of
this you need to be leveraging graphs
and we know this even before the
technology begins to get applied
uh
and i i will say that you know if you
look at the literature gartner
up until 2020 gartner research was
saying that uh well i'm not really so
sure about graphs they did an abrupt
about face early in 2021 and they are
now saying no actually even though graph
analytics is at 10 penetration in in
industry
today they're projecting that by 2025
graph technologies be used by 80 of data
analytics and currently over half the
inquiries that they get from enterprise
about ai are about graph technology
right here this bottom line is really
good the very thing that's happening in
the background when you're running a sql
query or when you're using an excel
spreadsheet the very thing that's
happening is it's a graph that's
executing and the metadata and the
business rules are being applied are
through a graph but those are
hidden behind the scenes to make them
look simple now the problem is as we've
learned from kinefin if you take a very
complex kind of problem and try to
oversimplify it
bad things happen
we saw that in the united states
certainly
where the unknown unknowns came into
play
so
um this point about a village and about
graph thinking we can embellish this a
bit more i want to shout out to uh some
very good friends and colleagues uh
jurgen buehler at bsf uh there's an
article called graph thinking that goes
into much more detail about this i'll
give jurgen credit he and i developed
this whole village thing together we've
been using it to help train executives
in graph thinking
there's also a recent podcast
with my friends ben lorca and jen webb
talking about this kind of surge in
interesting graphs
and along with it also i'll point out a
really good article from last year by
cassie kozakov about what is ambiguity
aversion because i'll say this one of
the points that jurgen mueller and
others out in industry make about graphs
in industry is that when you propose
using a graph for a problem typically
about half the people in the room who
are domain experts they'll get it
they'll jump right into it it's how they
think about their problem whether
they're working in logistics or market
intelligence or some sort of you know
business process
but the other half of the people run
screaming the opposite direction
and there's a reason for this out of
behavioral economics is something called
ambiguity aversion and we could go into
more detail but cassie has done a really
fantastic article about that
so um moving right along
there's something called graph theory
especially algebraic graph theory which
says that if we do have complex data
organized as a graph there's nodes and
edges and properties and all that
we can take and simplify this and turn
it into on the one hand a vector a
really simple case or a matrix
that's a very common case in algebraic
graph here or a tensor if you want to
you capture more of the nuances of the
graph
this is a very mathematical kind of
approach to working graphs and it it
tends to move everything into a numeric
space so that we can do number crunching
with things like gpus which is very
useful
but i want to make a point sometimes we
must use both the symbolic and the
numeric
the numeric is great if you're doing
deep learning or graph algorithms or
visualization
but if you're auditing for compliance
you're working with natural language
applications you're doing human in the
loop if there's rules regarding domain
expertise that have to be merged in or
if there's needs to explain what your
models are doing you're going to be in
the symbolic space so you need to be
able to have transforms back and forth
between the numeric and symbolic
and we provide this in an open source uh
sense it's it's very similar to say what
label encoding does in psychic learn or
of course embedding in pi torch and
other types of deep learning uh
frameworks
uh and in general this idea of going
back and forth between american symbolic
there are analogies uh i like to think
of it as something called thinking
sparse and dense
with uh all apologies
the author of uh thinking fast and slow
um but the idea is that when you're
working with data and workflows it's
really crucial when you're thinking
about how to leverage the hardware at
some stages you must work in a sparse
sense and these are typically bandwidth
limited uh
and even parts of deep learning when
you're calculating a loss function it's
typically sparse like this and it's
bandwidth limited data preparation is
like that
but then there are other times we need
to crunch on a very dense piece of data
that can be packed into a gpu like the
convolution layers in deep learning
that's compute limited
and if you want to go into more detail
on this there's a recent report dean
wampler and i just did for uh nvidia uh
working with the open source leads uh
tech leads at nvidia it's called
hardware is greater than software
greater than process
uh and i'm
throwing this out here as a sense of
graph data science how can we leverage
graphs how can we leverage the
dimensionality within graphs how can we
go through this process of starting with
unstructured data that has a lot of
connections in it to producing more
structure that we can leverage for data
science problems
and so that leads us to a library it's
called kg lab we started on this ah
we've been working on a lot of these
things for a long time but as an
official project it got started last
october and it's really picked up it's
an abstraction layer in python
and here's links to the repo and forums
and
and all that
um
the idea is that in the graph space
there's a lot of really interesting open
source unfortunately they're broken out
into different camps and they don't
really talk with each other the people
doing w3c technologies in rdf lib they
do great things but they don't really
have an integration path if you want to
use networkx to do graph algorithms
another of them have an integration path
if you want to go out and use pybiz to
do some nice visualization and if you
happen to have some sort of
probabilistic graph problem and you're
doing you know statistical relational
learning and you're using something like
psl or or pgmpi
nobody talks with them
so the problem was how can we establish
common ground abstraction layers to
integrate open source projects
and while we're at it let's make a lot
of paths out to things that we know like
pandas numpy psychic learn pi torch etc
and while we're at it let's do the right
thing and make this stuff so we can
parallelize it using spark and ray and
and arrow and rapids on and on and on
that's the gist of what we're doing with
kg lab
and there's like a very ambitious
roadmap although we've knocked a lot of
this down we have a lot of these
integrations now
um
also there's a related project i've been
working on for a number of years going
back to 2008 i've been working on text
rank um pi text rank has become uh
rather popular in the python space for
doing uh relatively lightweight but very
effective entity extraction from text
and also you can do some summarization
very closely related the two projects
work together
so um let me go into
last parts of this rather quickly
kg lab we do a lot of things here but
i'll give you a little bit of a flavor
if you're ever working with semantic
graphs and the whole w3c space like rdf
we do that
and
we try to make it as simple and painless
as possible if you've ever worked with
rdf lib before it
takes a lot of coding so we try to
provide an abstraction later make this
simpler
and we also have a lot of different
serialization formats supported but
importantly we support json ld a lot of
people talk to that
more importantly these days we're using
parquet and its orders of magnitude more
efficient than any of those others
it also integrates well with spark and
neutrino and cassandra and other things
works really well with gpus
ah there's a number of paths for
working with cairo medpo lib and pi viz
and exports to gaffy and things like
that for doing visualizations again
really just a few lines of code
if you need to query you can use sparkle
this is built in and we
bring the results back as well you can
get them as an array of rows or you can
get them back as a pandas data frame
uh if you need to do some sort of
validation one of my favorite projects
lately is called shackle it provides
shape constraints you can apply rules to
validate a graph like building unit
tests
also really great part of this
and when you need to jump into your
graph algorithms we have transforms
there and back for working with networkx
igraph and and some others on the on the
horizon
so the reason is this
you can use graphs for a lot of things
they really fit complex data problems
when you look at the space of what's
being implemented for graphs it's kind
of all over the map and i've tried to
represent this here some of the
solutions work really well with
uncertainty some of them are much more
formalized they're much more of an
analytic solution
and so you know
axiomatic transforms in scars don't
really fit well with graph embedding in
pi torch
we're trying to bridge that so that you
can build applications that mix and
match between these different parts and
leverage these different technologies
uh
and so for instance here's an idea of
using probabilistic graphs
with psl which i find extremely useful
for uncertainty
also graph embeddings using something
like pytorch geometric
so real brief in the time remaining i
want to show a general pattern for what
we're doing here along with an example
so if you think of an idealized machine
learning workflow this is the kind of
thing you're typically working with data
prep feature engineering models etc
let's look at an example of that uh
here's a data set from kaggle and it's
from food.com it has a quarter of a
million recipes all their ingredients we
take it as a cvs file and build it into
a knowledge graph
so you've got to have some data prep
you've got to go and do some
deduplication in addition to reading
csvs
but you've got to be able to infer
relations out of what's there
somewhat connected but it could be
connected more
uh you probably want to have some
feedback loops as far as getting people
in there to understand how to label
things appropriately apply annotations
using rubrics or snorkel something like
that and then you want to go out and
build a graph and then start to measure
some of the data quality within it rdf
and shackle are really good at these
points
then you can go out and run some graph
algorithms perhaps you want to analyze
the structure and find out what's the
most popular ingredient in this set of
recipes for how to make uh my favorite
food chastio bao um
maybe you could use leiden or take horse
or some sort of centrality measure for
that
on and on and on you can apply for the
different parts of the use cases these
different types of tools all within the
same structure and again we're really
we're not trying to invent a lot of new
code here we're really trying to do
integration and test and tutorial added
on top of other existing open source
libraries
um so all of this is online and there's
uh about 12 different jupiter notebooks
on our docs page that uh go through this
step-by-step and use this worked example
with the food.com recipe data
so you can take a look and run those uh
run those we have docker compose that
we're building out of github if you want
to run it in docker
um
and there's some other tangential
tutorials i really love what's going on
my friends uh in spain
in madrid and olympia uh this company
called recognize they do something
called rubrics we're very close friends
and work together on our projects back
and forth
also i want to give a shout out to
our github sponsors on the projects and
also to the knowledge architecture team
at basf global digital services they've
been hugely supportive uh jurgen miller
and others there
and we'll be going into this in more
detail with some tutorials and keynotes
and whatnot uh
other conferences coming up for the next
several months
and then with that i would like to say
thank you very much i appreciate we have
a lot more details online i wanted to
save some time so that we could have
some questions here um i
have only one screen
where i'm at so i'm going to leave it on
this page right here and we can go to
questions
thank you paco that
that has been a great talk and i
particularly appreciate the shout out to
my friends in madrid valencia who i
don't know yet but now i will
there are questions from the audience
and
here they come
the first one is
does the kg lab abstraction layer work
with neo4j and how it's different from
network x i'm mixing i'm messing them up
yeah no that's a great question so i'm
you know neo4j if you haven't worked
with it neo is arguably the most popular
amongst the graph databases and it
really started out as like a single
instance they've tried to go into more
distributed areas but
it's not going to be the thing you use
for really really large graphs as much
but they're arguably they have a a long
tail distribution of customer use cases
so very very popular
it is a database and you can do queries
inside of it although some of the other
things you would want to do graphs
aren't going to be quite as native
inside neo4j there are integration paths
we do have a connector there's something
called neo4j oh well actually there's a
few different ways but there's a way of
bridging between neo4j and semantic
graphs and so we can use that to import
and in fact one of the developers just
used it for
i think it was a 40 terabyte project it
was huge it was enormous so we've got a
good industrial strength integration put
in place there
the thing that it differs from network x
network x is a python library for
algorithms it doesn't have anything to
do with persistence or really any other
parts of graph other than
let's get a lot of different algorithms
implemented this is something that neo4j
is not really what you'd want to be
using um so the very separate kinds of
use cases so for instance if you wanted
to run page rank or or betweenness
centrality or or perhaps
some sort of you know connected
components neo4js sorry uh networkx is
brilliant for that so we integrate with
both of those
i see
and um
someone asked thinking about the idea of
sensing emergent patterns from unknown
unknowns what strategy what strategies
can experts use to separate
what they see as an emergent pattern
that they sense from relevant experience
uh that they have and
from implicit bias they may not be aware
of
something very good question um so you
know the experts do
this is one of the things we find over
and over again if you take somebody
who's an expert in global supply chain
and logistics and you put a graph of
their data up in front of them they
start to see the connections especially
if there's any kind of a real-time
updated aspect they get it right away i
mean this is how they think so um you
know typically in a domain the experts
will have these kinds of insights how
can we make it easier for them to
surface though if you have a 5 billion
entity graph they probably won't catch
all those patterns you probably won't be
able to grab go to to visualize them all
on one screen so uh what can we use to
to basically shine a lens and this is
where the algorithms come in handy some
of the query preprocessing certainly a
lot of work that's going on with deep
learning is basically shining a lens in
different parts of the graph that might
be very interesting given the kinds of
things that that expert is looking for
and this is where the graph data science
comes in very handy to work with the
domain experts
but the second part of the question is
what if it's something they're missing
and again this is where by having
automation having very large deep
learning models go in learn those
patterns
then you can say well the expert
actually i'll point out a great use case
of this novartis has exactly this
problem they take all the research
coming in in terms of pharma and they
run it through a graph and then they
build models out of that to predict the
interactions between different genes
different molecules and different
diseases and what they found the first
time they did it they presented to their
biologists the biologists said oh we
know all this stuff well we know 80 of
it so the company said well what about
the 20 that you didn't know and they
said
hold my beer i'm gonna go back to the
lab and then they found out actually
very important discoveries by that 20
they hadn't tried before and so now this
approach leveraging graph analytics has
become part and parcel of the research
strategy at novartis and at other kinds
of pharma so this is where yeah they may
be some bias on the part of the domain
experts how can we use ai technologies
to augment that and uh in particular we
have one project at kg lab where we're
using reinforcement learning to surface
a leader board of emergent patterns that
maybe nobody bothered to check before
thank you you've mentioned um working at
higher a bigger scale of data and it
segues into the next question from an
audience member who asks how does kg lab
perform at scale when compared with
libraries such as igraph or networkx on
algorithms like betweenness centrality
so the idea is now performance where you
mostly
focus on capability before
very good very good well i mean things
like like uh running between a
centrality on network x or igraph um
what you probably want to do there's a
few slides back there's an illustration
of this
have your graph manage your graph you
can use different technologies to manage
it and persist it
when you get to the point of needing to
use some of these algorithms you
typically want to take a projection off
that you want to take a sub graph and in
fact when you're working with network
hex you must so that's one of the
abstractions that we have is how to
project out part of the graph as a
subgraph
you won't be using the entire graph when
you run it through the algorithm
and in some ways there are actually some
pretty good algorithms to try to filter
and pare down
i did a multi-scale backbone uh for
instance that's in production use in
hungary i just found out about that at
one of the recent conferences um there
there are techniques of being able to
scale down a pair down if you will a
subgraph to get again the lens on the
part that you need
as far as how does kg lab scale it
really depends on what kind of
infrastructure you have um i guess
without letting the cat out of the bag
i do other work besides kglab some of
which is
currently private in early stages but
maybe someday soon will be open source
that's in active negotiation right now
and uh it's something that's built using
much the same technologies as we use the
kg lab uh using ray for scaling on a
large cluster and uh
to be clear we're already at pretty high
scale we're aiming for trillion node
graphs by the end of the year
thank you i
that's all the time we have
unfortunately but thank you so much for
giving us your time today at pike on eu
and
um big hand of applause is going to be
virtual and venue less but
thank you
much appreciated thank you javier have a
great day
you