transcribe

Review Session: Midterm Review

Stanford University School of Engineering · 1h 25m · transcribed 10d ago
More from Stanford University School of Engineering
𝕏 Share ▶ YouTube 📥 PDF 🤖 .md

Transcript

0:05 Stanford University >> Hi, everyone. Welcome to the midterm of this session for CS224N. I'm just gonna start with some announcements. So the first one, as I hope you're aware of, homework 2 is due today. And we had an issue with the submissions script that made submissions unavailable for a couple hours. So we apologize for that, but that is now fixed. There's a slight change to the submission instructions to the initial version. And that is we don't want you to include the trained weights for your models, because it turns out, that takes up a lot of space.

0:41 And we run out of AFS, and we can't take any more submissions. So we apologize for that inconvenience. The other thing due today is the project proposal, so these are both due at midnight. And we are saying that if you have not yet found a mentor, but you would still like to do a final project other than the default final project, you can still submit a project proposal. And say, that you've not found a mentor yet, and we would do our best to find you a mentor, anyway.

1:11 Now, for a couple of notes on the midterm. So the midterm is Tuesday. Same time as the regular lecture, but I want to point out that it’s not being held here. It’s being held in Memorial Auditorium. There is an alternate exam only if you cannot at all make the February 14th, is normal midterm time. And if you want to take the alternative exam, or you have to take the alternative exam, I'll post about that on Piazza.

1:37 We are allowing a single cheat sheet. And the material on this midterm is all the lectures including the most recent one. The midterm is gonna be a mix of multiple choice, and true/false questions, short answer questions, and some longer more involved questions that may involve radiant computation. And for SCPD students, you have to turn up in person, or have an exam monitor pre-registered.

2:09 The rest of this lecture is going to be just review material to help prepare you for the midterm. And in particular, we're going to cover word vector representations, neural network basics, back propagation and gradient computation. And we're gonna do some example problems on the white board for that section, RNNs and Dependency Parsing. And with that, I will leave it to our first section, Word Vector Representations.

3:03 All right, we can start that again. So what are word vectors? For every word, we could come up with a vector that encapsulates semantic information about the word. There could be various ways of interpreting what meaning or semantic representation could be. And which is why it so severely depends on how you actually go about training your word vectors. In this class, we first covered word2vec and GloVe, and we'll be reviewing that now. So just to recap, Word2Vec, the task for it is, learn word vectors to encode the probability of a word given its context.

3:41 Now, consider this example, our window size is 2 here. I understand the Word2Vec model now. If you consider the center word to be Word2Vec, understand the and model now become context words. And you'll see how to probabilistically model this now. So for each work, we have two vectors. The input vector and the output vector, then for vectors represented by v and the output vector by u. And we'll see how v and u are used in the model now.

4:09 So we'll be covering two algorithms here, Skipgram, which predicts the probability of the context words given the center word. And the Continuous Bag-of-Words, or CBOW, which predicts the center word from surrounding context. All right, so to recap on Skipgram, consider the sentence again where I understand the Word2Vec model now. And in this case, since the center word is Word2Vec, that'll be the only word that's left, and the context words will be omitted. And our job is to actually go about and assign probably the words there.

4:43 So, how do we go about doing this? We first generate a one-hot vector. In this case, this vector will have the same dimensions as the number of words in a vocabulary, with one of the index of the word Word2Vec, and 0 everywhere else. Now, we need to use this one-hot vector to index into over embedding matrix, which is capital V, the input vector in embedding matrix. And we looked in a word vector corresponding to that word.

5:10 We then go and do a doc product with the output word vectors hue, and to generate a score for it. So far, so good. Any questions? So once we get a score, we get the probabilities by using Softmax. And once we have those, we have Softmax probabilities for every context word. And we can then find out which word actually would go into these context windows. How do we actually go about training this? We assign over a cost, which is either given by Softmax cross-entropy, or the negative sampling loss.

5:46 And as you can see, the formula takes abstracts or the cost function over there. So we take the input vector, and we take the word vector for the context words, and we apply these cost functions and sum them over, okay? And our job is to minimize this loss. I'm using cost and loss interchangeably, as we will do that in the midterm in the class as well. That is Skipgram.

6:17 Now, we move onto Continuous Bag Of Words, CBOW. Now, let's take the previous sentence again. I understand the Word2Vec model now. In this case, our job is to actually predict the context word, or the center word, my bad, given the context words. So in this case, our job would be to actually guess the Word2Vec model here. So in this case, as in the previous case as well, we generate one-hot vectors for each of the context words.

6:43 And this would, again, be the size of your vocabulary with one at the index of the word itself. And then we look into our embedding matrix, again, the input vector embedding matrix, and obtain the word vectors for those context words. We take the average of those word vectors, and then compute the score again by multiplying with the output vector matrix. Now, that we have the scores, we can get the probabilities by computing the Softmax function. And now, we have for each of the words in the vocabulary.

7:16 We have the probability assigned that what how likely it is to be the center word. All clear so far? This should be pretty clear since we also had a live coding session on this. Sweet. The cost function here is similar to the one in Skipgram except, in this case, it takes in the average of the word vectors as one of the arguments and the center word itself. And again, our job is to minimize the loss here.

7:46 Sweet. We didn't do this as a part of the assignment, but GloVe is a pretty famous set of word vectors, as well. Like Word2Vec, it also captures semantic information about the words. But unlike Word2Vec, however, it also takes into account the co-occurence statistics. And we'll see what we refer to just in a second. From one of the lines in our review notes, GloVe consists of a weighted least squared model that trains on global word co-occurrence accounts.

8:17 So what do we mean by co-occurence? Consider our corpus to be only a set of three sentences. I like deep learning. I like NLP and I enjoy flying. Now, you can see that we can come up with a n by n where n represents the number of words in our corpus. A matrix where each index corresponds to whether word GA belongs in the context window of word I, okay? This is a symmetric matrix as well. So you can, as you can assume.

8:46 The ordering does not matter. So let us denote this matrix by x. And so if you index into this using -ing, that would be the number of times word j occurs in the context of word i. And let us also denote xi to be the number of times any word appears in the context window of a word i. Just like in Word2Vec, we also have two vectors for each word here, the input vector and the output vector.

9:12 And the cost function is given by the equation here. There are a couple of interesting things about this cost function which we'll cover right in a second. But a few things to note here, we're applying the least squares as we mentioned earlier. We are iterating over every pair of words in the co-occurrence matrix. What's interesting is that since you can imagine words like d or a, the articles as the stock words would have a large xij value, we need to sort of clip on it.

9:45 And the other option is to just take the logarithm of it. And so which is why you can see there's a log over the xij over there, okay? So any questions about the cost function here? Okay, let's move on then. So now, after minimizing this loss for the GloVe word vectors, they will be having V and U, where V represents the output word vectors and U represents the input. And since both of these capture similar co-occurrence information, we can obtain the word vector for a single word just by summing them up.

