# Query Recommendation Using Hybrid Query Relevance
## 3 Our Approach
### Query Relevance Based on Query Information  
The query log in the search engine can be divided into different sessions. The queries in a session have the same query intention. We count the number of queries \(q_{i}\) and query \(q_{j}\) in the same session and \(q_{j}\) submitted immediately after the query \(q_{j}\). We define the query pairs as a tuple, \([q_{i},q_{j},f(q_{i},q_{j})]\). So the query log contains many query pairs. The query relevance can be determined by the following equations [7]:  
\[Rel_{session}(q_{i},q_{j})=\left\{\begin{array}{cc}\frac{f(q_{i},q_{j})}{f( q_{i})}&if(Rel_{session}(q_{i},q_{j}))>\theta\\ 0&\textit{otherwise}\end{array}\right. \tag{1}\]  
where \(Rel_{session}(q_{i},q_{j})\) denotes the relevance between query \(q_{i}\) and query \(q_{j}\) based on query co-occurrence in sessions. \(f(q_{i})\) denotes the numbers which \(q_{i}\) appears in the query pairs. \(f(q_{i},q_{j})\) denotes the numbers that query pairs of \((q_{i},q_{j})\) appeared in the query pairs. Due to data sparsity, there are many missing values in calculating \(Rel_{session}(q_{i},q_{j})\). At the same time, we cannot accurately calculate the query relevance if we do not correctly distinguish whether the queries have the same search intention. Therefore, we use query semantics to expand query information by query embedding vectors, better understanding queries. Word2 vec is a good way to train word vectors. The learning process of a vector by word2 vec can be expressed as linear translations. For example, we can find the results of simply computing vector (\"King\") \(-\) vector (\"Man\") \(+\) vector(\"Woman\") is very close to the vector of \"Queen\" [17; 18]. Therefore, taking the element-wise sum or mean of the word embedding over all words in the sentence also produces a vector with the potential to encode meaning [19; 20]. The queries in the search log are usually short, averaging only two or three words. Therefore, we can get the query embedding vectors based on pre-trained word embedding vector by linear combination. Moreover, the word vector of each word in the query is easily obtained through corpus training. It is a time-saving method.  
The calculation of query semantics can be divided into three steps (illustrated in Figure 2):First, each query can be seen as a set of words, represented as \(q=\{q_{w1},q_{w2},\ldots,q_{wn}\}\), where \(q\) is query. The \(q_{w1}\) is the keyword in the query.  
Second, we calculate the query embedding vectors by pre-trained word embedding vector [19] by the following equations:  
\[V_{q}=\sum_{i=1}^{n}word2 vec(q_{wi}) \tag{2}\]  
where \(word2 vec(q_{wi})\) denotes the word \(i\) in the query and \(n\) denotes the number of words in the query.  
Third, we calculate the relevance of query semantics between each query embedding vector via the following formulas:  
\[Rel_{sem}(q_{i},q_{j})=sim(V_{qi},V_{qj})=\frac{\sum_{i=1}^{m}{(x_{i}\times x _{j})}}{\sqrt{\sum_{i=1}^{m}{(x_{i})^{2}}\times\sqrt{\sum_{i=1}^{m}{(x_{j})^{2 }}}}} \tag{3}\]  
where \(v_{qi}v_{qj}\) denote the query embedding vector. \(x_{i}\), \(x_{j}\) denote the value of the query embedding vector \(v_{qi}\),\(v_{qi}\). \(m\) denotes the dimension of vector.  
The query relevance based on query information can be obtained as follows:  
\[Rel_{query}(q_{i},q_{j})=\alpha Rel_{session}(q_{i},q_{j})+(1-\alpha)Rel_{ sem}(q_{i},q_{j}) \tag{4}\]  
where \(Rel_{query}(q_{i},q_{j})\) denotes query relevance based on query information, \(Rel_{sem}(q_{i},q_{j})\) denotes the relevance which calculated by query semantics, \(Rel_{session}(q_{i},q_{j})\) denotes the relevance where queries in same session, and \(\alpha\) denotes weight.