Language Models are Open Knowledge Graphs (Paper Explained)
deep learning machine learning arxiv explained neural networks ai artificial intelligence paper nlp natural language processing bert gpt gpt2 gpt-2 gpt3 gpt-3 gpt 2 gpt 3 knowledge graph knowledge base language natural language understanding berkeley uc berkeley dawn song unsupervised extraction corpus wikidata wikipedia entity linking entity recognition spacy attention attention matrix beam search viterbi causal attention language model autoregressive
#ai #research #nlp

Knowledge Graphs are structured databases that capture real-world entities and their relations to each other. KGs are usually built by human experts, which costs considerable amounts of time and money. This paper hypothesizes that language models, which have increased their performance dramatically in the last few years, contain enough knowledge to use them to construct a knowledge graph from a given corpus, without any fine-tuning of the language model itself. The resulting system can uncover new, unknown relations and outperforms all baselines in automated KG construction, even trained ones!

OUTLINE:
0:00 - Intro & Overview
1:40 - TabNine Promotion
4:20 - Title Misnomer
6:45 - From Corpus To Knowledge Graph
13:40 - Paper Contributions
15:50 - Candidate Fact Finding Algorithm
25:50 - Causal Attention Confusion
31:25 - More Constraints
35:00 - Mapping Facts To Schemas
38:40 - Example Constructed Knowledge Graph
40:10 - Experimental Results
47:25 - Example Discovered Facts
50:40 - Conclusion & My Comments

Paper: https://arxiv.org/abs/2010.11967

Abstract:
This paper shows how to construct knowledge graphs (KGs) from pre-trained language models (e.g., BERT, GPT-2/3), without human supervision. Popular KGs (e.g, Wikidata, NELL) are built in either a supervised or semi-supervised manner, requiring humans to create knowledge. Recent deep language models automatically acquire knowledge from large-scale corpora via pre-training. The stored knowledge has enabled the language models to improve downstream NLP tasks, e.g., answering questions, and writing code and articles. In this paper, we propose an unsupervised method to cast the knowledge contained within language models into KGs. We show that KGs are constructed with a single forward pass of the pre-trained language models (without fine-tuning) over the corpora. We demonstrate the quality of the constructed KGs by comparing to two KGs (Wikidata, TAC KBP) created by humans. Our KGs also provide open factual knowledge that is new in the existing KGs. Our code and KGs will be made publicly available.

Authors: Chenguang Wang, Xiao Liu, Dawn Song

Links:
YouTube: https://www.youtube.com/c/yannickilcher
Twitter: https://twitter.com/ykilcher
Discord: https://discord.gg/4H8xxDF
BitChute: https://www.bitchute.com/channel/yannic-kilcher
Minds: https://www.minds.com/ykilcher
Parler: https://parler.com/profile/YannicKilcher
LinkedIn: https://www.linkedin.com/in/yannic-kilcher-488534136/

If you want to support me, the best thing to do is to share out the content :)