10:21 So just U plus V will equal the word vector for that particular word. And we can use that for all sorts of NLP tasks. It's essentially an embedding for that word. So before we move on from word vector presentations, any questions on any of the terminology? We got a lot of questions about how does an embedding defer from a word vector. We want to make sure that that definitions ambiguity is cleared up. Yes, please.

10:57 It is a vector, I mean it is a scalar. Yes, the question was. If Xi is a vector, shouldn't the laws actually be referring to a scalar? Xi is actually a scalar because it's solely the number of times that word appears in the context window of any other word. So Xi is defined as the number of times any word key appears in the context, so it's not a vector. Yes.

11:28 Most research papers tend to use embeddings and word vectors pretty interchangeably. Basically, you can imagine it's a a vector that encapsulates semantic information. So in terms of analogies, you can imagine that if you had word vectors for king, man, queen, and woman, then if you subtract king minus queen, it should be roughly equal into man minus woman, for example. Sweet, any other questions? Yes.

11:59 So those input vectors and output vectors are solely just differing in the sense that, if you have a context word, we are going to predict the output vector for it. So in any case, you're considering a word solely, you're considering only the output vectors. Okay, all right, so let's cover neural networks. This will be roughly quick because we also have RNNs and LSTMs to cover. So coming back to the basics, you have a data set x and y where x is the input, y are the labels.

12:26 And you want to train a 1-hidden layer neural network on this. You do a forward pass given by xW + b, and then you apply non-linearity or a activation function on it. You compute the loss, you compute the gradients from that loss using back propagation. We'll go into back propagation with Barack. Then we update the weight using an optimization algorithm like saccustic gradient descent, or SGD. We do hyperparameter tuning of Dev set, not on the Test set.

12:52 And then evaluate the neural network on the Test set itself, all right? So this was a very high level of review of how neural networks have changed. Let's go where the activation functions are the nonlinearities quite quickly. So we have the sigmoid function. What it does it takes and input and squashes at between 0 and 1. However, this has some problems. If the activation function was very large, if the activation was very large, is still always end up being 1?

13:18 Or if the activation is really small, it's still end up always being 0? So you can imagine that a lot of neurons get saturated by this. And the output is not centered as 0. This is particularly bad, because if the output for our sigmoid is always a positive number, then the gradients are always negative or positive. And we do not want that, we want the gradients to be more adaptive, okay? Another issue, this is also that takes the exponent and it's computationally expensive, but nothing in here can run with the map there.

13:51 Okay, then the tan h function, an input squashes at between negative 1 and 1. Here, in this case, the output is centered at 0 so which is a nice thing, and it sort of resolves the problem that sigmoid had. However, similar to a sigmoid, this also kills the gradients at saturation. And which is why tan h is not as good as well. Yes? Right, so if your input, if the output of your node. The question was, why is it bad that the output of our activation function is is not centered at 0?

14:25 So if the output of your activation function is always positive, then the gradients are always positive or always negative, because they can only go in one of the two directions, always. Yes. They do break the, so we are able to train networks with this function. So it's not like it's the end of the world in terms of training neutral networks. So in this case, what would actually be better is that you take your input and you center it at zero, either way works.

15:00 Moving on to ReLU, the Rectify Linear Unit, which essentially takes some acts on checks if it's greater than 0. If it's greater than 0, it returns the same value. It does not have the problem of saturation because it's linear. It's confidentially cheap, there are no explain on calculations. And it's also empirically known to converge faster, right? Yes? Yeah, so that is an error. So which is why I have the second point in the problem says referring to that.

15:31 Yeah, so the problem with this is that it's again, not centered at 0. The larger problem with this, and it's slightly annoying as well, is that if the input is less than 0, then the ReLU gradient is always 0. And this is a problem because once a neuron dies, it always is dead. You can never revive a neuron after the input becomes less than 0. Sad times, I know. Anyways, moving on to stochastic gradient descent or the optimization algorithm.

15:58 In this case, theta represents our weights or the parameters. Alpha is our learning rate and J is our loss or the cost function. And going very technically, SGD update happens after every training example. However, researchers tend to abuse the notation and call minibatch SGD also normal SGD. And what minibatch stochastic gradient descent does, is it takes a small batch of training examples at once and averages their loss over before performing the gradient update.

16:28 Okay, moving on to regularization, this is a form, dropout is a form of regularization. And it randomly drops neurons at forward pass during training. While this might seem very counterintuitive that it should work, it does because it prevents overfitting. It forces the network to learn dependencies. When you have fewer number of neurons to learn the same task, it forces each neuron to capture more important information about your data and learn more important abstractions. So think about dropout as training an ensemble of networks.

16:58 Every time you run your network during forward pass, a couple of neurons are dropped. And as a result, you are getting a new network almost every time and then you're training an ensemble of networks. During test time, make sure that you turn your dropout also that you again take this ensemble of networks and then use the shared power between all of these networks. Any questions on dropout? Yes. So it depends.

17:28 If you make sure that. So the question was do you have to scale your output whenever you run dropout at tester? And the answer to that is no. And just because if during test time you make sure that your activations are already scaled correctly, then you don't have to do it during test time. So, a few training tips and tricks here. These are a couple of loss plots. So the one in the green represents a phenomenon when your loss is very noisy.

17:59 And what happens, you can see the jagged line. And in this case, what must be happening is that since your gradient updates are very large, you are not converging properly. You are almost iterating over and around the local minima, which is why it's advisable to lower your learning rate in that case. If it's blue, you see that there is high potential for your network to actually train faster. And hence, you should make your learning rate higher.

18:24 Okay? The red line is sort of an ideal one. Again, this is something I just drew up on Paint. So it's not something that's very technical. It's just intuition. All right. So this is something you must have faced issues with in the last assignment. Where if the gap between your training curve and your dev accuracy is very large, that means you're overfitting. And in this case, there are a couple of ways you can actually counter that.

18:49 One is by increasing your regularization constant. This could be by increasing your dropout rate or by increasing the L2 Norm rate, okay? And again, this is very important to stress that do not test your model in the test set before you're done resolving overfitting issue. It almost sort of breaks the scientific pipeline if you test your network on the test set and then tweak your parameters, because you're not supposed to look at the test set.

19:23 So the question was, if you're not supposed to test them on the test set, then what kind of data are you suppose to test it on? And the answer to that is you can divide your data into three parts. Training, dev, and test. You train on the train. You evaluate regularly on the dev set. And then, finally at the very end, test on the test set, okay? With that, I'll leave you to Barak for Backpropagation and Gradients.

