Transcript
0:00 Stanford University. >> So we are now heading to the crucial end phase of the semester, so I guess we're now at the start of week nine. So first of all if I just do sort of reminders. Obviously everyone should keep working on their final projects- assignment 4s. A couple of just notes on that.
0:31 So on Thursday we're just going to talk about dynamic memory networks. While they are only one of several ways that you could go about approaching assignment 4. They'll certainly be relevant material if you are doing assignment 4 because, it's an instance of the kind of architectures of sort of attention based architectures that people can use for tasks like the reading comprehension question/answering, like the squad data sets, so watch out for that. We've been trying to keep money in people's Azure accounts, actually a Microsoft rep Kristine is here right now if you need to pester her.
1:09 Pester her about any problems, and you're certainly contact us on Piazza if they're any issues, and we've been trying to be proactive at keeping things restocked. I know it's slightly frustrating if you go out of money and it then locks you out and we need to reset it, but we're doing our best. Okay, and it's great that there are now lots of people that are clearly very actively using it and doing stuff. And that's super, we are very pleased to see that all happening.
1:39 Okay, then for assignment four, so for the assignment four submissions, we're doing submissions on CodaLab, which is conveniently tied right into Azure as well. And so for assignment four we've set up a leaderboard, at least when I looked this morning it only had one submission from Chris, and the people who set up the leaderboard. And they were only getting 2% on squad, so if you can get higher than 2% on squad at least temporarily you could be top of the leaderboard.
2:12 And so I hope people can try that out. And so, a couple of Percy Liang's RAs have been very actively working at helping us out of doing this CodaLab-Azure integration for using an assignment four. So big thank you to Percy and his RAs. And so, they've also made a couple of videos on how to use CodaLab that there's short videos.
2:43 There was an announcement about it on Piazza, so have a look about those. Okay so, then moving right along for today's lecture, so for today's lecture, I'm gonna talk about coreference. So when we did the mid quarter survey, one of the things that a whole bunch of people complained about was that, we actually weren't doing much linguistics and natural language content in this class. So today, it's getting a little bit late since it's the start of week nine.
3:15 I've actually got a try to have some more linguistic content in the first half before going back to deep learning models for the same. I think that sort of comment in the mid-quarter evaluations was completely fair because the reality was in the first half of the class. It really was sort of just about all deep learning models all the time. I mean, I'm not sure I've yet worked out the perfect solution to that because the fact of the matter was we kind of felt when organizing the class.
3:46 That we were sort of on this treadmill where we had to get through more stuff in time for our next assignment. And so that is what it is, but over the last couple of weeks, we'll try and have a bit more NLP content as we go along, Coreference Resolution is an instance of a task. And it's really the only one that we're going to look at in any depth here. Where we're working on a larger level of a text so that we're not longer just trying to look at an individual sentence and say, what's the subject and the object and parsing or is this a company name.
4:25 Where we're trying to make sense of a bigger text and work out what's going on about that. And it's not the entirety of understanding long text but it's sort of one of the most prominent things you need to do as you go along. So when we're doing coreference resolution, the first thing that we're doing is working out all the mentions in the piece of text so that pieces of text, basically noun phrases that refer to some entity in the world.
4:56 And then once we've got those, we're trying to find the ones that refer to the same real world entity that co-refers. So there's one set them here which co-refer in this example to Barack Obama and then there's another set, which are these ones here, and they're the ones that co-refer to Hillary Clinton. Okay so that's our task of coreference resolution, and so I thought next we could just go through, really get a sense of what goes on in coreference resolution, of go through an example text.
5:32 And this is where I signal to these guys here to flip me over to my other screen. Look at that! Okay, so here's our example text done, this is from a short story, story by Shruthi Rao called, The Star. Now, I have to admit, since this isn't a literature class, I actually made some little cuts and edits to this story so I could more easily fit it in a larger font size on my slide. So the text is slightly mangled but it's basically part of the story, so what have we got here when we do this, right?
6:07 So first of all, we have the named entities, which is precisely what you were finding in assignment three, right? So we have Vanaja, and Akhila, and there's Akhila, and there's Prajwal, Akash, Lord Krishna, He is a named entity, Akash. So we've got all of those, but then we have a lot of other kinds of phrases that refer in the text.
6:41 And the second prominent category is that we have pronouns. So there's they and there's she. There's this one thats a pronoun, that's kind of a special pronoun, herself. And there's she and him. And she, she, it, it. then I admit, I noticed I missed at least one of the named entities, there's another named entity.
7:16 And there are probably other things I've missed, so you can tell me what I've missed. Okay, so those are both prominent categories, but that's not all there is, there's really a third category. Which are then things that are mentions but are done with common nouns so that they're neither pronouns or named entities. So that's something like the local park, well, there's her son is such an example, the same school, the preschool play.
7:50 So there's sort of, you get an interesting thing is you get embedded ones. So the preschool play is in reference of a mention of an entity, but inside that there's the preschool, which is another mention of an entity. Okay so there is the naughty child, a tree, the best tree, a brown T-shirt, brown trousers, the tree trunk, a large cardboard cut out.
8:30 Okay, then there is a circular opening, there are red balls. So they are those ones and then there are some other things that are common noun phrases and it's not quite so clear whether they're actually mentions of anything in the world. So there's a couple of years. Is that a mention of anything in the world? Not quite so clear. And then there's this, a tree's foliage which doesn't really seem like it's referring to anything concrete in the world.
9:05 So there are various complicated cases like that. And in particular, there's another one of those more complicated cases at the end, which I'll maybe come back to later, this, the nicest tree. Okay, but somehow we work out what all our mentions are. And then, the task we want to do is to start to then work out which ones corefer. For a start, there's then Vanaja here.
9:38 Then, what's the next thing that refers to Vanaja? Her, yes. So this is her, which I guess I forgot to mark when I was marking the pronouns. So embedded in the MP, her son, so again, you can get mentions and side mentions, there's that her.
10:10 Is there anything else that is coreferent? She, okay, so there's that she there. And then the next one is, herself. Right, and so here we have these reflexive pronouns. And so reflexive pronouns are kind of special because they always corefer very closely back to each other as in that example, she resigned herself.
10:41 Okay, so there's she again. Then she made, she attached. So that goes right through. Ok, so then we have. Now we have Akhila, which is Akhila. Sometimes you just get names being repeated as names. Are there other things that corefer with Akhila?
11:24 Maybe not. Note that this is kind of part of how it's tricky, right? Because well here at the beginning, we have the names of two women. Akhila's name is actually repeated in the second sentence. But somehow we have to understand enough of the text beyond that to understand that all these other references to a she and a her aren't referring to Akhila at all, they're all referring to Vanaja. So we have these two entity chains, and then we have some more entity chains.
12:00 So if we go to the next one, the local park, that one is just a singleton. Nothing else refers, I believe, to the local parks. There's something for a lot of background mentions, things have just been mentioned once and never repeated. And so then we have Prajwal, who sort of appears twice here. Like, there's Akhila's son which is sort of a descriptive term and then his name, Prajwal, so that's generally referred to as apposition.
12:33 So we get two mentions of him right there. And then where else is Prajwal appearing? Well, one's his name is right here. Are there other places that Prajwal appears? Okay, so here's a complicated one. There is this they which refers to two people, right? That refers to Prajwal and Akash. So that's a phenomenon, maybe I'll start putting Akash in as well. So we have this phenomenon here of when you have split antecedents.
13:08 So you can have a plural they that's referring back to two things that are disassociated with each other, they're just discontinuous in different places. When we start looking at co-ref algorithms that NLP people use a bit later, one of the embarrassing things that you will notice is that the standard algorithms that we use just can't handle this kind of split antecedents. That you're looking at a mention and you're trying to decide what to make it coreferent to, and you just can't get ones like that right.
13:42 So that's a bit of embarrassing but that's the current state of natural language processing. What else is coreferent to Prajwal? Okay, we'll go on. So Akash appears a lot. We have Akash, Akash, him, Akash.
14:19 Okay so, he goes through all the tree. So what other entities are there that occur multiple times here? The tree, okay. If you think about it, there's definitely here a tree, but if you think about it which of these things count as mentions in the real world, and which one do you want to deem this coreferent, is actually tricky.
14:57 If you just half look at it, you just think, okay, anytime I see the word tree in a noun phrase, I'm just gonna say all of those coreferent with each other, but that doesn't actually seem to be right. Cuz when it was here, Akash was to be a tree, that's not talking about any specific tree that's referred in the world, that's some intentional description. She resigned herself to make Akash the best tree that anybody had ever seen.
15:30 Again, that doesn't seem to be referring to any particular tree that's extant at any time, that's some kind of descriptive text. On the other hand, when it's gone down to she bought him a brown T-shirt and brown trousers to represent the tree, this is now, it's an abstract tree costume obviously. But that actually seems to be a real tree that's a thing in the will that you can point at. So, that's a real thing and then, well what about when it says a tree's foliage?
16:02 Is that referring to that tree that she's building? Kind of a little bit unclear. But by the time it says, she attached red balls to it. That's clearly a reference to the tree that she's making and it's a good clear one. But then the last sentence says, it truly was the nicest tree. So for that one, the it is clearly again, referring to the tree that she's constructed.
16:36 So that one is clear. The question is what to do about the nicest tree. And, to be honest, if like for various other NLP tasks for co-reference resolution, people have constructed data sets where people have essentially done what I'm trying to do live in front of you as to identify mentions and then say which one's a co-reference. And so what we have here for something like it truly was the nicest tree.
17:07 The nicest tree is referred to as a predicate nominal. So it's something in the form of a noun phrase, but it's actually a property that is being predicated of the subject. It is the nicest tree. And so some of the data sets that people use for co-reference, they declare predicate nominals like this to be co-referent to the subject and therefore it would be purple. But there's kind of an argument that that's actually just wrong and the predicate nominal is actually kind of a descriptive property of the nicest tree and it's not actually referent to anything.
17:43 And so then it wouldn't be what you're wanting to do. But I'll leave my purple there for the moment, okay. Are there any other interesting things I should comment on? There's obviously more things that we haven't done yet. I could choose a different color. So there's, Yeah, so I mean, there are obviously lot's of other things that are mentioned that aren't in change, right?
18:29 So something like Akash's face is a mention that's a singular mention. There's a circular opening I guess that's kind of an interesting one cuz it seems like that is an entity in the real world. But it's an entity that's a hole in the world as opposed to a thing that's in the world. So there are lots of real world complications as to how things pan out in co-reference, but that's sort of an idea of that task and the problems.
18:55 Does that make sense? Okay, I will go on from there by sending back my person, awesome. Okay, right, so what we've seen from that is basically what we're working with is the noun phrases. Most of them refer to entities in the world. There are many of them that in pairs refer to the same entity of the world and they're the ones we're gonna call co-referent.
19:28 And then the other interesting thing that's different to what we tried to do with named identity recognition is that there are lots of cases in which you get nesting, right? So when you have CFO of Prime Corp, that Prime Corp is a mention, but CFO of Prime Corp is also a mention. His pay is a mention, but the his inside is also a mention. And we've got another one there. So you got lots of these nested examples.
19:58 I mean, in truth you'd get the same thing happening also in named identity recognition. And some people, including a former student of mine, Jennie Finkle, actually looked at that. Because there are a whole bunch of cases that also in sort of names of things, when you have something like Palo Alto Utility Company, that you have the organization, which is Palo Alto Utility Company. And inside that you have a location, that's Palo Alto. Though in general, in NER, people just do it flat, and you kind of lose those embedded locations.
20:33 But if you're wanting to follow along co-reference links like John Smith, and his pay, that you're sort of really losing a lot in your ability to interpret texts if you aren't dealing with those embedded mentions. And so normally, people do. So co-reference resolution is a really key task. It's used in all sorts of places. Essentially, anywhere where you want to do a fuller job of text understanding, you need to have co-reference. So if you want to sort of understand a story, like the story of the star, where you definitely need to be able to follow along the co-reference.
21:09 It helps in lots of other tasks. So if you wanna do machine translation, if you're doing machine translation from one of the many languages like Turkish that don't distinguish gender in pronouns. And you want to then translate into say, English and it does have gender. Then what you need to do is follow along the co-reference chains to be work out which ones should be he and which ones should be she. It's been observed and complained about by a number of people recently that current MT systems don't do that.
21:44 If you take Turkish and you translate into English, everything comes out male, sorry. That's a state of NLP on that. So text summarization, including things like web snippets right, if you're trying to cut out sort of a little snippet to put on web results. And it contains a pronoun in it, it would be much cleverer if you could replace it with its reference so its interpretable. And then also tasks like information extraction, relation extraction, question answering.
22:14 This doesn't apply to the squad task the way it's formulated, but a lot of the time we have questions like, who married Claudia Ross in 1971? And you start searching the text for the answer to that question. And you say, yeah, I found the right place to look. Here's the sentence. He married Claudia Ross in 1971. And you're sure you've got the answer if only you could work out what he was co-referent to and that's why you need co-reference resolution.
22:44 So when we've made all of these attempts to link things together, I'll just explain now how we go about evaluating co-reference resolution. So effectively co-referenced scoring it's kind of like clustering. And basically any metric that people have used for cluster evaluation, people have also tried to use the co-reference resolution. And so the one that we're gonna emphasis in today's lecture is one called B cubed, which is one of the widely used clustering evaluation metrics.
23:15 So what you have here I mean, I've sort of just duplicated on both sides. So I can show you precision, recall, is so the colors of my little balls are the gold answers of what's correct. And then the circles that I've drawn around it is how my system has decided to gather things that it thinks its co-reference. And so what you do for the B cubed metric is you sort of align system clusters and the gold clusters.
23:48 So I've chosen to align this system cluster with the blue color here, which I've shown by that black around the circle. And then I say, okay, well of the things that I put in my system cluster, what is the precision of what I put in there? And well, it turns out that four out of the five of them are blue and one of them is pink. And so I say my precision is 4 5ths For this cluster.
24:15 Then I do it the other way around, and I work out a recall. So I say, well, I aligned the blue things with this system cluster. And, well, actually, this system cluster only contains four out of the six blue things. So my recall for that alignment is then four-sixths or two-thirds. And I'm gonna put those together in an F measure and that's then going to give me the B cubed measure. And so that's sort of the main idea.
24:46 It's just a little bit more complex than that. I mean, first of all, obviously I want to do it not only with that cluster. I also want to align this cluster with the oranges and say they're precision recall one, cuz they're completely correct. And this cluster and the pinks, and then I wanna say precision, four sixths and recall, four fifths.
25:16 So there are a couple of other tricks. One is that you're weighting the different precisions and recalls based on the size of the clusters. So, it matters more to get high precision on really big clusters. The other bit that I sort of slightly glossed over is I said, well, you align these system found clusters with a gold cluster. And as you might know from some other class, in the general case if you're doing a bipartite alignment, or things of that sort, that's actually an NP-hard problem.
25:56 So it's sort of almost impossible to guarantee that you've found the optimal B-CUBED score. So normally, what you're actually finding in your system is sort of a lower bound on a possible B-CUBED score. But in practice, provided your system is reasonably good, it's fairly easy and a greedy manner to start aligning together system clusters and gold clusters, starting with the ones that you did best. And in practice, there's greedy matching software that's used for B-CUBED, which seems to nearly always work and give you the right answer.
26:32 And so that hasn't been a huge problem in practice. That's only one measure that's been used for coreference. There are a whole bunch of other ones that have been used. Most of which relate to clustering algorithms, evaluations that people have used elsewhere. Okay, so before getting to the halfway point, I then want to say just a little bit more about what goes on in coreference from sort of a linguistic point of view. And this is actually a little bit interesting and hasn't actually been much dealt with by NLP systems.
27:06 So what kinds of things do we have? So we have referring expressions, so things that directly refer, like John Smith, as named entities or the President as common nouns. We then have things that aren't directly referring, but or sort of variables that are contingent on something else. And there ones that are free variables. So his pay, that's sort of a free variable, but it's reference is dependent on the reference of Smith. And then we have these reflexives, the bound variables which are sort of closely connected with something nearby.
27:42 And so in linguistic theory most of the work is dealt with these variables and trying to interpret what they are going to be coreferent with. Whereas, in doing practical coreference of a real text, there's quite a lot of pronouns. But a lot of the actions was actually dealing with these proper noun and common noun referring expressions. And it turns out in practice, getting these guys right is actually harder than getting these guys right, which is sort of interesting.
28:15 So things to notice. Not all noun phrases are referring. So, if we have every dancer twisted her knee, her knee does not refer to anything because it's sort of embedded under this quantifier of every dancer. That's perhaps more clearly seen if you look at the second example. No dancer twisted her knee. There's no her knee being talked about, right? So that's a clearly non-referring noun phrase. Okay, and similarly, no dancer isn't a noun phrase that refers to any dancer either.
28:51 So in linguistics, people normally distinguish two relations. So one of them is coreference, which is when two mentions refer to the same entity in the world. And that has nothing to do with the structure of text. And the other one is a relation of anaphora, which is a textual relation when a term, the anaphor, refer gains reference with respect to another term, the antecedent.
29:23 So you're using it for its interpretation. So if you go back to Greek roots, an anaphor meant that you had this word whose interpretation was dependent on something that preceded it in the text. And so anaphora was distinguished from the opposite relationship, which was called Cataphora, where you actually had a dependent term that was dependent on something after it in the text. So here's a lovely example of Cataphora from Oscar Wilde.
29:56 From the corner of the divan of Persian saddle-bags on which he was lying, smoking, as was his custom, innumerable cigarettes. Lord Henry Wotton cold just catch the gleam of the honey-sweet and honey-colored blossoms of a laburnum. This is a Laburnum, in case you were wondering. >> >> So this is a beautiful example of cataphora, because the referential noun phrase is Lord Henry Wotton. And then both he and his then cataphors on the following Lord Henry Wotton.
30:31 Again, it turns out in nearly all of our NLP systems, we never try and do this. So we're always coming across mentions and then we're trying to assign them to something before them. So we always treat them as backward looking anaphora. So we'd be actually hoping to say this he doesn't refer to anything before it. And then we'd be, later on, saying Lord Henry Wotton is coreferent with the he.
31:02 But that's actually sort of linguistically bad and doesn't make terribly much sense. So a lot of the time, things that are anaphoric are coreferencial because the textural dependence is one of identity. So an anaphor is coreferencial with its antecedent. But that's not always true, either. So you have things, anaphoric relations that aren't identity relationships and then they're not coreferential.
31:33 And so here's an example of this. We went to see a concert last night. The tickets were really expensive. So the tickets here is an anaphor that's dependent on reference to this antecedent. Because it's meaning that the tickets for the concert were really expensive. But it's not an identity relationship, so those are referred to as bridging anaphors. And there's been a little NLP work on trying to interpret bridging anaphors, but extremely little.
32:03 For most of the coreference systems, a concert is a mention of an entity. The tickets are a mention of an entity. And you just don't learn the relationship between them. Okay, so there are really kind of two different things. So you can have anaphoric relationships in the text which may or may not imply (co)reference, 90% of the time they do but not always, and then you have (co)referential relationships with two things in the text referred to the same thing in the world.
32:35 But that may just be because they refer to the same thing in the world. There isn't necessarily any textual dependence relationship between them, and so something that you might like to think about is maybe those two phenomenas should actually be handled somewhat differently in our models, and the truth is for most of the models we build at the moment they're really not handled differently. You could hope if you crossed your fingers really hard, that somehow the way our neural network model works will end up treating the pronouns, which are normally anaphors, sort of differently to the way it's treating You know the various mentions of a cache which were just (co)reference relationships but you know sort of a crush your fingers really hard there's nothing really that model structure that's sort of really distinguishing these two notions.
33:26 Okay, so on the second half of getting to say how we build (co)reference systems but before we do that we're onto the research highlight and James is going to talk about that. So, hello everyone. Today's research highlight will be summarizing source code using a neural attention model. This paper was published in ACL 2016, and its by authors from University of Washington, Computer Science and Engineering Department. So the main task in a dataset that they define is to generate sentences that describe C# and SQL queries, and they use a dataset from StackOverflow.
34:06 Essentially, what they do is they just query the whole dataset for all the posts that have tags that have C#, SQL or Database, or Oracle in them. Well, as you would expect, just doing this naively doesn't work very well because there's lots and lots of noise in the dataset. So one of the cleaning sets that they do beforehand is to remove all the posts where the question and the text doesn't actually have any relevance with the content of the code.
34:29 For example like people often ask questions about codes such as like how can I make these code run faster and in that sense that won't be a very good summary at all. A second thing that they do in order to, a more technical thing that they do is they actually try to parse the code in the sense that like a lot of code contains like literals, they have specific variable names Things like this, which are not very general, like general systems, to try to summarize code, and what they do in this case is they actually replace literals with their types.
34:56 They also replace the table and column names with something more generic, and then they also remove in-line comments in order to make the system less reliant on those things. And two examples of the code are shown on the side, where one is C# code for getting the whiff of a text block in some view, I think, and the second is source code for SQL where you're trying to get the second largest element. Okay. And specifically, like they define two tasks that they're actually going to try to attempt, and these are to generate text, specifically a sentence to describe some code sequence that maximizes a scoring function.
35:34 A second task is the information retrieval task, which is to go through, essentially their corpus, and find the code snippet that most closely relates to the input question, which would in a natural language. The scoring function is shown to the side. It's essentially the product of the next word probabilities, and these are proportional to what the output that we get from their model, which takes into account the hidden states of the LSTM and also some attention on the source code.
36:04 Specifically, here's an example of how they generate their text using their model which they call CODE-NN. You feed in some starting token and then you make some form of prediction based on the attention and based on the LSTM to get on the next word, N1, and then you keep doing this iteratively again and again, and this is how they generate their full sequence. So to evaluate their system, they did, first on the text generation side they compared against, well they used existing MT metrics such as METEOR and BLEU, and they took some existing translation system and information retrieval baseline system called Moses which is a phrase based translations system and then on a previous model that also know that and they found that their models get higher scores on essentially METEOR and BLEU and then they also did something that's a user study, where they got five people, and they had them rank the result.
37:01 Like manually score the results, in terms of naturalness, which is how well does the sentence actually read, in terms of fluency and informativeness. In terms of how much of the content of the code was actually captured by the summary, and they found that their model unsurprisingly does better than existing approaches. And then their information retrieval task they use a metric called Mean Reciprocal Rank, and they compared against some existing previous papers and existing baseline out there.
37:32 So what's more interesting is the actual example outputs that the model generates. Here's an example of a C# code which is to add children to some tree node, and in particular, this is C#, so treenode is actually part of a TreeView, and in this case, CODE-NN actually gets pretty close, where they recognize that these tree nodes are related to tree views but it doesn't quite get the idea that you're trying to add instead of get them all.
38:02 On the second example where the CODE-NN actually got the right result is this query where we're trying to select random rows from a table and CODE-NN actually get's it exactly. Cool, and that's all. >> >> Okay, so now for the remaining 40 minutes, it's now algorithms to try and do (co)reference resolution, and so I guess for about the first 15 minutes, I'm gonna sort of say something about sort of the history of ways of doing (co)reference resolution, anaphora resolution in general, and just the sort of space and traditional methods.
38:48 And then sort of for the last 25 minutes I'm gonna talk about one particular way of doing it which is actually from a paper that Kevin Clark did. The most famous thing in the space of (co)reference resolution, actually just an algorithm for determining the pronominal anaphora resolution, working out. What, you know, he, him, she, hers, its, refer to is an algorithm that was proposed by a long time ago by Jerry Hobbs, which these days is normally referred to as the Hobbs' Algorithm.
39:26 But actually in Jerry Hobbs' paper he refers to as the naive algorithm for a reason that I will explain in a minute. And so this algorithm, I'm not gonna read through it, it's a complex mechanistic procedure for deciding what a pronoun refers to. So you begin at the noun phrase, so it's assuming a syntactic pass of the sentence, begin at the noun phrase immediately above the pronoun. Go up the tree to the first NP or S.
39:55 Call this X, and the path p. Traverse all branches below X, to the left, blah, blah, blah, and this is in all of it. It keeps on going on the next page, and it's got go-tos, go to step 4. So, the sort of embarrassing thing is that, not in the system I'm gonna present at the end part of class. But if you look at the sort of machine learning approaches to co-reference resolution that were done in the 2000s and the first half of the 2010s, nearly all of them used this algorithm as a feature.
40:37 So if you had a regular statistical classifier, you can take any kind of little sub routine and sort of put its judgment in as a feature, into your logistic regression. And it turned out that what this calculated was sort of a useful enough approximation to getting out most likely anaphoric relationships out of syntactic trees. That most machine learning systems use this and got value out of that as a feature. So here's the kind of idea of how it was meant to work.
41:07 So "Niall Ferguson is a prolific well-paid and a snappy dresser. Stephen Moss hated him." Okay, so here's a him and you're wanting to work out what that's co-referent to. And so you start at this noun phrase here. And so what it said was that you started from this noun phrase and you went up to the next S or NP and you called that X, and the path that you'd gone up p.
41:39 And then it says, traverse branches below X to the left of p, propose as antecedent any NP that has an NP or S between it and X. So I traverse things to the left and I can find here a noun phrase. But that doesn't have anything else in between that and so, therefore, it's not a candidate. And so, at that point, I'm going to be at the highest S in the sentence and I'm gonna traverse the parse trees of the previous sentences in the order of recency.
42:20 And I traverse each tree left-to-right, breadth first. So there's a lot of stuff embedded in this very complex mechanistic procedure. But most of it is sort of correct, and gets first order linguistics right. And so what's going on here? So what's going on here? So when we see him, the first thing to suspect is maybe it refers to something to the left in this same sentence. But that's where the kind of linguistic constraints on pronouns come in, right?
42:53 So that if Stephen Moss referred to him, he couldn't of said him, he would of needed to say himself, right, you have to use a reflexive there. So that's why it says, unless there's some intervening NP or S in between, it's not a candidate anymore. But precisely, if there was a more complex sentence structure, it would be a candidate. So if you had something like a more complex noun phrase in which Stephen Moss was a modifier, then co-reference would become possible.
43:28 So if it was something like, Stephen Moss' brother hated him, then it'd be possible for him to refer to Stephen Moss, right? And so that will be captured because then there would an extra NP node in between here then it would be okay. So that didn't work and so we went backwards and so then again now instead of using software heuristics. So the heuristics are usually right, it said to go backwards to sentences and order of recency.
43:57 So if the antecedent isn't in the current sentence, it's mostly in the immediately preceding sentence, so you look there first. And then it says, within the sentence, go from left to right. Well, what's going on there? There's sort of an obliqueness hierarchy in sentences. And actually within a sentence, a subject, which at least in English is on the left side, is more likely to be the antecedent than something that's an object or an indirect object or object of a preposition that's buried down here.
44:27 So it's saying the first thing you should try is Niall Ferguson and so that's then a candidate. It doesn't get disqualified on page two from reasons of gender or anything like that. And so we propose it as an answer and the Hobbs Algorithm gets it right. And so the Hobbs Algorithm gets the right answer for pronouns about 80% of the time, it's actually pretty good. Of course, sometimes it gets it wrong, it's easy to come up with sentences that won't get it right for.
45:00 So I just wanted to, before going on, deviate for a minute and talk about what Jerry Hobbs was actually interested in. So what Jerry Hobbs was actually interested in was knowledge-based pronominal coreference. And so, from the early days of AI, there's been sort of observations about how to actually get coreference right in many cases, you actually have to understand sentences. And so there was this famous pair of sentences, which was proposed by Terry Winograd, who until very recently, was on the Stanford faculty.
45:36 Though he had kind of dropped out of doing NLPN and moved onto HCI. And so, Terry contrasted these two sentences. The city council refused the women a permit because they feared violence. And the city council refused the women a permit because they advocated violence. This was back in the 60s and 70s, when there was more protests around, I guess. So anyway, so in the first sentence, the natural reading is the they, is coreferent with the city council.
46:09 And in the second sentence, the natural reasoning with reading is with the they being coreferent with the woman, right? And the crucial thing to notice is this isn't something that the Hobbs naive algorithm could possibly get right cuz both of these sentences have completely identical structure. And so the answer that was suggested at the time was well, what we actually need to do is have knowledge of the world and being able to sort of represent these actions, and representing relationships that are likely to occur.
46:45 And that we just need to know, we have to sort of understand about city councils and permits. To understand that if you're refusing a permit, that would happen if someone was advocating violence but it would happen if the people who would be getting the permit were doing the advocation of violence. And so this is an idea that people have actually tried to resurrect recently. So, Hector Levesque a good old-fashioned AI guy.
47:17 And I guess he gave an invited talk in 2013 where he sort of suggested, gee, we should kind of try and get back to these kind of Winograd sentences and actually be trying to understand them as interesting, co-referenced challenges. And so people have tried to, more recently, run a Winograd schema challenge. So, really this is what Jerry Hobbs was interested in. And so actually why he proposed his naive algorithm, it was actually one of the first instances of NLP when someone said, gee, before proposing something really complex, I should have a baseline.
47:55 So I've got a good baseline to compare against as to how well something simple works. And what he discovered. Was the kind of systems he built couldn't possibly beat his baseline, because trying to do knowledge-based pronominal coreference was way too hard for what could be done back in the 1970s. But this is what he wrote about it. So he said, the naive approach is quite good. Computationally speaking, it will be a long time before a semantically based algorithm is sophisticated enough to perform as well.
48:32 And these results set a very high standard for any other approach to aim for. Yet there is every reason to pursue a semantically based approach. The naive algorithm does not work. Anyone can think of examples where it fails. In these cases it not only fails, it gives no indication that it has failed and offers no hope in finding the real antecedent. So in one sense, since 1978 we have progress because we now have algorithms that are significantly better than the Hobbs' naive algorithm.
49:06 So we've passed that bar for at least a decade, so that's a good news. On the other hand, Jerry Hobbs could very viably argue, that actually the second paragraph that I quoted there hasn't been addressed whatsoever, cuz we're writing. They might have more machine learning than them but we're writing the same kind of mechanistic algorithms that usually get things right, sometimes get things wrong. And that's just how it is and we don't really have any way of telling when it's failing.
49:42 Okay, so how do people do coreference. So there are different ways that people approach the coreference problem. So actually the most common way of doing it is what's referred to as mentioned pair models. And that's what we gonna look at for the end part of this class. So we try and work out all the coreference relationships by just making a sequence of pairwise links. So we're gonna take pairs of mentions and say, are these coreference or not, yes or no.
50:11 So we're doing binary classification decisions independently. And then as a result of those binary decisions we sort of induce a kind of clustering of mentions into entities, and we just do that in a simple deterministic way. We just join everything together into a lump that's been put together by these binary decisions. And we just say, and they all close together by transitivity. There are a couple of other approaches that people have used for coreference resolution.
50:44 Rather than simply doing binary yes/no decisions, another choice is to say that you can actually use a ranking algorithm. Something that's gone very prominent in certain areas of machine learning that you kind of don't cover in your basic ML class, is doing ranking problems. But they have come up in a lot of places. Think things like, Netflix recommending you a movie. Google recommending you a web page, all of those things are ranking problems.
51:16 And so you can think of coref as a ranking problem, because if you have a pronoun, well it should be coreferent with something. And maybe there are seven prior mentions in the document. And then you're doing a ranking task as to which one of those seven it would be. And then there's a third way of doing coreference resolution, which is arguably really the right way. Which is, what are referred to as entity mention models. And that's just explicitly think about the entities.
51:48 They're actual real entities that your discourse is about. And when you see a mention, you should be saying, that's a mention of a particular entity, or maybe this mention introduces a new entity in to your discourse and you've got this set of underlying entities. So in some sense, your entities are your clusters or mentions, but you're actually giving them first class status as objects in your model rather than them just appearing as a result of some linking process.
52:18 And so, a number of people then tried to work on models that explicitly represent entities and then do some kind of joint inference, or have some kind of generative model of how the mentions are created from the entities. But the simplest case and what we're look at mainly, are these mention-pair models. And so mention-pair models are normally trained to supervise learning models. What you do is you have some data, you have mentions.
52:52 And so there's this prior problem of finding the mentions, but we can roughly think of the mentions as our noun phrases. And then here's a He, and what we're gonna say is that gonna be coreferent with something. Well, if we have gold standard data we'll know that the right answer would be either Mr. Obama or the president, cuz both of them are coreferent. And if you have multiple choices, you'd normally just choose the nearest one. And you say, the correct answer for this one is the president.
53:26 And then you have negative examples which are things that are not coreference. So Milwaukee is a negative example. So you get positive and negative examples, you train a binary classifier and you're done. So if a conventional coref people then used all sorts of features, that were indicators of coreference. So for pronouns in English, they're things like person, number, and gender agreement. So Jack gave Mary a gift.
53:57 She was excited. That has to be Mary because of gender, rather than Jack. There are softer notions like semantic compatibility. So if there's a reference to the mining conglomerate, that could be coreferent with the company because that's sorta semantically compatible, that's much harder to do. Some things that we've already mentioned are hard syntactic constraints. So John bought him a new car, him can't be John, that'd have to be himself. So that's a feature we can use.
54:28 But there are lots of softer things which I was mentioning before. So, recency is a good indicator. John went to a movie. Jack went as well. He was not busy. That sort of sounds like it was probably Jack that wasn't busy, at least to me. And that's presumably a recency effect, but it's not really categorical, it has to be. Subjects are commonly preferred. John went to a movie with Jack. He was not busy. I think the most natural reading of that is that John was not busy, so that's preferring subjects.
55:03 Parallelism, John went with Jack to a movie. Joe went with him to a bar. I think the most natural reading of that is that that is Jack that Joe went with. And that seems to make sense not according to grammatical role preference, which would give you John, but in terms of the parallelism of the two sentences and interpreting it that way. So there are lot's linguistic features that you would start to build features from and put them into a classifier and try and determine coreference, and people built these things where loosely, they are big logistic regression classifiers with hundreds of thousands of features that try to capture some of these kind of relationships.
55:46 But for the last 25 minutes what I want to tell you then is about what people have done with deep learning and coreference. And the answer to that in two words is, not much. And so at this point in time There are basically four papers that have tried to use neural networks, deep learning, to do coreference by two authors. So there's Sam Wiseman at Harvard who's worked on the problem in a couple of papers. And then there's Kevin who's worked on the problem in a couple of papers.
56:19 And so there is some sort of connections and there's some different approaches here. I mean, in particular, there are a couple of papers, both sorta Sam's second paper and Kevin's first paper, which we're both trying to do entity-mention models. And actually try to have explicit representations for entities and doing more global inference in terms of entities. And I think most people who have tried to do coreference a bit really do believe that surely they should be good power from doing things jointly over these entities and that should give some real advantages.
56:55 In practice, it's repeatedly sort of proven hard to get sustained advantages from doing that and so there's sort of been this continuing use of entity pair, sorry, mention-pair models, which are very simple to implement, and you keep on thinking to work out how to make them work well. So Kevin's most recent paper is actually back to a mention-pair model and that produces great results. And I'd thought I'd actually show that one, not only because it's the most recent and best, but because it might be kind of a good chance to sort of show a couple of other techniques of doing things, in the context of deep learning.
57:35 Okay, so here we go, so the first couple of bits may be fairly similar, right? So, we wanna find these coreference clusters. And so we're gonna be doing it simply as a mention-ranking model where you want to assign a score to each candidate antecedent. So, we want to be saying, what does my refer to? And we're picking the preceding mentions, and then we add on one extra candidate, cuz for any mention you have one possibility is this is a new referent in the discourse and it's not co-referent with anything that appears before it.
58:16 So, we then have this new up the end. So you can say this a NEW referent. And so for each of these mention pairs, we're gonna build a model that scores them. And so, it's just gonna score a pair of mentions for coreference, independently still, and give them a score. And then what we're gonna do is say, well, which one has the best score? Okay, that's putting I and my together. And so that one, we're going to rejoin.
58:47 And so then we can literally just go through the mentions in the discourse from left to right and run this mention-pair classifier on each successive mention and sort of then assign them. And that will give us our model. And so then the question is, how can we go about designing and training a good mention-pair classifier? Then yeah, cuz at the end of the day, our actual set of coreferent things will just be the result of these local decisions.
59:22 So if we say, I as a new thing, Nader as a new thing, he refers to Nader, my refers to I, she refers to my. Then the result of that is we've sort of constructed these two coreferent clusters as a result of these local decisions. And as a result of imputing transitivity. So we're then saying that she is also coreferent to I. Okay, so I hope the setting in general is clear enough.
59:53 How is that done? And so for doing the neural mention-pair model, this is being done as a feed-forward network. It's sort of, in some sense, it's no more complicated than that. But what are the parts that go into it? So down at the bottom we have two kinds of things. So firstly, for both the mention and the candidate antecedent, we have embeddings of words. And so this model didn't use any kind of recurrent neural network or something like that that goes through the mentions.
60:30 I mean, Kevin actually experimented with that a little bit and found no particular value in it. And so it actually kind of like the dependency powers of Danqis that you did in assignment two if you remember back to that one. And so it picks out particular words and uses their word representations. So it will use the head word of the mention, the last word of the mention, and things like that, and so that gives you some word embedding features.
60:59 And so the word embedding features are gonna be good for capturing similarities. I mean, certainly when it's just the same word, right? They both say Akash, you'll get that. But you hope to also get things like conglomerate and company having similar word representations that you can do things with. But there are some relationships that that's clearly not capturing. If you think of some of those properties that we've already mentioned like recency and grammatical role and things like that, they're not being captured.
61:31 So there are also, then, a few features that are calculated for each mention that are also put into it. So after that it's really a straightforward architecture. It's a deep feed-forward network of sort of ReLus at every level that take you up to the top, and then at the top you're turning that into a score which is a numeric score of how likely it is to be coreferant. Yeah, so the tradition, compared to traditional systems, the number of handcrafted features is getting smaller over time, but there are still just the number that really help.
62:08 Distance is one that really helps. And if you have any kind of dialogue doing tracking of speakers and change of speakers also really helps you, and you don't just get for free out of word embeddings. Okay, users pretrained word embeddings. I mentioned the no RNNs, deep network, dropout. So, that part is all pretty straightforward. So what's a novel more interesting part of the model? And so that was to say, well, you aren't necessarily gonna do well if you just train such a model as a straightforward classifier.
62:48 You either got this decision right or wrong. You could do that but that's non optimal and the reason why it's non optimal is that some mistakes matter much, much more than others. Because even though the mention pair classifier is just an independent classifier of a pair of mentions. The reality is that as a result of making a sequence of those mention pair classifications, you're then going to end up with these clusterings of mentions that are your entities.
63:22 And you have the quality of your co-reference is going to be decided by how good are those clusters mentions that your entities that you formed at the end of the day. And so what that means in particular is that some mistakes you can make are really bad mistakes. So if you've started along saying Bill Clinton coreferent with he, Clinton coreferent with he, and Hillary is coreferent with Clinton, her. If you then said let's make these two Clinton's coreferent, that sort of collapses your.
63:55 Two partial clusterings together into one huge hair ball. And that sort of destroys your ability to kind of do discourse interpretation because you've collapsed two individuals in your discourse into one individual. So that's gonna really destroy you. But there are other ways in which you can make little errors which don't really matter. So, it was raining, but the car stayed dry because it was under cover. So this first it is what's referred to as the pleonastic it.
64:24 That it's just not really referential at all. Just somehow in English we like to have subject. So rather than just saying it's raining as you would in many other languages, you say it is raining. But it's not really referring to anything, so It was a mistake to make that co-reference, the car, but it sort of doesn't really matter. It's not gonna destroy your understanding of the dialogue, you've just got sort of one thing wrong. So that's a minor error.
64:51 And so the question is couldn't we train a model so that it's actually sensitive to these ideas of what a major error is and minor error is. and the secret of that is to say Well, that means that we can't work out the loss simply of individual decisions. We've gotta work out what impact those decisions have at the end of the day. And if you're in that situation in which you can't locally work out the loss of individual decisions, but you have to wait around and say how does things turn out later in the day cuz I'll have to use that.
65:33 That's the space in which you need to use reinforcement learning. And so, that's one possibility that this paper talks about. So, previously people had done something about this problem. And I'll show you that in just a minute which is to say, gee, some of these decisions are more important than others. So we could come up with heuristics to decide how important different things are. And then we could For different kinds of errors.
66:05 We can kind of set hyperparameters to weight those kind of errors and adjust those to maximize our performance. And to some extent, you can do that. But it seems like the more right and principled way to do it would be to say, no, this can be done, this reinforcement learning problem. And if we too wanna be finding local decisions, which lead to the end of the day as a good clustering. Say that our reward function for reinforcement learning is do we a get good clustering at the end of the day?.
66:35 And if we do that we can get rid of having to, manually find, things to weight and setting the weights of them with hyper parameters. And we can get some gains, not huge gains, but some gains, from doing that. So the thing that are being done in prior work is to say, well, there are different classes of co-reference decisions and their importance we might want to weight differently. So the mistakes you can make is you can do a false new.
67:07 You can claim that something is a new cluster when really it should have been made coreference to something. So that's failing to cluster when you should have. There's a false anaphoric. Something should have been it's own cluster, but you've joined it to an existing cluster. And then there's a wrong link where you should have been joining it with some previously established cluster and you chose a different one. So these notions still don't really get at sort of making a big scale mistake, like the Clinton mistake, versus small scale mistakes.
67:40 But they sort of distinguish different decisions. And some of these are worse than others. So in general, doing a Wrong Link is worse than doing a False New. Cuz a False New doesn't thave the same knock on effects that a Wrong Link has. Yeah, so what prior work had said is okay, we have these four kinds of things. They can actually be coreferent. And done correctly or you can make these three different kinds of errors.
68:10 And so what we could do is manually set weights for these different kinds of errors and adjust them to try and maximize our score. And so Sam Wiseman had proposed doing that In the kind of margin loss scenario. So that we are taking the maximum choice of candidate antecedents for each mentioned. And then here we have the usual kind of margin loss that we are looking at the score difference of the model.
68:41 For the true antecedent versus this candidate. And they're both being scored by a current model. And so, again, we wanna adjust the scores according to our model to sort of minimize that kind of large margin loss. But we add this one extra factor to our loss function which we say is well, scale how much it cost's you to make this mistake based on what kind of an error you're making. Which is sort of classifying it as one of these different kinds errors.
69:15 Okay and so that kind of idea wasn't actually original to Sam Weisman. So really sort of a whole bunch of papers really kind of just about all the coref papers that were done in the 2010s, had used this kind of idea. Because there's a way to push up coreference numbers a bit. But it doesn't seem perfect firstly you have to do the hyper parameter search. And secondly those error types are a bit correlated with badness, but they don't seem to be very directly correlated with badness.
69:50 And so Kevin was wanting to try and do things better than that. These are the ways he approached it and he introduced two approaches. What we can say is when we are doing coreference, what we're doing is we're taking a sequence of actions. And so each action is looking at one mention as we head through and choosing something as it to be coreferent to, where one possibility is you are co-referent to NEW. So you're making this sequence of actions.
70:22 So you are deciding what to do with I, deciding what to do with Nader, deciding what to do with he. That these are your sequence of actions. And so what we'd like to do is chose the sequence of actions that maximizes getting a good coreference clustering at the end of the day. So how do we decide what's a good coreference clustering? Well, what we do is we actually just believe our metric. So I showed you the BQ metric for coreference and that seemed kind of sensible it was sort of is F measure of getting your links right and precision and recall.
71:00 So we call that our reward function. So if you kind if you get everything right, your BQ metric Is 100 or a 1 depending on whether you make it a point or make it a percentage. And so we then have no loss and if you make some mistakes, we can then work out the reward for different coreference algorithm. The reward will then be a lower award corresponding the b cubed score. And so Kevin explored two methods of doing this.
71:30 One's sort of the REINFORCE algorithm which is the most common reinforcement learning algorithm that's used in deep learning techniques and elsewhere. And then reward-rescaling. So for the REINFORCE algorithm, what you're doing is you're defining a probability distribution over actions. And the way he was doing that was sort of taking the scores from the mentioned pair model and exponentiating those and normalizing them, so sort of standard soft max function.
72:02 And saying that's the probability for taking different actions. And then what you're wanting to do is work out four action sequences with their probabilities, you want to maximize your expected reward. So the REINFORCE Algorithm maximizes your expected reward. So you're taking the expectation over action sequences, according to this probability distribution and then working out the reward, the B-cubed score, having taken that action sequence.
72:35 The problem, is of course, that there are sort of an, oops, the problem is that there are an exponential number of different action sequences that you can take here. And so you can't actually explore all of them. But what you can do is then sample trajectories to estimate that expectation and to approximate the gradient and you can learn according to that. So using the REINFORCE Algorithm for reinforcement learning, it basically worked.
73:08 It's sort of competitive with the heuristic loss functions that people had found. But it still seemed to have a small disadvantage, which is that the REINFORCE Algorithm maximizes performance in expectation but that's not what we actually want here. We actually want to sorta maximize the highest scoring action sequence, cuz that's where we're actually gonna use in practice. And so Kevin explored this other idea, which is to sort of say, let's actually continue with this idea of incorporating rewards into the max margin objective slack rescaling.
73:45 But instead of using these sort of handset hyperparameters like before, what we will do is actually we can work out how to set those sort of losses for rescaling the large margin objective. So the idea there is for our training data, we can actually just look at the effect of different decisions. So since each action is independent from every other action, we can change one action and see what effect it had for the reward.
74:20 So, this is the correct set of actions when our Reward = 100. And so, we can just say for AI there, suppose we made that decision differently, suppose we had said AI then declared that mention to be NEW. Well, we can just say this is what our system returned what's the B-cubed score for that? And the answer is 85, and so our Regret = 15 because we could have gotten the right answer and 100. And then we could say, well, let's consider a different possibility.
74:53 We could have put my as coreferent to he, what's the B-cubed score then? And the B-cubed score is 66 and so now our Regret is larger, our Regret = 34. So we can actually empirically over the training data work out what the cost of different mistakes is in terms of B-cubed score. So, then what we can do, is sort of incorporate that, so that now, the sort of, the scaling factor over our max margin loss function is being taken as the difference between the best action we could have taken at that point.
75:36 Which may no longer be the perfect action because we might have previously made mistakes versus the actions that we did choose. So that the cost is then sort of the regret for taking a particular action, and that replaces the heuristic cost we used previously, for actually what is the actual cost of this mistake in the context of a particular sentence? Okay, so that was the system or the second system that was built. And so then this was evaluated on coref.
76:06 So most of the recent work on coreference has used, there were these CoNLL shared task in 2011 and 2012, the coreference. It was, it had English and Chinese in it and these are scored with the sort of CoNLL score. The people who did the CoNLL competition, I guess they didn't wanna take sides as to which was the best metric for co-reference so they came up with the CoNLL score for co-reference, which was actually just the arithmetic mean of three co-reference metrics, B-cubed and two other ones.
76:40 And so these are how things performed. So the kind of heuristic losses that people had used previously actually work quite well. So using the REINFORCE algorithm is a smidgen better but not really better than using the current heuristic loss functions. But what you could find is that using Reward Rescaling actually did work significantly better because you could then sort of actually use the real losses that were incurred in different environments.
77:16 Now, these results and differences may not look very impressive. But that's partly because even the heuristic loss is being run on a good neural coreference system. So I should also show you these other results, just to give you a sense of things. So this is the sort of progress that's really been made in coreference resolution. So at the time of CoNLL 2012, the best Chinese system was this Chen & Ng which got 57 on the CoNLL score, the best English system got 60.
77:49 There had been some work on non-neural systems since then, so there's a better Chinese system, and there's also a bit better English in this system. So the Wiseman was sort of the first neural system, so that was actually now starting to do a lot better. And then here is Kevin's two system and it sort of starting to get some decent gains beyond that going up. So the neural systems actually have given a nice new level of gain beyond previous coreference systems.
78:24 And so I just wanted to end in the last minute it by saying, well why is that? So, one of the biggest gains is just the sort of general goodness of embedding. So, one of the places where you get the biggest gains is what turns out to be one the hardest cases of coreference in practice, is when you have these common noun nominals and you have to realize they're coreferent. And so that's things like the country's leftist rebels and the guerillas, the gun, the rifle, 216 sailors from the USS Cole, the crew, these are the kind of ones that are very hard to get, right.
79:01 If you're just doing conventional system with word features and things like that. But that's precisely the kind of place where having our word vectors actually does give us some purchase that these are still hardest cases to get right. But the other place you were getting gains is from using this Reward Rescaling algorithm. And the kind of interesting thing that the results actually turned out, is compared to the heuristic loss function, that using Reward Rescaling, that the Reward Rescaling system actually made more mistake than heuristic loss function.
79:38 But was cleverer at deciding where to make its mistakes and so it made mistakes that were less important. So, even thought it made more mistakes, overall it was able to achieve a better B-cubed score by concentrating on making less important mistakes. And that reflects the fact that is for different mistakes, there is a wide variety of different costs. So this is an empirical graph of looking at all cases of false new, and then this is the distribution over how much they cost You.
80:15 Even though, as you can see, there is a clear mode to this graph. So if you were doing a heuristic loss you would say, okay, customer false new is about 0.28 or something like that. For different situations there's an enormous distribution as to what the real cost of a false new is and that's precisely what could be captured by the Reward Rescaling. Okay, that's it for coreference and then back on Thursday for doing the dynamic memory networks.