concept sentence in category deep learning

This is an excerpt from Manning's book Deep Learning for Search.
Neural search is about integrating DL and deep neural networks into search at different stages. DL’s ability to capture deep semantics lets us obtain relevant models and ranking functions that adapt well to underlying data. Deep neural networks can learn image representations that give surprisingly good results in image search. Simple similarity measures like cosine distance can be applied to DL-generated representations of data to capture semantically similar words, sentences, paragraphs, and so on; this has a number of applications, such as in the text analysis phase and in recommending similar documents. At the same time, deep neural networks can do more than “just” learn representations; they can learn to generate or translate text, and how to optimize search engine performance.
Listing 2.13. Fetching sentences for word2vec from the Lucene index
public class FieldValuesSentenceIterator implements SentenceIterator { private final IndexReader reader; #1 private final String field; #2 private int currentId; #3 public FieldValuesSentenceIterator( IndexReader reader, String field) { this.reader = reader; this.field = field; this.currentId = 0; } ... @Override public void reset() { currentId = 0; #4 } }
The CBOW model is expanded so that the input layer also contains the label of the document containing the current text fragment. During training, each text fragment is tagged with a label. Such text fragments can be entire documents or portions of a document, like sections, paragraphs, or sentences. The value of the label generally isn’t important;[3] a label can be doc_123456 or tag-foo-bar or any kind of machine-generated string. The important thing is that labels should be unique within a document: two different text fragments shouldn’t be tagged with the same label if they don’t belong to the same piece of text.
As you can see in figure 6.2, the architecture of this model is similar to CBOW; it just adds an input label representing the document in the input layer. Consequently, the hidden layer needs to be equipped with a vector for each label, so that at the end of the training, you have a vector representation for each label. The interesting thing about this approach is that it allows you to handle documents of different granularities. You can use labels for either entire documents or smaller parts of them, like paragraphs or sentences. These labels act as a sort of memory that wires contexts to (missing) words; therefore, this method is called the distributed memory model of paragraph vectors (PV-DM).
In the case of documents like “riemann hypothesis - a deep dive into a mathematical mystery,” it makes sense to use a single label, because the text is relatively short. But for longer documents, like Wikipedia pages, it may be useful to create a label for each paragraph or sentence. Let’s pick the first paragraph of Riemann’s Wikipedia page: “Georg Friedrich Bernhard Riemann (17 September 1826 – 20 July 1866) was a German mathematician who made contributions to analysis, number theory, and differential geometry. In the field of real analysis, he is mostly known for the first rigorous formulation of the integral, the Riemann integral, and his work on Fourier series.” You can tag each sentence with a different label and generate a vector representation that will help find similar sentences instead of similar Wikipedia pages.
The reason it’s called a thought vector is that it’s meant to be a compressed representation of the input text sequence, which, when decoded correctly, generates a desirable output sequence. Seq2seq models, as you’ll see in the next chapter, are also used for machine translation; they can transform a sentence in an input language into a translated output sequence. You want to extract such thought vectors for the input sequences (documents, sentences, and so on) and use them the same way you used paragraph vectors to measure similarity between documents.