19:51 >> All right, hi everyone. It's another bright and sunny day to do some backpropagation. I mean, cold and rainy. I think it's also pretty ironic that last time I spoke to you from here, I told you about all of the wonderful things that TensorFlow can do with automatic differentiation, and here we are again computing gradients by hand. But anyway, so the main ideas of this part of the review is to go over some of the intuition and the math behind backpropogation, as well as how to use it in practice.

20:14 Before I begin, I highly urge you to check out Kevin's notes on gradient computation, as well as some of the principles behind like matrix calculus. I think it's very helpful to understand what's on those notes to help you the most with the midterm. Okay, so our itinerary is to first review what backpropagation is, then to have a quick chat about matrix calculus. Then, we're gonna talk about how to compute products of gradients correctly. In other words, when do I transpose my darn symbols?

20:43 And then, we're going to solve two midterm problems. Okay, so the problem statement that we are looking at is given some function f with respect to inputs x and some labels y, including some parameters theta, we wanna compute the gradient of your Loss with respect to all your parameters theta. And what backpropagation is, it is an algorithm that allows you to compute the gradient for some compound function as a series of local, intermediate gradients.

21:13 So if you have some compound function, backpropogation is the tool that you have that allows you to compute the total gradient through an application of the chain rule to all of the local intermediate gradients in you function. So there are three kind of parts to backpropagation. The first is that you want to identify what your intermediate functions are, i.e, the intermediate variables. And this is basically done for you in the forward propagation stage. You then want to know what the local gradients are of all of the variables inside your compound function.

21:43 And then you want to somehow combine those through some application of the chain rule to get your full gradients. So the first thing that we need to talk about is what modularity is and let us look at is at an extremely simple example. We have some function of three scalar variables x, y, z. We're going to add x and y and then multiply that by z. Our intermediate variable is q, which is equal to x + y.

22:03 And our final compound function is q x z. So the idea of modularity is to kind of separate out our smaller operations such that each level of our forward propagation, we know how to complete the gradient of the output with respect to our inputs of interest. So the key idea of modularity is that it allows you separate out the operations that you're using. So that at each point, you're able to calculate the gradient in some sort of palatable way.

22:30 Okay, so, modularity for a neural network is basically what we've seen in our assignments so far, in terms of splitting up our compound function as a series of all of our propagation steps. So in this example of a two-layer neural network, we have the loss of some cross-entropy of a sigmoid activation of some linear function again applying to linear function over that and taking the cross-entropy with y. So intermediate variables are going to be all the things you're familiar with.

22:57 It's going to be our hidden layer, it's going to be the activaion, it's going to be our scoring, which is z2 in this example, followed by our Loss. So the idea is that at each step of this forward propagation stage we know how to compute the gradient of our output with respect to our inputs. So, let us look at how the forward propagation and the backward propagation relate to each other. On the left, we have the forward propagation, which is where the values from our inputs are propagated down through our network.

23:26 And we're basically computing the value of our compound function. What is happening in backward propagation is basically the reverse side of the mirror. Where at each point, we take the gradient at that level with respect to the variable above it. So the last thing that we need to do to finish off our backpropagation Is to find out how we're going to merge all of these local gradients together, to get our total gradient. And this is as good a time as ever to talk about the chain rule.

23:50 So the key intuition behind the chain rule, is that slopes multiply. So if I'm trying to take the derivative of some sort of compound function, f and g, of some input x over that x. It's going to equal that derivative of our total function with respect to the intermediate value. Times the derivative of the intermediate value over our inputs. And this is a bit of a mathematical wonder, you might think. It's so beautiful that if you have two functions.

24:18 You can just multiply the slope of the intermediate by the slope of the function that happens after that. So this is kind of the key tool that allows back propagation to work. Another useful analogy for understanding back propagation is looking at circuit diagrams. So this is going to be the circuit diagram of our initial simple example. We're going to add x and y and that is our q node over there. We're going to multiply that by our z variable.

24:44 And that gives us an f. So the green values in this diagram represent the forward propagation values. And the red values represent the backward propagation. So looking to the right most. We start off with an error value of 1 because trivially, the derivative of f with respect to itself is just 1. What is interesting though is if we look at the error signal that is happening at the q node. It's currently -4 because the derivative of F with respect to Q is just going to be the value of Z minus 4.

25:11 We know that the derivative of Q with respect to X is just 1. But what we're going to do to get the total gradient at position x. Is we're going to multiply that gradient times our error signal that is flowing into q. And this is I guess the key point of what we're showing here. And we'll see how this kind of figure can help us do back propagation in midterm questions soon. Okay, are there any questions so far about this large overview of back propagation, before we start talking about matrix calculus.

25:46 Great, okay, moving to some matrix calculus. So let us first talk about derivatives over vectors. So the derivative over a vector is going to be a matrix of partial derivatives. Where the derivative of each row is going to be the derivative of that index of the output with respect to all of the indices of your input x. So for the scalar by vector example, you're going to get a single vector. Where each column is going to be the partial of y by the partial of x at that particular column index.

26:19 In the vector by vector case, we're going to have the matrix of partial derivatives. Where each row is the partial of yi on the ith row by all of the indices at position x. The case for derivatives over matrices, question. The question was, does the presentation of the derivatives change with respect to whether x and y are column vectors?

26:52 So a potentially complicated answer to your question is that each of these derivatives represents the Jacobean of that derivative. That is a matrix that takes as input whatever shape your x is and outputs the shape of y. So if x was a row vector, yes. The presentation would actually be transposed. Yes, question. So the question was, are we going to be using the convention that x is a row or a column?

27:23 That depends on the question and it'll be stated very clearly when you're taking derivatives in that question, okay. So the case for derivatives over matrices is slightly more complicated. Ad it's complicated for this reason. You can interpret y as a function. If I'm trying to compute my partial of y over my partial of a where y is a scalar. Y is actually going to be a function of every single element inside your matrix A.

28:02 Okay, so the proper derivative of partial y over partial A is actually going to be an element of, thanks. It is actually going to be an element of RMN. So the true Jacobean derivative of partial y over partial A is actually going to be some long form vector ofsize MN. But this is not such a good presentation for us when we want to do derivatives of matrices. So we actually rearrange that sort of derivative to be some matrix of derivatives.

28:34 Where the partial of y at each index is going to correspond to the partial of the index at that position A. The case for derivatives of vectors over matrices is even more complicated. Because the true form derivative of a derivative over a matrix is actually some sort of three-dimensional array. Or it's going to be a tensor that is sort of beyond the scope of what we're trying to do here. So since we're only interested in computing gradients of our lost scalars with respect to matrices.

29:07 We can actually hide out that sort of strange three-dimensional array derivative thing. Cuz we're going to be computing it by some error signal from above. And let me show you what that means over here. So if we're interested in computing the derivative of z with respect to A. Let us look at what the derivative would be of that z with respect to a single element inside our A matrix. So you can think of Aij as representing the sensitivity of the ith index of the output with respect to the jth index of the input.