If you want to support me financially (completely optional and voluntary, but a lot of people have asked for this):
SubscribeStar: https://www.subscribestar.com/yannickilcher
Patreon: https://www.patreon.com/yannickilcher
Bitcoin (BTC): bc1q49lsw3q325tr58ygf8sudx2dqfguclvngvy2cq
Ethereum (ETH): 0x7ad3513E3B8f66799f507Aa7874b1B0eBC7F85e2
Litecoin (LTC): LQW2TRyKYetVC8WjFkhpPhtpbDM4Vw7r9m
Monero (XMR): 4ACL8AGrEo5hAir8A9CeVrW8pEauWvnp1WnSDZxW7tziCDLhZAGsgzhRQABDnFy8yuM9fWJDviJPHKRjV4FWt19CJZN9D4n
 Hi there. Today we'll look at language models or open knowledge graphs by Cheng Wang Wang, Xiao Liu and Don Song. This paper on a high level proposes to construct knowledge graphs which is a structured object that's usually built by human, by experts, either fully manually or semi-manually with heavy human involvement. It proposes to construct knowledge graphs automatically by simply using a pre-trained language model together with a corpus to extract the knowledge graph from. The cool thing about this paper is that there is no training involved. So there is no model that learns how to construct a knowledge graph. The entire knowledge is simply extracted from running the corpus once. So one forward pass through the corpus through the pre-trained language model and that constructs the knowledge graph. So that's kind of the core message of this paper. They say this paper shows how to construct knowledge graphs from pre-trained language models without human supervision and it turns out the way they do it, it works pretty well on kind of standard knowledge graph construction benchmarks. So that's the paper in a nutshell. We'll go through all of this including I have a bunch of criticisms but it is a pre-print. Remember this. And yeah, so usually I'd say at this point if you like this content don't hesitate to share it out and so on. Today we're gonna try something different in three, two, one... Stop! It's sponsor time! This video is sponsored by tab 9. Tab 9 uses deep learning to help you write code faster. What could possibly go wrong if you do that? No, I'm joking. I'm joking. Take a look at this piece of code here. I was trying to refresh some elastic indices and as you can see here all I said was could and tab 9 completes it to could not refresh because above I was trying to call a refresh method. This is something that I haven't seen any other completion engine do yet. Compared to a regular coding engine tab 9 is trained on lots of open source projects and it combines this with your code and it predicts what you want to do compared to predicting what's possible which is what a classic engine does. Tab 9 it uses a GPT based model and it downloads that model onto your machine so the code never leaves your machine. There is an opt-in feature where you can run that in the cloud and that will just give you a bit of a better beam search and better quality predictions and it saves you a bit of RAM. As you can see I myself use tab 9. I just have it on by default and I'm pretty happy with it. I use it through CoC integrated into my NeoVim but you can also get it in Sublime, Atom, IntelliJ, VS Code even like Jupyter notebooks and you can use it together with classic completion engine so you can really get the best of both worlds. So whenever you see me code in a coding video look out for this TN marker next to the completions that's the completions by tab 9. It doesn't only work for Python it actually works for pretty much any programming language that isn't completely obscure. If you go to this link within 72 hours of when this video is released you'll get three months of tab 9 professional for free. The professional version removes the project size limit of the free version and it also gives you access to that sweet sweet cloud inference. After the three months you're automatically kicked out of the pro version there's no auto sign up there's really nothing to lose. I mean the only bad thing here is that tab 9 itself is written in Rust. If that's the worst thing about an offer it's a pretty good deal. Again I use this myself and I'm pretty happy with it. So again if you sign up at tab9.com slash promotion slash yanaculture within 72 hours of when this video is released you'll get a free three months of tab 9 pro no strings attached and now enjoy the video. Thanks! Alright I hope that was fun let's get back to the paper let's get into the paper. So first of all what is my first criticism of this paper? This the title. There are some disturbing trends in the last few years in in in machine learning papers and the disturbing trends can be maybe encapsulated with the phrase is all you need. So people have sort of since attention is all you need since this paper people have discovered that if they just append this to whatever their paper is about then the paper will get much more notoriety. And the same thing I think is a bit at play here with this with the R because in recent times we've kind of seen a bunch of papers that show equivalences between models such as a famous example is that the transformers are Hopfield networks in some kind of in some regard and these papers are pretty cool right even if the two things are not exactly equal all the time if you can say look there is a setting there are you know under these assumptions under these settings in this situation these two models actually are the same that's a pretty cool recognition a pretty cool thing to show and it's very useful for academia and and practice I believe however I believe that our keyword that is keyword should be sort of reserved for when two things are equivalent whereas here in the very first at least they're honest right in the very first sentence they show they say well we show how to construct knowledge graphs from pre-trained language models so essentially they're going to use a language model to approximately construct a knowledge graph and they're also going to use a bunch of other auxiliary models that come all pre-trained but still they do not show an equivalence of language models and knowledge graphs in this paper not at all so I would sort of I see that you can get somewhere with these titles but yeah maybe people will be disappointed kind of if they read the paper which it is actually a cool paper believe me all right so as I said what we have usually is a corpus okay a corpus is simply a bunch of text pieces you can think of maybe just the text in Wikipedia okay here you know the this Wikipedia page about Bob Dylan Bob Dylan is a songwriter was awarded a Nobel Prize signed Alva Grossman these are easy sentences right there there can be sentences are usually larger and longer and so on and what you want to do is you want to extract a knowledge graph so the knowledge graph has two distinct things it has entities and one entity here would be kind of Bob Dylan songwriter is an entity Nobel Prize in it is an entity you can sort of think of them as nouns okay and then the second part in knowledge graphs are the relations here occupation sign award received and so on so that the relations connect two entities there is always what's called a head of an end of a of a triple so a head of a fact which in this case is Bob Dylan three times then there is a tail which is sort of like the object of the verb and then there is the relation which is described by the verb now here you can see there are two stages of constructing such a knowledge graph any system that does this probably goes through these two stages so first you extract a set of candidates which it's not the knowledge graph yet because these are still strings right you extract a bunch of string triplets as you can see here and as we said as the sentences get more complicated it gets more and more difficult to extract these kind of triples and then the second part is that you need to map it to a to a scheme to a to a schema and these schemas are usually defined by humans so here we're still going to rely on humans to define the schema top so there is one list that says entities and the entities there are just the entities are listed okay by the humans and at some point it says Bob Dylan Bob Dylan and it has a bunch of mentions of Bob Dylan associated with it and it has a clear ID in this case you see the ID is Q 392 in that knowledge graph and the system not only needs to extract these facts but then also map these facts to the correct entities sorry map these facts to the correct schema entries this second stage right here is a a bunch of standard tasks so especially mapping something like the the word Dylan in its context to this entity Bob Dylan which you can think of it as like the Wikipedia page of Bob Dylan right that's how the system usually work that is a task called entity linking okay entity linking and similar tasks exist for leak for sign like the relation awarded mapping this to award received to this so maybe there is some kind of dictionary entry award received and what it means and a bunch of examples and you're supposed to map this to that these are standard tasks and the system that we are going to look at right here is not not much concerned with these tasks it simply uses pre-existing methods to do these things so the system we're looking at today does this first part right here it takes text okay this is text and it comes up with these candidate facts about the text whether how this is then mapped to the schema that is a a different question and it's so there there are pretty cool things in this paper about this step but we're first going to look at the first step and then at the second step all right so how does this system do this and how does it do it that there have been machine learning models before but being machine learning they all have like some sort of a training corpus where you have kind of the facts as a training set and then you have a separate set of facts as a test set and you try to learn from the conjunction of the text and the training facts how to extract facts not this system this system simply uses a pre-trained language model so what's the reasoning the reasoning is the following we used to think that we could do NLP probably best with having a knowledge graph right with having this set of very structured data we can answer something like what's the what's the age of Barack Obama's wife and then you could go to the entity of Barack Obama you could look at the relation spouse you could go to Michelle Obama you could look up her birth date which would all be structured information in this graph so you could sort of answer questions like this and search engines like Google and so on they have this built-in so there is kind of a knowledge graph entry sometimes when you search an entity in Google that pops up and these have been very useful to answer questions like however in recent years language models have become better and better things like BERT or GPT-2 have become better than these expert systems let's call them at answering questions by the way if you want to if you want to hear a very very cool and solid argument of where these kind of expert systems where this kind of structured human annotated or maybe extracted information can still come in in natural language understanding I would recommend the machine learning Street talk episode we had with Wally Saba extremely interesting person and I had I just I can recommend listening to that this should be out any day now if it is not already so the language models have become better and better at these tasks without having this structured information so the hypothesis is maybe these language models can already contain the information that's necessary to construct these structured facts because the structured facts is what we you know let's say should use to answer these questions because we feel that structured information is better than unstructured the language models are pretty good at these tasks so maybe we can get the structured information out of the language models so that's what they do they say the contributions are as follows we show how to construct knowledge graphs from pre-trained language models the knowledge graphs are constructed with a single forward pass of the pre-trained language models without fine-tuning over the textual corpora I think this is the this is kind of a very strong point about this paper and it's also shows that if you're some PhD student somewhere and you don't necessarily have the resources to train the next GPT-3 model or fine-tune it there is still research to be done simply if you have enough resources to forward pass your data which is often much fewer than to train one you can still do very cool research I think this paper shows this explicitly okay this helps researchers explicitly understand what the language models learn bridging the deep language model and the knowledge graph communities through enhanced model transparency okay they say we propose an unsupervised two-stage approach MAMA which stands for match and map to first match the candidate facts in the corpora with the knowledge stored in language models that's the first step we looked at then map the matched candidates facts to both fixed and open schema to produce a knowledge graph and then they say they produce a new type of knowledge graph which simply is the the facts sometimes the facts they extract they can't really map to a schema entry and we're going to look at that because I think a bit critically of this they say namely the open knowledge graph consists of mapped facts in the fixed schema of existing knowledge graphs annotated by humans and the unmapped facts in the open schema that are new in the reference knowledge knowledge graph schema so what they claim here is that their system is finds these new relations that are don't even exist in the schema and is able to uncover kind of build new additional schema entries and they call this the open knowledge graph I'm a bit skeptical of this as we are going to see so the first step how do you come up if you have a sentence and this is it this is a very poor example I feel honestly to to do this it's I get it must be short but it's a poor example but stay with me so you have this sentence Dylan is a songwriter and you would like to extract a fact from this the paper is not really written clearly on how I mean it is I could you can parse it out but the description is kind of distributed so step one step one is run spacey run spacey this is a standard kind of library for NLP to extract noun phrases or they call them noun chunks okay so step one is not there's nothing to do with the language model it is simply you want to find the noun phrases in here the noun phrases are Dylan and songwriter now these noun phrases now define your head and your tail of the facts so you already have two things right so the the entire task of what of their method they're proposing is so the step one is run spacey to find the head and the tail of facts step two is question mark for now step three is going to be use the entity linking system and the relation linking system to construct the knowledge graph okay so step one is steel underpants and then step three is profit so what's step two step two is obviously step two is where their system comes in step two is here is the head and here is the tail in the text some hot wear in between there might be a relation and we need to figure out where that is right so how does this method figure it out so you already see the assumptions here are very very restrictive right so you use spacey to extract basically noun phrases which means you probably already going to miss a lot of things that are not recognized as noun phrase and they all they also say that that spacey's annotations are sometimes error prone and that's why they miss a lot of things and then secondly the assumption that the relation must be in between the two things textually now you can run the algorithm forward and backward but still it must be in between and it must sort of be encoded let's say as a semi accurate string in there I guess then that's up to the relation linker but already these assumptions are super constraining in the the kind of things you can find and you'll see in the experiments that their biggest flaws that they have a very very low recall I mean so do all the systems on the task apparently but they still have a very low recall and it's because they constrain their problems so much I'm going to guess if they wouldn't constrain their problems so much then they would have maybe a better recall but their precision would just plummet because these these things if you let them run wild they just over extract so basically every every set every verb in every sentence is going to be a relation right so like I ate a banana I ate banana would be a triple not necessarily a really valuable entry in any knowledge graph though banana has a lot of carbs so I would want to know about that okay so you see that the task is now reduced from building knowledge graphs to simply given a head head annotation had peace in the string span and a tail span extract any span in between the head and the tail that describes the relation between the head and the tail so the way this algorithm does it that's where it uses the language model okay so here it's going to do something that is going to be similar to dynamic programming if you've seen kind of the dynamic programming and search algorithms let's say you know string matching algorithms and so on this is going to be sort of similar in that what we're going to do we're going to start from here from the head in the string there could be text before it right we're simply going to locate the head Dylan right here and going to start then we're going to look at its attention matrix now the attention matrix is we're going to cross out here the attention matrix if you I've done many many videos on attention the attention matrix basically in a sequence means how much each token attends to each other token right how much information is kind of sent from each other token to this token right here so this up here would be be the query and these would be the keys the attention matrix specifies that so since we locate things between the head and the tail what we want to do is we want to cross out we want to disregard everything that's kind of behind the query and only look ahead in the sentence okay so that's why the sum of the attention matrix here is crossed out as you can see these are the X's this is exactly because we only search in one direction so from each from the token Dylan we can look at three things we can look at is a or songwriter and this the question is simply where do we go next with this algorithm right there's no interpretation yet it's simply where do we go next and the where do we go next is simply answered by just taking the highest scoring thing in that column of the attention matrix I look at the attention column where of the token Dylan I take the highest scoring one that's point three here is higher okay then I go to point three and that means is gets into my candidate fact okay and once I put ears into my candidate fact I then go to is so the next thing I do is I go to is and then I again look in the corresponding attention column and I see what's now the biggest entry here and the biggest entry is point four which is songwriter and you can see here now we skip the a that's how we leave out some text okay by skipping it basically so you can see that this this can create artifacts right this can create like kind of holes in the middle and so on but we skip a we go directly to the point four and then we discover up the point for that is our tail so now we put our tail into here and since our tail is the last word we can stop the algorithm I yes so there is no need to to go on even if there were text behind the tail as soon as we are at the tail which we already know right we're given the head and tail we stop all right so the we simply go forward with always the biggest entry in the attention matrix until we reach the tail that's the algorithm this this there it's described here but it's kind of described in this in this way where it has these actions like start yield and like this maybe I'm not understanding something but it seems completely unnecessary to kind of describe these actions and and it basically start the search from the head the head is added as the initial candidate and so on then in yield it sometimes says with the largest score from the attention matrix is appended to the end to yield the new candidate and so on but still and then stop we stop and the algorithm description here it basically just says while we're not done if we're if it's not the stop action we continue it's it's sort of it doesn't tell you anything like this is this is a super unclear description of this algorithm basically the whole logic that you would want to know about is here in this action manager right so the action manager that gives you the action is doing the actual logic of figuring out which token you know you should do next and where you should go next and so on this is nowhere in the algorithm the algorithm just describes beam search so you can do this a little yeah the little more sophistication that comes in is that you don't do this deterministically but you actually do it via beam search okay but you can you can just generalize this all right so the description is a bit floppy with the whole actions and action manager and whatnot and not describing the only thing they don't describe formally is how actually to select the next token which is basically the entire kind of meat of the algorithm in any case you might this is something that confuses me right here so fair enough you know they say here we take the attention matrix and we cross out these X's all right but they say they can take things up here right they can take things like Bert and you know as I said fair Bert has a full attention matrix everything attends to everything but they can also take things like GPT-2 now GPT-2 is an autoregressive language model that means that in GPT-2 if you look at it then you produce each token one after another which means that when you produce so each token when you train or when you evaluate even each token can only attend to the things in front of it right you see that the problem with what this thing requires of this is also the same okay let's do that you see the problem with this method this method is the exact opposite each token attention matrix is deleted such that only the entries ahead of it are in the attention matrix you don't actually get GPT-2 to give you an attention matrix that looks ahead because it only ever looks behind so maybe maybe what's happening is that the query and key matrices are switched up in some way in that case when we want to interpret the algorithm the way they write it down is if I am at a particular part of what I think is the relation between the two entities how am I going to find whether or not there is more to the relation right there could be a it could be a multi-word relation like has a child with or I don't know can't think of any multi-word relations or whether we kind of are done with the relation and go to the to the tail what this thing is saying is that we should look at the the language model so if if this is really how it is here and you are at the word is what you want to know if this is BERT if this is a BERT language model what you want to know is if I were to cross out is if I were to delete this word which other words in the sentence right here that are ahead of me are very very informative to predict this particular word and that's that's kind of the query style and you know if the answer turns out to be songwriter is quite important for that maybe Dylan is too but we only look ahead if it turns out a the word a is not as important as the word songwriter right because songwriter yeah it gives an indication that there should be is because songwriter is kind of a profession and there's a person in front of it we don't look at that but the attention matrix would would have that in mind if that's valid right so that's how this this construction is made however if this is the key we have to think of the other way around if we are at is we look ahead and say if I were to delete the word a could I reconstructed how well could I reconstruct it from this word is or if I delete songwriter how well could I reconstruct that from the word is I think both are you know there is interpretations probably for both of these methods but what I want kind of to convey is that none of these things are really amenable to constructing a knowledge graph it's it's quite interesting that this stuff actually works because all it asks is how well does one word inform about the presence or how well can one word predict another word and from that information we construct this knowledge graph which probably is a testament to the fact that knowledge graphs maybe aren't so much about knowledge if you extract them from a corpus but more about grammar I would think that's the thing that goes on here because these language models are a lot about grammar right a lot about how different words appear together frequently so given that songwriter is kind of a mix between grammar and basic word knowledge given that songwriter is kind of an object here the word is being the verb is probably quite important for it and that's exactly these these triples they always appear a bit like in of compressed sentences and which which are very grammatically relevant so I'm not buying these hypothesis that there is much knowledge in these language models and that's why this works what I much rather think is that they are really really really good at a kind of grammar and statistical association between words across the language and that's why they can extract these candidates facts so well okay so that's what I think about the algorithm they do constrain it some more as if it doesn't already have enough constraints but they all make sense okay so they say the matching degree which is simply the sum of all these attention matrix entries that we've encountered during our search so all the ones we didn't skip or to count it together or the matching degree of this triple the matching degree must be above some threshold that's the first constraint because so they give an example right here for the sentence rolling stone wrote no other pop song has so far only challenged artistic conventions and the extracted candidate fact is rolling stone wrote pop song again you can kind of see here it's mostly going in into into grammar ish so spacey extracts rolling stone and pop song and the language model here extracts like the only verb in between wrote so yeah to to limit to kind of limit the the to limit the matching degree to say it must be at minimum kind of some some number it makes a lot of sense because if the matching degree is high that means if we go by this attention matrix it means that these words that are in the candidate fact they kind of as themselves they follow from each other so the language model thinks that wrote is a very good follow to rolling stone and pop song is a very good follow for wrote or the other way around depending on which way the attention matrix is but that's kind of the language model thinks that that these words together make sense in the context of the sentence of course like in the context of this entire sentence so as I said it's sort of can think of it as a bit of a summarization paper but with more constraints constraint number two is that the frequency of R is above a threshold so the relation itself shouldn't be too specific it actually should appear a bunch of times in the corpus so what you do is you know you go through the corpus once extract all the facts my pen just dropped you extract all the facts or the all these candidates and then you you kind of count them and go through the candidate facts again and delete all the ones that are below a certain thing that's people usually do this with things like stop words or rare words and so on it's pretty standard makes a lot of sense and constraint number three relation or is a contiguous sequence in the sentence okay so you have an example here from the same Rolling Stone wrote challenged conventions which the language model would like to extract because again these in the context of that sentence these words sort of you know they jump to each other in the attention matrix because you can predict them from each other very well but they say this must be a contiguous sequence so what I said before I said this could happen with this constraint they excluded okay so for the second part where they actually have to map a candidate fact to a fact in the schema as I said they use kind of pre pre-made solutions entity linking and relation mapping with the schema I won't go into this except to say that whenever they find a match they say that this is a mapped fact whenever they don't find a match they say oh this is an unmapped fact okay an unmapped candidate means that at least one of H RNT is not mapped to the schema there are two types partially unmapped facts is where some are mapped and completely unmapped facts indicate that all H RNT are not mapped to the schema okay for example Jacob was a registered Mennonite now here they so they they say they have these different facts and you know it's a cool thing if a model like this can actually come up with new fact not so not only new mapped facts which is something you would expect right if humans provide some kind of a schema then build a knowledge graph this is never complete so if you can automatically kind of fill in missing facts that's very very cool though I would say humans if you construct knowledge graphs humans should probably also build kind of like negative connections saying like yes it is conceivable that Elvis was a vegan because a lot of texts talk about it but in fact it is explicitly not I don't think that's what we have in the knowledge graph so far but it would be cool if this model could fill in new facts yes to the schema it would also be cool if it could uncover completely new relations that haven't they hadn't been considered by the human makers of the knowledge graph like if the knowledge graph itself is incomplete the schema is a man you know same argument the schema is probably also incomplete this paper is sort of trying to sell their system as something that can do that and I believe that to a degree but also also Jacob was a registered Mennonite okay now maybe I'm completely wrong from the sentence Jacob was a registered Mennonite in Amsterdam I might be completely wrong but Mennonite is a religion I think and I'm very very sure that any of these knowledge graphs with the schemas that they have have being in a religion or being of a certain faith in their relations table somewhere and I'm also pretty sure that Mennonite large enough that that would actually appear as an entity maybe Jacob not right maybe Jacob is an unknown Jacob we don't know who Jacob is but this seems more like a failure of the entity linker and relation linker than an uncovered new relation or an uncovered new entity so yeah take this stuff with a grin now they they are very honest about this but just to say that that's probably what happens most often so here you can see the graph for Bob Dylan constructed from the Wikipedia pages that are kind of they say around the page of Bob Dylan so I guess one or two or three hops away something like this and you can see the blue stuff is stuff that we already knew so that the human humans also found when looking at this then yellow stuff I believe is either new relations so whenever things are annotated it's a new relation in the schema so you can see this is an entity in the schema because it's annotated this is a relation in the schema but the arrow is new so the humans hadn't yet extracted the fact that Bob Dylan was or was a member of artists united against apartheid then the yellow also sometimes means that there is a new thing so here tour with is a relation that's extracted that is not in the knowledge graph yet also this one and you can it's pretty it's pretty cool right that you can extract these things automatically there's a lot of yellow stuff here which means there is not a lot of new information that this extracted and a lot of this new information is actually mapped to the schema right Bob Dylan residents in Duluth I don't know how to pronounce that by the way yes so so that's that's fairly fairly cool they do some of these tasks of these knowledge-based tasks in these tasks what you'd have I believe what you'd have is always you'd have like a head and a relation given so you have a document and you are given a head and a relation and you're asked what's the tail of this and then you ask the system and the system will tell you so you have these baselines and these baselines I believe they are specifically made to extract these knowledge representations they might even be trained I don't I don't know that but you can see that the MAMA even the even the smallest one here beats those by quite a bit now you can see that the recall is significantly lower than the precision which is a direct result of how many constraints on the system there are and tells you sort of what the going forward what the improvements can be so they analyze a lot of this and yeah so a first recognition is that larger and deeper language models produce knowledge graphs of higher quality BERT language models outperform GPT-2 language models under similar model sizes which is interesting is scalable to larger corpora which again as we said you don't need to train it and larger corpora embed more complete knowledge graphs which is something we would expect the other interesting part is the unmapped fact so the numbers you can actually compute only for the mapped facts right because that's where you have data humans produce the knowledge graphs from this that's what you can compare with now the unmapped facts they say they analyze we turn to study the quality of the candidate facts that are not mapped to the above reference knowledge graph schema but are in the open schema generated by MAMA that's mama we manually judge such unmapped facts generated by our best method from 100 sample documents in wikidata and TAC KBP respectively so they they go as researchers they look at these things and they judge them whether or not they're true given these documents in Wikipedia they say the quality of unmapped facts is very for that so that the claim is that they've looked at them and they are good we find that 35.3% of the unmapped facts are true on wikidata we find that 83.2% of those true facts are partially unmapped facts for example Bob Dylan tour with the Grateful Dead and yeah here is an if this really isn't in the schema right this is a nice relation that you might think humans would miss because touring with someone is not the first thing that would come to mind if you had to come up with a bunch of relations between entities but it is something that is regularly useful regularly used for musicians so that is an application where certainly an automated system can even extend the schema right whose relation is not within the scheme of wikidata well both head and tail are in the schema the register the remaining true facts are completely unmapped facts for example this red Jacob was a registered men and I and they also say accurate entity detection is desired where they say a lot of the errors are due to spacey detecting wrong incorrect entities or due to incorrect or missing entity linking by the by that those systems the rest errors made by mama are incorrect relation phrases such as uninformative relation phrases for example Bob Dylan made and his breakthrough oh what can you do what other what other one what other verb would you put there yeah but okay we're going to look at a few last things right here they have a bunch of a bunch of experiments right here which where they show you know the beam size has an influence this constraint number one and number two that we looked at has an influence right so you can tune these things a bit what is interesting here is that they try they try to look at either the attention matrix of the last or of all the layers and interestingly the system performs better if you only look at the attention matrix in the last layer now they reduce that attention layer because there are multiple heads using max or mean and see they perform similarly but it is interesting that only the last and they argue they argue in the text that we know that the last layers kind of have higher level features than the lower layers but I recall there are multiple papers like I've done videos about them what does Bert learn and so on I think even something in constraint in conjunction with lottery tickets and so on that show that in a transformer at least I think it is the middle layers that encode the most kind of semantic knowledge because the lower ones yes they are for kind of low-level features but the upper ones they are again for low-level features because the task right here at the end is to predict an individual word or token right so you'd expect that the features in the attention matrix there are go back to kind of sort of more grammatical features and so on and that the highest level features are actually somewhere in the middle I don't know if they tested if they only tested like all versus last in which case yeah I believe that but if they tested each one individually and it still turned out that last is the best that would kind of add to my hypothesis that what happens here is more kind of a grammatical effect of extracting the this correct candidate candidate verb in between the head and the tail all right so that's that's kind of kind of gives more weight to my hypothesis like so to repeat my hypothesis is that it's kind of a grammatical thing that's going on here because the only task of this model is basically to find the correct string span for the relation between head and tail because it's already given head and tail and there from the text their hypothesis is more like we the language models have a lot of knowledge built into them and we can extract that knowledge kind of it they make it sound like then the language model has this semantic knowledge in them okay okay so so let's look at a bunch of mapped facts right here you can okay you can maybe check out a lot of them yourself but we'll just look at like one in each category blah blah mail yada yada yada yada is in worse shape however a Klaus told press conference at the Western city of Essen where the other yada yada and it extracts this company and it maps it to the city of headquarters maybe they leave out some text here what I want to get to is the unmapped facts where are the unmapped mapped facts to just kind of show you mapped facts unmapped facts okay so the unmapped facts what I feel and you can judge for yourself please what I feel just to pre-bias you before we look at them is that a lot of times simply it extracts things that are that are it extracts things that are not it simply can't can't assign things right it's a failure to assign it's not a new thing because in these schemas like you haven't seen the schemas but you kind of get a feel the last which is the last table you kind of get a feel of what contains in it so maybe get a feel for for what okay Ernst Heckel was born 16th of February 1834 in Potsdam okay so the extracted thing is heckle was born on 17th of February 83 in Potsdam okay so that it maps to this is in the knowledge base a schema this is in the schema but was born on 17th of February 1833 in is simply a failure of the relation linker okay he was also a pacifist until the First World War yada yada yada then Ernst Heckel and then was on a and a pacifist are both not in the schema now maybe pacifism isn't in the schema maybe maybe though I would guess pacifism has a Wikipedia page so it must be in the schema because it's a wiki data but was as you know the relation here with something be like a political leaning or something like this which is certainly certainly in the knowledge base right then you have things like heckle was awarded the title of excellency so you have correctly heckle again recognized award received is in the schema nice excellency as a tail and excellency you know what what do you want like this is this is a this is not a fact right this is the award or the title of excellency would be kind of the thing so this is a failure of spacey so again I have I've seen little facts here that would actually be of genuine a genuine addition to the schema that should be considered and I absolutely believe that the schema is incomplete don't get me wrong I like a 100% the schema is probably less than 1% of what it should be right if we did a thorough job I just don't think that this system here is a good like I think that the things that this system comes up with mostly are simply failures of its subsystems rather than genuinely new entries to the schema that's different from when it genuinely discovered when it discovers a new mapping between already established things for example Pauline Baines educated at this college right so these are new facts all fit in the schema and the system might be very very nice for that all right so that was my kind of estimation of this paper I hope I didn't rag on it too much as I said it's it's very cool work actually I look at this appendix is giant go look at it check it out please tell me what you think about it in the comments any feedback is welcome and I will see you next time bye bye
 Hi there. Today we'll look at language models or open knowledge graphs by
 Cheng Wang Wang, Xiao Liu and Don Song. This paper on a high level proposes to
 construct knowledge graphs which is a structured object that's usually built
 by human, by experts, either fully manually or semi-manually with heavy
 human involvement. It proposes to construct knowledge graphs automatically
 by simply using a pre-trained language model together with a corpus to extract
 the knowledge graph from. The cool thing about this paper is that there is no
 training involved. So there is no model that learns how to construct a knowledge
 graph. The entire knowledge is simply extracted from running the corpus once.
 So one forward pass through the corpus through the pre-trained language model
 and that constructs the knowledge graph. So that's kind of the core message
 of this paper. They say this paper shows how to construct knowledge graphs from
 pre-trained language models without human supervision and it turns out the
 way they do it, it works pretty well on kind of standard knowledge graph
 construction benchmarks. So that's the paper in a nutshell. We'll go through
 all of this including I have a bunch of criticisms but it is a pre-print.
 Remember this. And yeah, so usually I'd say at this point if you like this
 content don't hesitate to share it out and so on. Today we're gonna try
 something different in three, two, one... Stop! It's sponsor time! This video is
 sponsored by tab 9. Tab 9 uses deep learning to help you write code faster.
 What could possibly go wrong if you do that? No, I'm joking. I'm joking. Take a
 look at this piece of code here. I was trying to refresh some elastic indices
 and as you can see here all I said was could and tab 9 completes it to could
 not refresh because above I was trying to call a refresh method. This is
 something that I haven't seen any other completion engine do yet. Compared to a
 regular coding engine tab 9 is trained on lots of open source projects and it
 combines this with your code and it predicts what you want to do compared to
 predicting what's possible which is what a classic engine does. Tab 9 it uses a
 GPT based model and it downloads that model onto your machine so the code
 never leaves your machine. There is an opt-in feature where you can run that in
 the cloud and that will just give you a bit of a better beam search and better
 quality predictions and it saves you a bit of RAM. As you can see I myself use
 tab 9. I just have it on by default and I'm pretty happy with it. I use it
 through CoC integrated into my NeoVim but you can also get it in Sublime,
 Atom, IntelliJ, VS Code even like Jupyter notebooks and you can use it together
 with classic completion engine so you can really get the best of both worlds.
 So whenever you see me code in a coding video look out for this TN marker next
 to the completions that's the completions by tab 9. It doesn't only work
 for Python it actually works for pretty much any programming language that isn't
 completely obscure. If you go to this link within 72 hours of when this video
 is released you'll get three months of tab 9 professional for free. The
 professional version removes the project size limit of the free version and it
 also gives you access to that sweet sweet cloud inference. After the three
 months you're automatically kicked out of the pro version there's no auto sign
 up there's really nothing to lose. I mean the only bad thing here is that tab 9
 itself is written in Rust. If that's the worst thing about an offer it's a
 pretty good deal. Again I use this myself and I'm pretty happy with it. So again if
 you sign up at tab9.com slash promotion slash yanaculture within 72 hours of
 when this video is released you'll get a free three months of tab 9 pro no strings
 attached and now enjoy the video. Thanks! Alright I hope that was fun let's get
 back to the paper let's get into the paper. So first of all what is my first
 criticism of this paper? This the title. There are some disturbing trends in the
 last few years in in in machine learning papers and the disturbing trends can be
 maybe encapsulated with the phrase is all you need. So people have sort of since
 attention is all you need since this paper people have discovered that if
 they just append this to whatever their paper is about then the paper will get
 much more notoriety. And the same thing I think is a bit at play here with this
 with the R because in recent times we've kind of seen a bunch of papers that show
 equivalences between models such as a famous example is that the transformers
 are Hopfield networks in some kind of in some regard and these papers are pretty
 cool right even if the two things are not exactly equal all the time if you
 can say look there is a setting there are you know under these assumptions
 under these settings in this situation these two models actually are the same
 that's a pretty cool recognition a pretty cool thing to show and it's very
 useful for academia and and practice I believe however I believe that our
 keyword that is keyword should be sort of reserved for when two things are
 equivalent whereas here in the very first at least they're honest right in
 the very first sentence they show they say well we show how to construct
 knowledge graphs from pre-trained language models so essentially they're
 going to use a language model to approximately construct a knowledge
 graph and they're also going to use a bunch of other auxiliary models that
 come all pre-trained but still they do not show an equivalence of language
 models and knowledge graphs in this paper not at all so I would sort of I
 see that you can get somewhere with these titles but yeah maybe people will
 be disappointed kind of if they read the paper which it is actually a cool paper
 believe me all right so as I said what we have usually is a corpus okay a
 corpus is simply a bunch of text pieces you can think of maybe just the text in
 Wikipedia okay here you know the this Wikipedia page about Bob Dylan Bob
 Dylan is a songwriter was awarded a Nobel Prize signed Alva Grossman these
 are easy sentences right there there can be sentences are usually larger and
 longer and so on and what you want to do is you want to extract a knowledge graph
 so the knowledge graph has two distinct things it has entities and one entity
 here would be kind of Bob Dylan songwriter is an entity Nobel Prize in
 it is an entity you can sort of think of them as nouns okay and then the second
 part in knowledge graphs are the relations here occupation sign award
 received and so on so that the relations connect two entities there is always
 what's called a head of an end of a of a triple so a head of a fact which in this
 case is Bob Dylan three times then there is a tail which is sort of like the
 object of the verb and then there is the relation which is described by the verb
 now here you can see there are two stages of constructing such a knowledge
 graph any system that does this probably goes through these two stages so first
 you extract a set of candidates which it's not the knowledge graph yet because
 these are still strings right you extract a bunch of string triplets as
 you can see here and as we said as the sentences get more complicated it gets
 more and more difficult to extract these kind of triples and then the second part
 is that you need to map it to a to a scheme to a to a schema and these
 schemas are usually defined by humans so here we're still going to rely on humans
 to define the schema top so there is one list that says entities and the entities
 there are just the entities are listed okay by the humans and at some point it
 says Bob Dylan Bob Dylan and it has a bunch of mentions of Bob Dylan associated
 with it and it has a clear ID in this case you see the ID is Q 392 in that
 knowledge graph and the system not only needs to extract these facts but then
 also map these facts to the correct entities sorry map these facts to the
 correct schema entries this second stage right here is a a bunch of standard
 tasks so especially mapping something like the the word Dylan in its context
 to this entity Bob Dylan which you can think of it as like the Wikipedia page
 of Bob Dylan right that's how the system usually work that is a task called
 entity linking okay entity linking and similar tasks exist for leak for sign
 like the relation awarded mapping this to award received to this so maybe there
 is some kind of dictionary entry award received and what it means and a bunch
 of examples and you're supposed to map this to that these are standard tasks
 and the system that we are going to look at right here is not not much
 concerned with these tasks it simply uses pre-existing methods to do these
 things so the system we're looking at today does this first part right here it
 takes text okay this is text and it comes up with these candidate facts
 about the text whether how this is then mapped to the schema that is a a
 different question and it's so there there are pretty cool things in this
 paper about this step but we're first going to look at the first step and
 then at the second step all right so how does this system do this and how does it
 do it that there have been machine learning models before but being machine
 learning they all have like some sort of a training corpus where you have kind of
 the facts as a training set and then you have a separate set of facts as a test
 set and you try to learn from the conjunction of the text and the training
 facts how to extract facts not this system this system simply uses a
 pre-trained language model so what's the reasoning the reasoning is the
 following we used to think that we could do NLP probably best with having a
 knowledge graph right with having this set of very structured data we can
 answer something like what's the what's the age of Barack Obama's wife and then
 you could go to the entity of Barack Obama you could look at the relation
 spouse you could go to Michelle Obama you could look up her birth date which
 would all be structured information in this graph so you could sort of answer
 questions like this and search engines like Google and so on they have this
 built-in so there is kind of a knowledge graph entry sometimes when you search
 an entity in Google that pops up and these have been very useful to answer
 questions like however in recent years language models have become better and
 better things like BERT or GPT-2 have become better than these expert systems
 let's call them at answering questions by the way if you want to if you want to
 hear a very very cool and solid argument of where these kind of expert systems
 where this kind of structured human annotated or maybe extracted information
 can still come in in natural language understanding I would recommend the
 machine learning Street talk episode we had with Wally Saba extremely interesting
 person and I had I just I can recommend listening to that this should be out any
 day now if it is not already so the language models have become better and
 better at these tasks without having this structured information so the
 hypothesis is maybe these language models can already contain the information
 that's necessary to construct these structured facts because the structured
 facts is what we you know let's say should use to answer these questions
 because we feel that structured information is better than unstructured
 the language models are pretty good at these tasks so maybe we can get the
 structured information out of the language models so that's what they do
 they say the contributions are as follows we show how to construct
 knowledge graphs from pre-trained language models the knowledge graphs are
 constructed with a single forward pass of the pre-trained language models
 without fine-tuning over the textual corpora I think this is the this is kind
 of a very strong point about this paper and it's also shows that if you're some
 PhD student somewhere and you don't necessarily have the resources to train
 the next GPT-3 model or fine-tune it there is still research to be done
 simply if you have enough resources to forward pass your data which is often
 much fewer than to train one you can still do very cool research I think this
 paper shows this explicitly okay this helps researchers explicitly understand
 what the language models learn bridging the deep language model and the
 knowledge graph communities through enhanced model transparency okay they
 say we propose an unsupervised two-stage approach MAMA which stands for
 match and map to first match the candidate facts in the corpora with the
 knowledge stored in language models that's the first step we looked at then
 map the matched candidates facts to both fixed and open schema to produce a
 knowledge graph and then they say they produce a new type of knowledge graph
 which simply is the the facts sometimes the facts they extract they can't really
 map to a schema entry and we're going to look at that because I think a bit
 critically of this they say namely the open knowledge graph consists of mapped
 facts in the fixed schema of existing knowledge graphs annotated by humans and
 the unmapped facts in the open schema that are new in the reference knowledge
 knowledge graph schema so what they claim here is that their system is finds
 these new relations that are don't even exist in the schema and is able to
 uncover kind of build new additional schema entries and they call this the
 open knowledge graph I'm a bit skeptical of this as we are going to see so the
 first step how do you come up if you have a sentence and this is it this is a
 very poor example I feel honestly to to do this it's I get it must be short but
 it's a poor example but stay with me so you have this sentence Dylan is a
 songwriter and you would like to extract a fact from this the paper is not
 really written clearly on how I mean it is I could you can parse it out but the
 description is kind of distributed so step one step one is run spacey run
 spacey this is a standard kind of library for NLP to extract noun phrases
 or they call them noun chunks okay so step one is not there's nothing to do
 with the language model it is simply you want to find the noun phrases in here
 the noun phrases are Dylan and songwriter now these noun phrases now
 define your head and your tail of the facts so you already have two things
 right so the the entire task of what of their method they're proposing is so the
 step one is run spacey to find the head and the tail of facts step two is
 question mark for now step three is going to be use the entity linking system
 and the relation linking system to construct the knowledge graph okay so
 step one is steel underpants and then step three is profit so what's step two
 step two is obviously step two is where their system comes in step two is here
 is the head and here is the tail in the text some hot wear in between there
 might be a relation and we need to figure out where that is right so how
 does this method figure it out so you already see the assumptions here are
 very very restrictive right so you use spacey to extract basically noun phrases
 which means you probably already going to miss a lot of things that are not
 recognized as noun phrase and they all they also say that that spacey's
 annotations are sometimes error prone and that's why they miss a lot of things
 and then secondly the assumption that the relation must be in between the two
 things textually now you can run the algorithm forward and backward but still
 it must be in between and it must sort of be encoded let's say as a semi
 accurate string in there I guess then that's up to the relation linker but
 already these assumptions are super constraining in the the kind of things
 you can find and you'll see in the experiments that their biggest flaws
 that they have a very very low recall I mean so do all the systems on the task
 apparently but they still have a very low recall and it's because they
 constrain their problems so much I'm going to guess if they wouldn't
 constrain their problems so much then they would have maybe a better recall
 but their precision would just plummet because these these things if you let
 them run wild they just over extract so basically every every set every verb in
 every sentence is going to be a relation right so like I ate a banana I ate
 banana would be a triple not necessarily a really valuable entry in any knowledge
 graph though banana has a lot of carbs so I would want to know about that okay
 so you see that the task is now reduced from building knowledge graphs to simply
 given a head head annotation had peace in the string span and a tail span
 extract any span in between the head and the tail that describes the relation
 between the head and the tail so the way this algorithm does it that's where it
 uses the language model okay so here it's going to do something that is going
 to be similar to dynamic programming if you've seen kind of the dynamic
 programming and search algorithms let's say you know string matching algorithms
 and so on this is going to be sort of similar in that what we're going to do
 we're going to start from here from the head in the string there could be text
 before it right we're simply going to locate the head Dylan right here and
 going to start then we're going to look at its attention matrix now the
 attention matrix is we're going to cross out here the attention matrix if you I've
 done many many videos on attention the attention matrix basically in a sequence
 means how much each token attends to each other token right how much
 information is kind of sent from each other token to this token right here so
 this up here would be be the query and these would be the keys the attention
 matrix specifies that so since we locate things between the head and the tail
 what we want to do is we want to cross out we want to disregard everything
 that's kind of behind the query and only look ahead in the sentence okay so
 that's why the sum of the attention matrix here is crossed out as you can
 see these are the X's this is exactly because we only search in one direction
 so from each from the token Dylan we can look at three things we can look at is a
 or songwriter and this the question is simply where do we go next with this
 algorithm right there's no interpretation yet it's simply where do
 we go next and the where do we go next is simply answered by just taking the
 highest scoring thing in that column of the attention matrix I look at the
 attention column where of the token Dylan I take the highest scoring one
 that's point three here is higher okay then I go to point three and that means
 is gets into my candidate fact okay and once I put ears into my candidate fact I
 then go to is so the next thing I do is I go to is and then I again look in the
 corresponding attention column and I see what's now the biggest entry here and
 the biggest entry is point four which is songwriter and you can see here now we
 skip the a that's how we leave out some text okay by skipping it basically so you
 can see that this this can create artifacts right this can create like
 kind of holes in the middle and so on but we skip a we go directly to the
 point four and then we discover up the point for that is our tail so now we put
 our tail into here and since our tail is the last word we can stop the algorithm
 I yes so there is no need to to go on even if there were text behind the tail
 as soon as we are at the tail which we already know right we're given the head
 and tail we stop all right so the we simply go forward with always the
 biggest entry in the attention matrix until we reach the tail that's the
 algorithm this this there it's described here but it's kind of described in this
 in this way where it has these actions like start yield and like this maybe I'm
 not understanding something but it seems completely unnecessary to kind of
 describe these actions and and it basically start the search from the head
 the head is added as the initial candidate and so on then in yield it
 sometimes says with the largest score from the attention matrix is appended to
 the end to yield the new candidate and so on but still and then stop we stop
 and the algorithm description here it basically just says while we're not done
 if we're if it's not the stop action we continue it's it's sort of it doesn't
 tell you anything like this is this is a super unclear description of this
 algorithm basically the whole logic that you would want to know about is here in
 this action manager right so the action manager that gives you the action is
 doing the actual logic of figuring out which token you know you should do next
 and where you should go next and so on this is nowhere in the algorithm the
 algorithm just describes beam search so you can do this a little yeah the little
 more sophistication that comes in is that you don't do this deterministically
 but you actually do it via beam search okay but you can you can just
 generalize this all right so the description is a bit floppy with the
 whole actions and action manager and whatnot and not describing the only
 thing they don't describe formally is how actually to select the next token
 which is basically the entire kind of meat of the algorithm in any case you
 might this is something that confuses me right here so fair enough you know they
 say here we take the attention matrix and we cross out these X's all right but
 they say they can take things up here right they can take things like Bert and
 you know as I said fair Bert has a full attention matrix everything attends to
 everything but they can also take things like GPT-2 now GPT-2 is an
 autoregressive language model that means that in GPT-2 if you look at it
 then you produce each token one after another which means that when you
 produce so each token when you train or when you evaluate even each token can
 only attend to the things in front of it right you see that the problem with what
 this thing requires of this is also the same okay let's do that you see the
 problem with this method this method is the exact opposite each token attention
 matrix is deleted such that only the entries ahead of it are in the attention
 matrix you don't actually get GPT-2 to give you an attention matrix that looks
 ahead because it only ever looks behind so maybe maybe what's happening is that
 the query and key matrices are switched up in some way in that case when we want
 to interpret the algorithm the way they write it down is if I am at a particular
 part of what I think is the relation between the two entities how am I going
 to find whether or not there is more to the relation right there could be a
 it could be a multi-word relation like has a child with or I don't know can't
 think of any multi-word relations or whether we kind of are done with the
 relation and go to the to the tail what this thing is saying is that we should
 look at the the language model so if if this is really how it is here and you
 are at the word is what you want to know if this is BERT if this is a BERT
 language model what you want to know is if I were to cross out is if I were to
 delete this word which other words in the sentence right here that are ahead
 of me are very very informative to predict this particular word and that's
 that's kind of the query style and you know if the answer turns out to be
 songwriter is quite important for that maybe Dylan is too but we only look
 ahead if it turns out a the word a is not as important as the word songwriter
 right because songwriter yeah it gives an indication that there should be is
 because songwriter is kind of a profession and there's a person in front
 of it we don't look at that but the attention matrix would would have that in
 mind if that's valid right so that's how this this construction is made however
 if this is the key we have to think of the other way around if we are at is we
 look ahead and say if I were to delete the word a could I reconstructed how
 well could I reconstruct it from this word is or if I delete songwriter how
 well could I reconstruct that from the word is I think both are you know there
 is interpretations probably for both of these methods but what I want kind of to
 convey is that none of these things are really amenable to constructing a
 knowledge graph it's it's quite interesting that this stuff actually
 works because all it asks is how well does one word inform about the presence
 or how well can one word predict another word and from that information we
 construct this knowledge graph which probably is a testament to the fact that
 knowledge graphs maybe aren't so much about knowledge if you extract them from
 a corpus but more about grammar I would think that's the thing that goes on here
 because these language models are a lot about grammar right a lot about how
 different words appear together frequently so given that songwriter is
 kind of a mix between grammar and basic word knowledge given that songwriter is
 kind of an object here the word is being the verb is probably quite important for
 it and that's exactly these these triples they always appear a bit like
 in of compressed sentences and which which are very grammatically relevant so
 I'm not buying these hypothesis that there is much knowledge in these
 language models and that's why this works what I much rather think is that
 they are really really really good at a kind of grammar and statistical
 association between words across the language and that's why they can extract
 these candidates facts so well okay so that's what I think about the algorithm
 they do constrain it some more as if it doesn't already have enough constraints
 but they all make sense okay so they say the matching degree which is simply the
 sum of all these attention matrix entries that we've encountered during
 our search so all the ones we didn't skip or to count it together or the
 matching degree of this triple the matching degree must be above some
 threshold that's the first constraint because so they give an example right
 here for the sentence rolling stone wrote no other pop song has so far only
 challenged artistic conventions and the extracted candidate fact is rolling
 stone wrote pop song again you can kind of see here it's mostly going in into
 into grammar ish so spacey extracts rolling stone and pop song and the
 language model here extracts like the only verb in between wrote so yeah to
 to limit to kind of limit the the to limit the matching degree to say it must
 be at minimum kind of some some number it makes a lot of sense because if the
 matching degree is high that means if we go by this attention matrix it means
 that these words that are in the candidate fact they kind of as themselves
 they follow from each other so the language model thinks that wrote is a
 very good follow to rolling stone and pop song is a very good follow for wrote
 or the other way around depending on which way the attention matrix is but
 that's kind of the language model thinks that that these words together make
 sense in the context of the sentence of course like in the context of this
 entire sentence so as I said it's sort of can think of it as a bit of a
 summarization paper but with more constraints constraint number two is
 that the frequency of R is above a threshold so the relation itself
 shouldn't be too specific it actually should appear a bunch of times in the
 corpus so what you do is you know you go through the corpus once extract all the
 facts my pen just dropped you extract all the facts or the all these candidates
 and then you you kind of count them and go through the candidate facts again and
 delete all the ones that are below a certain thing that's people usually do
 this with things like stop words or rare words and so on it's pretty standard
 makes a lot of sense and constraint number three relation or is a contiguous
 sequence in the sentence okay so you have an example here from the same
 Rolling Stone wrote challenged conventions which the language model
 would like to extract because again these in the context of that sentence
 these words sort of you know they jump to each other in the attention matrix
 because you can predict them from each other very well but they say this must
 be a contiguous sequence so what I said before I said this could happen with
 this constraint they excluded okay so for the second part where they actually
 have to map a candidate fact to a fact in the schema as I said they use kind of
 pre pre-made solutions entity linking and relation mapping with the schema I
 won't go into this except to say that whenever they find a match they say that
 this is a mapped fact whenever they don't find a match they say oh this is
 an unmapped fact okay an unmapped candidate means that at least one of H
 RNT is not mapped to the schema there are two types partially unmapped facts
 is where some are mapped and completely unmapped facts indicate that all H RNT
 are not mapped to the schema okay for example Jacob was a registered
 Mennonite now here they so they they say they have these different facts and you
 know it's a cool thing if a model like this can actually come up with new fact
 not so not only new mapped facts which is something you would expect right if
 humans provide some kind of a schema then build a knowledge graph this is
 never complete so if you can automatically kind of fill in missing
 facts that's very very cool though I would say humans if you construct
 knowledge graphs humans should probably also build kind of like negative
 connections saying like yes it is conceivable that Elvis was a vegan
 because a lot of texts talk about it but in fact it is explicitly not I don't
 think that's what we have in the knowledge graph so far but it would be
 cool if this model could fill in new facts yes to the schema it would also be
 cool if it could uncover completely new relations that haven't they hadn't been
 considered by the human makers of the knowledge graph like if the knowledge
 graph itself is incomplete the schema is a man you know same argument the schema
 is probably also incomplete this paper is sort of trying to sell their system
 as something that can do that and I believe that to a degree but also also
 Jacob was a registered Mennonite okay now maybe I'm completely wrong from the
 sentence Jacob was a registered Mennonite in Amsterdam I might be
 completely wrong but Mennonite is a religion I think and I'm very very sure
 that any of these knowledge graphs with the schemas that they have have being in
 a religion or being of a certain faith in their relations table somewhere and
 I'm also pretty sure that Mennonite large enough that that would actually
 appear as an entity maybe Jacob not right maybe Jacob is an unknown Jacob we
 don't know who Jacob is but this seems more like a failure of the entity linker
 and relation linker than an uncovered new relation or an uncovered new entity
 so yeah take this stuff with a grin now they they are very honest about this but
 just to say that that's probably what happens most often so here you can see
 the graph for Bob Dylan constructed from the Wikipedia pages that are kind of
 they say around the page of Bob Dylan so I guess one or two or three hops away
 something like this and you can see the blue stuff is stuff that we already knew
 so that the human humans also found when looking at this then yellow stuff I
 believe is either new relations so whenever things are annotated it's a new
 relation in the schema so you can see this is an entity in the schema because
 it's annotated this is a relation in the schema but the arrow is new so the
 humans hadn't yet extracted the fact that Bob Dylan was or was a member of
 artists united against apartheid then the yellow also sometimes means that
 there is a new thing so here tour with is a relation that's extracted that is
 not in the knowledge graph yet also this one and you can it's pretty it's pretty
 cool right that you can extract these things automatically there's a lot of
 yellow stuff here which means there is not a lot of new information that this
 extracted and a lot of this new information is actually mapped to the
 schema right Bob Dylan residents in Duluth I don't know how to pronounce
 that by the way yes so so that's that's fairly fairly cool they do some of these
 tasks of these knowledge-based tasks in these tasks what you'd have I believe
 what you'd have is always you'd have like a head and a relation given so you
 have a document and you are given a head and a relation and you're asked what's
 the tail of this and then you ask the system and the system will tell you so
 you have these baselines and these baselines I believe they are specifically
 made to extract these knowledge representations they might even be
 trained I don't I don't know that but you can see that the MAMA even the even
 the smallest one here beats those by quite a bit now you can see that the
 recall is significantly lower than the precision which is a direct result of
 how many constraints on the system there are and tells you sort of what the going
 forward what the improvements can be so they analyze a lot of this and yeah so
 a first recognition is that larger and deeper language models produce knowledge
 graphs of higher quality BERT language models outperform GPT-2 language
 models under similar model sizes which is interesting is scalable to larger
 corpora which again as we said you don't need to train it and larger corpora
 embed more complete knowledge graphs which is something we would expect the
 other interesting part is the unmapped fact so the numbers you can actually
 compute only for the mapped facts right because that's where you have data
 humans produce the knowledge graphs from this that's what you can compare with
 now the unmapped facts they say they analyze we turn to study the quality of
 the candidate facts that are not mapped to the above reference knowledge graph
 schema but are in the open schema generated by MAMA that's mama we
 manually judge such unmapped facts generated by our best method from 100
 sample documents in wikidata and TAC KBP respectively so they they go as
 researchers they look at these things and they judge them whether or not
 they're true given these documents in Wikipedia they say the quality of
 unmapped facts is very for that so that the claim is that they've looked at them
 and they are good we find that 35.3% of the unmapped facts are true on wikidata
 we find that 83.2% of those true facts are partially unmapped facts for
 example Bob Dylan tour with the Grateful Dead and yeah here is an if this really
 isn't in the schema right this is a nice relation that you might think humans
 would miss because touring with someone is not the first thing that would come
 to mind if you had to come up with a bunch of relations between entities but
 it is something that is regularly useful regularly used for musicians so that is
 an application where certainly an automated system can even extend the
 schema right whose relation is not within the scheme of wikidata well both head
 and tail are in the schema the register the remaining true facts are completely
 unmapped facts for example this red Jacob was a registered men and I and they
 also say accurate entity detection is desired where they say a lot of the
 errors are due to spacey detecting wrong incorrect entities or due to incorrect
 or missing entity linking by the by that those systems the rest errors made by
 mama are incorrect relation phrases such as uninformative relation phrases for
 example Bob Dylan made and his breakthrough oh what can you do what
 other what other one what other verb would you put there yeah but okay we're
 going to look at a few last things right here they have a bunch of a bunch of
 experiments right here which where they show you know the beam size has an
 influence this constraint number one and number two that we looked at has an
 influence right so you can tune these things a bit what is interesting here is
 that they try they try to look at either the attention matrix of the last or of
 all the layers and interestingly the system performs better if you only look
 at the attention matrix in the last layer now they reduce that attention
 layer because there are multiple heads using max or mean and see they perform
 similarly but it is interesting that only the last and they argue they argue
 in the text that we know that the last layers kind of have higher level
 features than the lower layers but I recall there are multiple papers like
 I've done videos about them what does Bert learn and so on I think even
 something in constraint in conjunction with lottery tickets and so on that show
 that in a transformer at least I think it is the middle layers that encode the
 most kind of semantic knowledge because the lower ones yes they are for kind of
 low-level features but the upper ones they are again for low-level features
 because the task right here at the end is to predict an individual word or
 token right so you'd expect that the features in the attention matrix there
 are go back to kind of sort of more grammatical features and so on and that
 the highest level features are actually somewhere in the middle I don't know if
 they tested if they only tested like all versus last in which case yeah I
 believe that but if they tested each one individually and it still turned out
 that last is the best that would kind of add to my hypothesis that what happens
 here is more kind of a grammatical effect of extracting the this correct
 candidate candidate verb in between the head and the tail all right so that's
 that's kind of kind of gives more weight to my hypothesis like so to repeat my
 hypothesis is that it's kind of a grammatical thing that's going on here
 because the only task of this model is basically to find the correct string
 span for the relation between head and tail because it's already given head and
 tail and there from the text their hypothesis is more like we the language
 models have a lot of knowledge built into them and we can extract that
 knowledge kind of it they make it sound like then the language model has this
 semantic knowledge in them okay okay so so let's look at a bunch of mapped facts
 right here you can okay you can maybe check out a lot of them yourself but
 we'll just look at like one in each category blah blah mail yada yada yada
 yada is in worse shape however a Klaus told press conference at the Western
 city of Essen where the other yada yada and it extracts this company and it maps
 it to the city of headquarters maybe they leave out some text here what I
 want to get to is the unmapped facts where are the unmapped mapped facts to
 just kind of show you mapped facts unmapped facts okay so the unmapped
 facts what I feel and you can judge for yourself please what I feel just to
 pre-bias you before we look at them is that a lot of times simply it extracts
 things that are that are it extracts things that are not it simply can't
 can't assign things right it's a failure to assign it's not a new thing because
 in these schemas like you haven't seen the schemas but you kind of get a feel
 the last which is the last table you kind of get a feel of what contains in
 it so maybe get a feel for for what okay
 Ernst Heckel was born 16th of February 1834 in Potsdam okay so the extracted
 thing is heckle was born on 17th of February 83 in Potsdam okay so that
 it maps to this is in the knowledge base a schema this is in the schema but was
 born on 17th of February 1833 in is simply a failure of the relation linker
 okay he was also a pacifist until the First World War yada yada yada then
 Ernst Heckel and then was on a and a pacifist are both not in the schema now
 maybe pacifism isn't in the schema maybe maybe though I would guess pacifism has
 a Wikipedia page so it must be in the schema because it's a wiki data but was
 as you know the relation here with something be like a political leaning or
 something like this which is certainly certainly in the knowledge base right
 then you have things like heckle was awarded the title of excellency so you
 have correctly heckle again recognized award received is in the schema nice
 excellency as a tail and excellency you know what what do you want like this is
 this is a this is not a fact right this is the award or the title of excellency
 would be kind of the thing so this is a failure of spacey so again I have I've
 seen little facts here that would actually be of genuine a genuine addition
 to the schema that should be considered and I absolutely believe that the schema
 is incomplete don't get me wrong I like a 100% the schema is probably less than
 1% of what it should be right if we did a thorough job I just don't think that
 this system here is a good like I think that the things that this system comes
 up with mostly are simply failures of its subsystems rather than genuinely new
 entries to the schema that's different from when it genuinely discovered when it
 discovers a new mapping between already established things for example Pauline
 Baines educated at this college right so these are new facts all fit in the
 schema and the system might be very very nice for that all right so that was my
 kind of estimation of this paper I hope I didn't rag on it too much as I said
 it's it's very cool work actually I look at this appendix is giant go look at it
 check it out please tell me what you think about it in the comments any
 feedback is welcome and I will see you next time bye bye