O'Reilly logo

Hands-On Natural Language Processing with Python by Rajalingappaa Shanmugamani, Rajesh Arumugam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Output module

The output module usually depends on the task at hand. In this case, it is used to retrieve the most appropriate reply from a set of candidates. It does this by first converting each candidate into embeddings in the same way as the input and question modules did, and then taking dot products of each candidate embedding with the context vector from the memory module. For each candidate, we get a similarity or matching score with the context vector. For inference, we apply a softmax function over the similarity values for all the candidates to select the most appropriate one:

    def _output_module(self, context_vector):        with tf.variable_scope("OuptutModule"): candidates_emb = tf.nn.embedding_lookup(self.output_word_emb_matrix,  ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required