29:39 And this is what we're going to be looking at. So the derivative at the ith position of the dz gradient is going to be exactly the value of xj in our input x. Since that is what is modifying the A. And this leads to the identity that the partial of j over the partial of Aij is going to equal the dot of our delta. Of our delta gradient flowing inwards at exactly position i.

30:10 Since that is the only value that is not 0 in our derivative of z over Aij times the value at xj. And this leads to the identity of dJ by dA. So you can somewhat ignore the slide and just focus on the identity for the purposes of the midterm. But this might be a bit of an explanation of what it means to take sort of derivatives over matrices. Okay, so on this slide I have, for your reference.

30:36 A list of perhaps the most useful identities that you'll need for computing all of the gradients that we use in our midterms. And I won't explain this now, but the slides are online. So I highly urge you to check these out or to check them in the notes. So are there any questions before we move onwards? Awesome, okay. So one thing that you might notice from the previous slides. Is that the nice thing of taking derivatives of scalars over vectors or matrices.

31:05 Is that the shape of our output has the same dimensions as the shape of our inputs. Both in the scalar-by-vector case and the scalar-by-matrix case. So what we enforce when we do back propagation is this shape rule. Where when you take the gradients against a scalar which is what you're essentially always doing. The gradients at each intermediate step have the shape of your denominator. So if X, whether it's a row vector, column vector, or matrix, has shape m by n.

31:31 The error signal of d scalar loss by dx is equal to the same size as our denominator And what this allows us to do is dimension balancing. So this is going to be the general gradients for any sort of matrix multiplication you do on any gradient question where X and W Can be either both matrices, or X can be a row vector and W a matrix, or X can be a matrix and W a column vector, so this is a general form.

32:00 So if Z is going to be some m times w matrix, and we represent the error at that point as partial Loss over partial Z as being delta, that because of our shape rule, we know has shape m times w. How do we find out what the dimension of our d Loss by d X? Well, if we are looking for a gradient of shape m times n, and we know we're going to be multiplying our gradient signal by W, using our identities from the previous slide.

32:30 Then we realize that we need to take the transpose of W so that the W is on the left side and the delta is, and the W is on the right side of the delta. So you can kind of solve these identities by looking at the dimensions of all of your terms, and making sure they balance out to give you the correct dimensions for the gradients. By matching the gradients of your error and the gradient, the dimensions of your gradient and the dimensions of your term.

32:58 Are there any questions about this dimension and balancing concept? The questions was, what is delta? Delta is going to be the error signal at the point of Z. So since we're trying to compute the gradient of the loss with respect to X, and the level above that, the intermediate level above that is Z. To apply the chain rule, we're going to have delta represent the derivative up to the point Z. And we're going to multiply that as an application of our chain rule with the derivative of Z with respect to X.

33:48 So the idea whenever we're, if I'm starting with some Z as a matrix multiplication of X and W, and I want to know what my derivative of Loss, With respect to W is. Using the chain rule, I know that that's the derivative of the Loss with respect to Z times the derivative of Z with respect to W. So this is going to be our intermediate variable that we're taking our local gradient of.

34:19 And we know what the derivative of this with respect to this is. But this is going to give us the error signal up to that point. The error signal records what the value of the error is up to the point of this intermediate computation, okay? The error signal is kind of what the gradient is up to the point of your equation, of the Loss down to the last variable that you're looking at, which is the output of that expression, okay.

34:53 All right, so it kind of feels like dimension balancing is this kinda cheap and dirty approach to doing gradient calculations. But they are indeed kind of the most efficient tool that you have to computing gradients quickly in most practical settings, and especially the midterm. But I do encourage you to read the gradient computation notes if you want to understand how the gradients work from first principle. The last thing that I wanna talk about is how gradients over activation functions work.

35:24 So one of the questions that we fielded frequently in office hours is, why is it the case that when you're taking gradients over an activation function, you're doing this element-wise multiplication or Hadamard product? And the answer to that is, if you're looking at, so the answer to that is the activation function is a function that maps a scalar to another scalar. Though we represent z as a vector as a sigmoid of an entire vector h, the sigmoid is actually being applied to each individual element in that vector, which maps the same index in your output.

35:58 So the way we represent the true gradient, the true derivative, is that it's going to be a diagonal matrix. Where each index on your leading diagonal is going to be the gradient of the ith index of your input. And multiplying some matrix or vector by a diagonal matrix is equivalent to doing the element-wise multiplication of a vector itself. Which we represent and the Hadamard product. Okay, are there any questions about what we've discussed so far before we get to some midterm problems?

36:34 Yes, If you go back to this slide, where this is the true, sorry.

37:22 This is the true Jacobian form of the partial of some y vector, with respect to x, you can see that it's a matrix that takes as input, a column vector x, and maps it to an output y. So if the shape of your Jacobian takes as an input, something with shape x and maps to an output something with a shape y, which is exactly what is happening in the top left box over here.

38:15 Can we talk about that question maybe after the lecture, so we can move on? Cuz we have a few more sections. Okay, so let's get through, and maybe when we actually do some midterm problems it'll become more apparent how it works. Okay, so the first question that we're going to look at is to do with Siamese networks. And, a Siamese network basically allows you to compute a similarity metric between two inputs x, between an x1 and some x2 inputs.

38:41 And this allows you to sort of compare the similarity of two word vectors or two sentences. So the first thing that I like to do when we're starting some gradient problem, Is to draw a graph of how our variables are related to each other. So we can see is we start off with some J, at the top we have our cost function J.

39:12 It takes as input an h1 and an h2 as two hidden vectors. These are activations of z1 and z2. And I am defining these variables myself, so I need to specify what they are. And this is going to be, in this problem, we're treating our inputs as column vectors. And for z2 it's going to equal to x2 plus b. So we have two inputs, x1 and x2.

39:42 And one interesting thing to notice about Siamese networks is that the variables, sorry the parameters, W and b Are shared across both of these activations. So if we're interested in taking the derivative of J with respect to W, we need to add the derivatives coming from both branches down. So the first thing that I like to do when I'm computing my gradients, is basically, to express this graph, and we'll see how it's useful to us in a second.

40:06 Okay, can the camera see me, awesome. So if we want to start our gradient computations, the first thing we want to do is to take the derivative with respect to J. So let me write out what my J is going to be. It's going to be half of the Hadamard, I'm sorry, the Frobenius norm of h1 minus h2 squared f. And we're going to have a regularization term.

40:38 So this is, I'm first writing out what my cost function is going to be. And I use this graph to kind of inform me about where I'm taking my derivatives and what my error signals are going to be. So the first thing I wanna find out if I wanna compute, what is the derivative of J, with respect to W. This is what I'm interested in. So the first thing we're going to do is flow down this branch.

41:01 So we're going to compute the partial of J with respect to the partial of h1, and I'll leave this for you to show on your own time, what the derivative over the Frobenius norm is. But it's basically just going to be h1- h2, cuz the 2 cancels out and you're left with an h1- h2 term. Equivalently, the gradient with respect to h2 is just going to be the negative of that expression, okay? So one thing that I like to do, is to also record what the dimensions are of all of my gradients.

41:36 So over here, since we're dealing with column vectors, this is going to remain an m by 1 vector. And this is going to be an m by 1 vector as well. And the other thing I'm going to do is give a name to these error signals. This one is going to be delta 1, and this one is delta 2. And what is nice to represent using this graph is what my error signals are flowing down it.

41:56 So over here I've defined delta 1 to be the partial of J with respect to partial of h1. And over here we have delta 2 being the partial of J over the partial of h2, okay? So the next thing we are interested in computing is what is the derivative of J with respect to z1? So we're going to apply our chain rule. We know what the derivative of J with respect to h1 is, so we only, sorry, we want to compute the derivate of J with respect to z1.

42:21 We know what the derivative of J with respect to h1 is, so we only need to compute the derivative of h1 with respect to z1. So, over here we have a sigmoid activation function, so we just need to compute the gradient over that. So my partial of J over the partial of z1 is going to equal partial of J by partial of h1 times the partial of h1 by the partial of z1. And that is equal to my first error signal with the Hadamard product of, this is getting a bit tight here, it's going to equal my error signal Hadamard product with h1 times 1- h1.

43:05 Which, as we know from assignment one, is the derivative of the sigmoid. I'm running out of space here. Let me move over here. I hope it doesn't get shadowed. Similarly, the partial of J with respect to z2 is equal to the partial of J by the partial of h2 times the partial of h2 by partial of z2. And that's also going to equal our current error signal flowing down to h2, so it's delta 2 Hadamard product with h2 times 1- h2.

43:43 And we're gonna give this a name. This is now going to be delta 4 and this one is going to be delta 3. Okay, so over here we have delta 3 and here delta 4, okay? So now the last thing that we wanna do if we wanna compute the gradient of J with respect to w, This is going to equal my error signal up to z1, so partial of J by partial of z1 times the partial of z1 by the partial of w.

44:20 It's also going to, and we're going to add to that what's happening in the error signal at the other branch. That's partial of J by partial of z2 by the partial of z2 over the partial of w. Plus we don't want to forget about our regularization experiment. The partial of lambda over 2, Frobenius norm of w by w, okay. And this is going to, now, we need to do some matrix balancing, using what we discussed earlier.

44:51 Since we're taking the derivative over this matrix product over here. So what we need to do is, we want this final product of each of these things, to have the same shape as w. So w is an m by n matrix, and this is just given to you in the problem. We know that delta 3 and delta 4 are m by 1. Why? Because when we computed our delta 3 and delta 4 we just took the elementwise product of whatever was up here, so it's still going to remain m times 1.

45:29 Finally, we know that x1 and x2 are both n by 1, since they are column vectors. So if we want to, we know that this is delta 3 and we're going to have to multiply it by the xs in some way. So we see that if we want our final to be m times n, we're gonna have to do this expression times the transpose of this. So this is equal to the delta 3 times w1 transpose.

46:00 Plus delta 2, sorry, delta 4 times, sorry, Delta 3 times x1 transpose + delta 4 times x2 transpose. And finally, we want to add this expression. And again, I will leave this for you to show on your own time that the derivative of this Frobenius norm, the 2 cancels out with this. And you're just left with lambda w, okay? Yes? >> >> So the question was, what happens if you run into some sort of ambiguity over here.

47:22 So the nice thing about when we're, since, at least for computing the neural network models that we are looking at for the midterm, and. The only tractable problems that we're going to be computing gradients over are things like linear transformations and activations over those, which are already the key operations that you use in neural networks. Apart from things like cross entropies and other losses at the top. So in most of those situations you won't really run into ambiguities.

47:50 And when you do, you just go back to deriving things using like, Traditional matrix calculus, so you just dig deeper. Like if you dug deeper into how these dimensions work out, it should still work out. So you just won't find ambiguities in these types of problems, okay. I will quickly run through my second example. Okay. Okay, so the next example that we are looking at.

48:25 Suppose, you wanted to build a word vector representation that you, and couldn't decide whether you wanted to have a hidden layer that is activated by a sigmoid. Or you cannot decide whether you wanted a hidden layer that is activated by a ReLU. So the only thing better than making a choice is to do both of them. So what we're going to do is we're going to have a network, Where at the top, we're going to have a cross entropy over some prediction y, that takes n from z3.

48:57 So over here, we're going to have some input that flows through both of these variables. So here, we have xW1 + b1. So we're going to apply a linear transformation over our input x, and then sigmoid activate it to produce this hidden layer. Over here, we're going to have a different linear transformation with two other parameters, two other matrix and BIOS term. But here, we're going to ReLU activate it.

49:27 Then we're going to add our h1 and h2. At z3, we're going to, Guess our score vector which is z3, and then we apply the cross entropy to that, okay? That's your model. It's like are the word vector representation we did in assignment one except now, we have two branches that take the input twice. So what we want to compute at least for this question is what is the partial of J with respect to X, okay?

50:03 So the nice thing about this problem is that we already know how to compute the derivative of our J with respect to z3. Since z3 is the input into our cross entropy, and we did this in our homework. So the partial of J with respect to z3 is just going to equal to y hat minus y, as we already know. And this is going to be our first r signal. So we already know what the errors from J flowing down to z3.

50:27 And we're calling that delta 1, okay? The next thing we see is that the partial of z3 with respect to h1 and h2 are actually equivalent. Cuz if we know what the partial of z3 is with respect to this sum, since the gradients of h1 + h2, with respect to h1 is just 1. And similarly, with h2, we can simply write down the partial of J with respect to h1 is equal to the partial of J with respect to, sorry, partial of h2.

51:00 Which is equal to the partial of J up to z3 times the partial of z3 over partial of h1 + h2. And what we need to do here is again, some matrix balancing. Since we know that h is a row vector. And I forgot to specify, but this is actually pretty crucial, and this is the next slide.

51:31 I did convert this problem into the exact same model except using row vectors. Just to show you that the way we do dimension balancing in a row vector versus a column vector situation is basically exactly the same. So we have h being 1 times m. And our W3 is m times k, is m by k. Our delta 1 is also 1 value K. So what we can see is that if we wanted to multiply our error signal from above by what we know is going to be the derivative with respect to h1 + h2, we're going to need to transpose our W3, and multiply our delta 1 by that transpose.

52:15 So going up here, I'll just write an equal sign. This is, I'm continuing this line over here. That is just equal to delta 1 by W3 transpose. And I'm going to call this delta 2. And then I'm going to fill in my error gradient flowing down here, okay? Moving over to this side, if we wanna move down the branches, we now wanna compute the derivative of J with respect to z1 and z2.

52:45 So the partial of J with respect to z1 is equal to the partial of J up to h1. There's a partial of h1 up to z1, and that's just going to equal since this is an activation, this is a gradient over an activation function, we again, use our elements y as multiplication, so that's just equal to delta 2. By since on the left branch, we're doing a sigmoid, we're going to have just h1 times 1 minus h1.

53:12 And on the other side, our partial of J with respect to partial of z2. And I'll just skip writing out, I won't write out the chain rule for the sake of time. That's going to equal our delta 2 by the gradient of the ReLU activation function which is 1. If our z2 is greater than 0 based on the value as we it saw earlier. And we're going to call this, delta 3, and this, delta 4. So I'm gonna fill in the deltas in my graph, okay?

53:48 Awesome. So the last thing we're gonna do, and I'm again, running out of space, Is to compute the gradients with respect to x, which is what what we wanna do. So the partial of J with respect to x is going to equal the partial of J up to z1 times the partial of z1, respect to x. Plus since we're working with our derivatives x appears in both branches, it's going to equal the partial of J with the respect to z2, partial of z2 with respect to x, okay?

54:26 And what we're gonna do is matrix bouncing one more, since we're taking derivatives over a linear transformation. So we wanna make sure our dimensions balance out. So we know from the problem statement that x is a row vector. So it's, okay? All right, W1, W2 are by n by m, and that's just given from the problem formulation. So, since x is and, We're gonna need to compute, we're gonna need to multiply our error signals by this being transposed.

55:05 Since we want the n to appear on the right hand side. And although, I didn't write over here you can see, you can prove to yourself that delta 3 and delta 4 are 1 by m. So this final expression, and going down here. Since we need to transpose this, it's going to be the error gradient up to this point. So delta 3 times our W1 transpose, since W1 appears on the left side, plus the error signal delta 4 times W2 transpose.

55:43 Okay, I know this is a little bit long winded, but the general approach that we're using is to first of all, build the graph of our variables Starting from J, we compute the derivative going down and at each point, we mark what the error signal is up to that point. After that, we apply our chain rule, where we compute the derivative of our current variable times our new thing going down, and we multiply that by our error signal coming from above.

56:10 And we use matrix balancing to make sure our products work out. Are there any questions. Yes. I would say yes, since it helps you keep track, it helps to keep track of derivatives up to a certain point. And it also helps you if you can just take my current error signal, specify what the dimensions of that are. It's very easy to make sure that your dimensions balance out, when you compute my error signal by what follows afterwards.

56:46 I mean, you don't have to, but it certainly is a way. Of keeping your calculations clean and organized. For the sake of time I'm going to move on to the next section, but we can take all questions about back log after the lecture. So my last slide, and you can look this up later. Your menu for success, I recommend doing all of them, is to write down your graph, compute the derivatives from the top down, keep track of your error signals, and force that the dimensions balance out.

57:12 And yes, that is it, thank you. >> Cool. Hi everyone. So our men are probably some of the coolest architectures that you've learned in this class, and and I may have the pleasure unrolling them a little bit further for you. So cool. So let's time write in to it, we'll also share some material questions from past exams. So here, you now have a distributed representation of each patient note.

57:42 You assume that a patient's past medical history is informative of their current illness. As such, you apply a recurrent neural network to predict the current illness based on a patient's current, and previous note-vectors. You also explain why a recurrent neural network would be better than a feed-forward network, in which your input is summation or average of past and current note-vectors. So you can talk to your neighbors, just like take a minute to discuss this problem and figure out why an RNN would actually be better than a feed-forward one.

58:48 Great, are there any suggestions? Are there any suggestions, to why our RNN might be better than feed-forward ones? I'll try to repeat what you just said, you can correct me if I'm wrong.

59:22 So you said that the RNNs, they can do something specific for a particular patient, and while if you sum them up they wouldn't. Okay. And thanks. Are there any other suggestions as well?

60:03 Mm-hm, and so what you just said, and again, you can correct me if I'm wrong, is that the more recent information about this patient might be more relevant. And that is something that an RNN could capture, which a feed network might not be able to capture. Mm-hm. Yeah, so what I just said right now is that, and there is some time dependency in this data, since we have a sequence of a patient notes.

60:38 And if we were to sum them up together, we lose that temporal information. And so these are all very good answers. And I do want to comment just on the first answer, I think there might have been a slight misunderstanding. So we are not summing up across different patients. I'm summing across the nodes for the same patient across time stubs. And I think that was probably just like maybe it wasn't phase super clearly. And what the other people said was and also correct.

61:03 So one thing is that RNNs can take in more recent information into account. And in a more general sense, they can take in temporal relationships into account, which we would ignore by summing up or arching over them. Very nice. Cool, so in order for us to see this more, yes, there's a question? The question was on what advantage would an RNN give us over taking a weighted average.

61:37 Often note-vectors, well if you do, weighted average we actually had to come up with the weights for on the particular notes, which we actually don't really know beforehand. And the idea of like chaining an RNN here, is that like the RNN might potentially be able to learn to what extent it should take in. Really old notes into account versus perhaps like more recent ones, so we don't want to predefine those weights. Does that make sense?

62:10 And we can also talk about that after class as well. Great. So let us take a really quick look at the RNN structure. So this is a very simple vanilla RNN. They key points are the weights are shared across timesteps. We also call them oftentimes tied. And the core of an RNN is the hidden state, and the hidden state depends both on that previous hidden state, so kind of like capture some of that memory from earlier as well as the new input, and that back propagation RNN happens across all timesteps.

62:39 And you should have seen that on the assignment two. And RNNs because of their architecture are very suitable for learning representations for sequential data, that has sometimes temporal relationships. And the predictions can be made at every timesteps, so you can have a y as can be seen in this figure over here. You can make a prediction every timestep or you can make can at the end of the sequence, depending on whatever your application might be. So in our key, RNN's come to use a special when we do language modelling.

63:10 So language modelling is the tasks of computing probability distributions over a sequence of words, so that can be for example seconds or a document. And language modeling is very important, when we are doing things like speech recognition, text summariztion and so on. So in an RNN, when we want to use it as a language model, would be passing at every time subsidy inputs Xt, are our word embeddings. And you could use word embeddings, for example, that you produce with word and or glove.

63:41 So you pass it at every timestep. And our prediction is just the next word in the sequence. So we can use that as our task in order to train this RNN. And the idea is that the hidden representation at the end. So if you take the hidden representation at the last time stamp, on our trained RNN, capture some of the semantic meaning of that sentence or sequence of words. So that can be, for example, used for translation, which is something you saw, or you saw on Tuesday I think, which Richard presented.

64:14 So here, this is actually a RNN which have an encoding part and a decoding part. So for the encoding part, that's your first RNN. You feed in the word embeddings for the German words, so. And then you pass in that hidden representation which captures the meaning of the sentence into the second RNN. So the weights are shared across the first RNN, and they're shared within the second RNN. And a second RNN is a decoder which produces the English sentence here.

64:44 So this is one example of using this type of RNN as a language model for a translation. Okay, so the problem though with the vanilla RNNs is that we can see the problem vanishing gradients. In back propagation, when we do back propagation RNNs, there is a recursive gradient call on the hidden layer. And so that's basically since we define a hidden layer in terms of its P precedent layer. And the magnitude of the gradients off the typical activation functions that we'd use, like ton H or sigmoid are between 0 and 1, which causes, and if you multiply a number that's smaller than 1 multiple times, what happens is that the number will shrink very quickly.

65:25 And if it shrinks very quickly, essentially what happens is that you final, gradient will be close to 0. And if your gradients are close to 0, then essentially means that you're not updating your parameters. And that also just means that your RNNs don't really learn. So in order to address this issue, this is like why people have worked on many of the different architectures and GRUs, LSTMs were some of the more popular ones. Yes, there's a question?

66:11 Okay, I should also repeat the question. So the question was, can we adjust the vanishing gradient problem by using a different activation function, something like a volume? Yeah, okay, sorry. And your second part was what? Yeah, we can also discuss this after class, too. Yeah, and so good question there.

66:41 Okay, so GRUs and LSTMs to the rescue. So I'll talk briefly about GRUs, Gated Recurrent Units. So the addition here is that we are introducing gate. So we have a reset gate, and an update gate. And you can intuitively understand these gates as they're controlling the long term and short term dependencies. To what extent we want to memorize things from the past? And to what extent to we just want to take something from the current input?

67:07 And that might be also something that you might see or like. It's related to what we talked about with patient notes. It's kind of this network might be able to learn whether I should only look at the last patient note, or whether I should take like the entire history into account? So and this is a more visual representation of a GRU games. So you can see that the input, X team over here, is fed into both of these gates, which are sigmoid functions.

67:33 And it's also fed into this other one, which calculates H tilde. So this is Kind of a first initial hidden state, but in order to decide whether we really want to use it, we are using the z factor over here, to decide whether we just want to use the previous hidden state, or if you want to update it to the H tilde, And this might also be a picture if you wanted to look at it again.

68:01 It's on our blog, so you can just try to figure out how this information is flowing and there. But in order to just get some more intuitive understanding of how GRU works, we are going to do some exercises together. So first, try to figure out what the dimensions are off the ws and the u matrices in here. And you can write it in terms of the x, dimension of x and the h, which is the dimension of h.

68:29 Again, you can just take a minute and try to figure that out. And you can also discuss again with your neighbor.

69:04 Since we are running a little bit out of time, I'm just gonna go ahead and explain how I would approach this problem. So first, you know that ht, the hidden vector h has dimensioin h just by definition. So I'll write a little bit bigger, okay. So this is just by definition, and we also know that ht minus 1 was also has mentioned dh, which means 1 minus zt, so zt itself needs to have to mention the dh as well, right?

69:39 Since we are doing a aliments bite operation in the fourth equation over here. So it also shows us that H tilde, suggest by looking at the last equation, H tilde means half dimension dh as well. And now, that we know that H tilde has dimension dh, then we can go into the third equation over here. So we know that the product of W and xc has to give us something with dh.

70:11 So that tells us that the matrix W, Needs to have dimension dh, and dx. Is this clear to everyone? Cool, I see a couple nods, okay. So similarly, if you look at the matrix u in there, we know that like the result of u, ht minus 1 needs to be dh. so percent should be dh.

70:43 And since we're multiplying it with a hidden vector, the second dimension should be dh as well. And you can apply a similar approach to figure out the dimensionality for the other matrices as well. Cool, and true or false question. If the update gate is close to 0, the net does not update its state significantly. Yeah, this one should be pretty obvious if you look at the fourth equation, because in that case, you're essentially just setting ht to ht minus 1.

71:19 And this also shows that if the network learns that zt is pretty close to 0, that just means that we are essentially using our input from the first time. So essentially, this means that your input from a long time ago still matters a lot in the future. Okay another related question, if the update gate is close to one, and a reset gate is close to zero, the net remembers the passing very well, true or false.

71:54 Yeah this is actually very similar to the first question, so again you can just set them on z t to 1 r t to 0 in these equations. And you'll find out that in this case, h t would depend very strongly on the input, since we're essentially saying that this term over here becomes zero. And we're only using the x t part of it. Okay, so Joee will now talk about LSTMs.

72:28 >> So, I’ll just run through LSTMs really quickly. LSTMs are kind of similar to GIUs except they are a more common model. So, instead of just having two gates, now we have multiple gates. One is the input gate, which decides how much weight should we give to the current input or the current word that we are looking at. The ft gate or the forget gate will decide how much we want to forget our past, how much you want to remember the past or just forget it.

72:59 The new gate ot, which is a little bit different, is how much we wanna expose our current cell to future. So combine the ot from the current, combined with the ft from the future will decide how much all of memory will be use in any other future node. So you can see how adjusting this can decide like whether you just wanna remember the B minus 3 times 3 but not, T minus 20 minus 1. Instead of just going linearly backwards, I'm having to remember everything from the past.

73:32 So, all these gates are computered using a Sigmoid because that's between 0 and 1. And that makes sure that when you are doing the dot products of, sorry, the micro dot products, in the end, you'll have kind of like a probability distribution of not just completely forgetting, which would be zero. Or completely remembering which would one, but a fuzzy possibility of remembering a little bit or forgetting a little bit. Does that make sense? Another difference between LSTMs and GRUs is the ct and ht node, so now you don't just have one memory, you have two memories.

74:07 And these define different things. Like the ct would define exactly what your memory is, while your ht defines in your it, ft, and ot, how much or how you want to remember the ht minus one memory. Or how much your memory should be remembered by the future. So instead of just having one, now we have two. These have a certain number of disadvantages, for example there are a lot more parameters now, which means you need more space.

74:39 Which means you need more learning, and which also means you need much more training data, so that your model doesn't start warpening. And empirically, GRUs and LSTMs have been, are very close in results. So in the end it's a trade off on how much accuracy you want, compared to how much you are willing to use your resources on training time and training data. So here's a quick illustration. The lower row corresponds to your ht flow, while the upper row corresponds to your ct flow.

75:12 And both of them are memories and they interact with each other which means they are not completely independent. But they represent different ways in which your future, or your next words will be using your current word. Yeah, question? So the question was can you give a little bit of intuition on what is the difference between c and h, and so if you see from the formulae, the edges are present, or the edges decide on what your input gates, your fts or ots will be.

75:54 So they decide how much you want to remember or forget or expose yourself. While your cts are the ones that are actually being used in the future. So they are the ones that are combining with the gates. And so, basically it's like saying your hts will decide the fuzzy probability of how much you want to remember, and how you want to remember, and your ct will kind of decide what you want to remember from the previous states.

76:20 This is just like illustration, it's not exactly like that. LSTMs might learn something differently. Depending on your problem statement. But that's like a rough way of how you can think about it. Great, so the question was will we have the equations. And, yes, all the equations for RINs, or LSTMs or GRTs will be there, so that you don't have to remember them. Also, you are allowed a cheat sheet, so to be honest if you wanted to remember it, just write it on your cheat sheet, and you can bring it.

76:56 So we'll just go to the midterm questions really quickly because we are running out of time. If xt is the 0 vector then ht = ht -1. It is true that ht will depend primarily on ht -1 but it won't be exactly equal because of the non-linearities and the multiplication with the parameters. So that's an embodied difference. The second question is if FD is very small or 0, then error will not be back-propagated to earlier time steps.

77:24 Again, intuitively it feels like because the FD is 0, they are trying to forget. But that is not true, because it and ct still depend on ht minus 1, and hence the error will still back propagate. So, one easy way to do it is just look at the mat, see what depends on what, and see how the rows are actually back-propagating. The next question is if either entries ft, it and ot are negative, and we see that the sigmoid activation is used, which is the range is between zero and one.

77:53 And so they're always non-negative. And, as I said, that just represents the fuzzy probability. Which brings me to the next question, can they be viewed as probability distributions. And the problem with viewing them as probability distributions is that they do not sum to one, like any probability distribution should. So these are applied independently of the element and thus they have no requirement of having to sum to one. So, this is just like an intuition of probability, but it's not exactly probability.

78:24 Does that make sense to everyone? Any questions? Okay. So, very quickly we'll go dependency parsing. So, these are two views of linguistic structures, we haven't seen which was constituency structure, we'll be seeing it for later. But basically it uses a kind of c f g model where you decide which phrase is broken down into what words. What we are seeing is dependency structure, where we decide what word depends on what other word in the sentence and how they depend on each other so what modifiers are used.

79:00 Just some properties about dependency parsing. One, it's a binary asymmetric relation with words. It's binary, which means two words are related to each other, no more and no less. It's asymmetric, which means one word depends on the other, but not the other way around. In this case, the dependent depends on the head. Which are the terms that we'll generally be using. And the arrows when you're drawing the dependency tree will go from the head to the dependent.

79:25 They usually form a connected, acyclic, single-head tree. And to make sure that this happens, we also add a fake root node so that one of the words will always have the head as a root node. And this also makes sure that every word has a head. And none of the words are just standing. And in the rare cases where you have a disconnected tree, the root known make sure that all of them are connected into a single tree.

79:51 Any questions? Okay. So we saw two different types of dependency parsing. One was the greedy deterministic transition based parsing. We've just seen this in the assignment right now so I am sure it's all fresh in your memories. You have a stack, a buffer, and a dependency list. Initially the buffer will be full of the words in your sentence, in order. So that will act like a queue structure. Your stack will act like a stack structure so that you pop from the top of this chart.

80:24 And whenever you do this shift transition, you take something from the top of the queue and put it onto the stack. The left toll will take the top two elements from the stack, and make an arrow from the first element to the second element, and just remove the second element. And this can be seen from the example here, which you can just scroll through the slides and go like decide. Now, how do we decide which transition to use?

80:50 This is generally done by some kind of a classifier, you could use multiclass as SVMs or any other kind of machine learning classifiers that you know of. The features that any machine learning involves need, so here we'll use the features, and you can always add more features. But the typical features that are generally used is the top of the word on the stack, the first word in the buffer, and maybe a lookahead on what words are gonna come next.

81:16 And also the dependence of the current word in the stack. And now that we have all the words, we also use the parts of speech of all these words. So generally we know that adjectives and nouns already likely to be dependents or connector, so that there's something that you would want to use as a feature. Yeah, those are kind of what dependencies that we have already figured out until now. And using all of these, we try to get what kind of transition we want to do next.

81:42 And define the valuation metric that we use is either UAs, if you're not typing the dependency from one word to another. Or LAS, which is the liberal attachment school which types their attachment from one word to another, and these are basically kind of like accuracies. You can think of them as accuracies. Okay. So one thing that we saw was projectivity and how we can handle cases where the non-projectivity comes in. And what projectivity means is that there are no arrows that cross each other when you put them in a horizontal line.

82:18 And why this would be a problem, is if you go back to this kind of a parsing mechanism, here the from and who will never be next to each other on a stack. And thus, left arc or right arc will never be able to get the dependency between from and who. And, so how do we handle something like this? One simple thing would be, you just declare defeat. You just say that okay, these are really, really rare cases.

82:44 And if you don't care about your accuracy as much and you don't want to complicate your model a lot, then you can just leave them as it is and let them decrease your accuracy a little bit. If you want to handle them, one of them would be to use a post resistor. So you go through the entire parsing mechanism and in the end, you use some kind of a post-processor to identify which ones have been parsed strongly and try to dissolve them.

83:08 This can be done using multiple methods like classifiers or other things. The last one is you use a completely different parsing mechanism or you make slight modifications to the ones that already exist. So in the greedy transition based parsing, you could add a transition, let's say swap where you just swap the elements that are already in the stacks so that you bring the element that is at the bottom to the top and then you can either lift right down to it.

83:36 There are other more complicated ways of doing it, and those can also be done. Finally, we have the neural dependency parsing. So one problem with really the domestic parsing that we saw was the features were all one-hot vectors, where it was either a word or a part of speech. And we have seen a lot of problems with one-hot vectors before. One is that, you don't have the semantic representation of the word. So if two words are actually similar in either a grammatical sense or meaning wise, you don't understand digest because of the one-hot vector notation.

84:13 And an easy way to do some, to solve something like that is using an embedding matrix. And here, we'll not only be using embedded matrix for the words but also the parts of speech and the dependency labels. And all of these are then added into one feature stack or a feature drawer and they are put into a black box which would be any unit that you want to use. For example, here you are using a hidden layer and a soft max layer.

84:37 But that black box can be any neural network and then finally, you use classification to decide what transition you want to do. Any questions on dependency parsing? And I know this was a little quick but we are running out of time so. Okay, so there are just a couple of acknowledgements and all the best for your exam. >>

© transcribe · For agents Built with care and craft by Gokul Rajaram