# Conversational AI over Military Scenarios Using Intent Detection and Response Generation
## 3 Methodology
### Response Generation
\[Cosine(A,B)=\frac{(A\cdot B)}{(|A|\times|B|)} \tag{6}\]  
\[TFIDF=\frac{tf_{i,j}}{\sum_{k}n_{k,j}}\times log\frac{|D|}{\{j:t_{i}\in d_{j}\}} \tag{7}\]  
In the above, \(X\) and \(Y\) are discrete random variables, that is, the correlation between the entity sets of the user query and the candidate sentence. The question generation module generated new queries based on the template-based representation of the intent-entity relations of queries. The structural composition was viewed as a set of intent-entity relationships within the state space, as shown in Figure 3. The intents of a question included who, where, when, and what, whereas named entities were in six types: person, unit, event, time, weapon, and document (Doc). Candidate sentences could be formed based on the occurrence probabilities of the intent-entity relationships. For example, the intent \"who\" and entity \"event\" was related by \"be responsible for\" in \"the commander (who) is responsible for this combat readiness mission (event).\" In general, as a response should also have a person as the intent (who) and a combat readiness mission (event) as the entity, the candidate sentences should be ranked according to the presence of the \"event\" entity and \"who\" intent in these sentences. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**No.** & **Feature** & **Description** & **Value** \\ \hline
1 & Location & Military location or organization entity & yes/no \\
2 & Person & Personnel name, rank and title entity & yes/no \\
3 & Time & Time descriptor & yes/no \\
4 & Event & Military event & yes/no \\
5 & Weapon & Weapon or transport entity & yes/no \\
6 & Document & Military document name & yes/no \\
7 & Unit & Commonly used quantifiers in military affairs & yes/no \\
8 & LCS & Common strings between user’s query and system response & \([0,1]\) \\
9 & Cosine & Similarity between user’s query and system response & \([0,1]\) \\
10 & TFIDF & Word importance for user’s query and system response & \([0,1]\) \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Features of the learning to rank (LTR) model. In the question generation module, the predicted intent types and the queried entities are combined according to the intent-entity relations shown in Figure 3. Table 6 shows some examples of such parsed sentences. Brackets correspond to slot-fill annotation entities, and bold corresponds to intent types. Templates can be applied in various combinations. To select the best new question from candidate sentences generated by multiple templates, we define Equation (8) to score each query-new-question pair. The higher the score, the stronger the semantic relevance between the newly generated question and the original query. \[QQ_{i}=\alpha(LCS_{i}+Cosine_{i})+(1-\alpha)TFIDF_{i} \tag{8}\]  
In this equation, \(i\) refers to the candidate sentence generated by the \(i\)-th rule for the same intent; \(\alpha\) is a weighting parameter that ranges from 0 to 1; LCS is the longest common subsequence between the user query and generated query; Cosine is the cosine similarity between the user query and generated query; and TFIDF is the importance of words around user's query, which is calculated the product by term frequency and inverse document frequency. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**No. ** & **Intent** & **Entity** & **Templates** \\ \hline \multirow{3}{*}{1} & Who & Doc. & Who + is in charge of + [Doc.]? \\ \cline{2-4}  & Who is in charge of personnel management? \\ \hline \multirow{3}{*}{2} & Who & Person & Who + [Person] + reports to? \\ \cline{2-4}  & & Who does the Chief of operations need to present the brigade combat plan. \\ \hline \multirow{3}{*}{3} & Who & Event & Who + is in charge of + [Event] \\ \cline{2-4}  & & Who is responsible for field lighting? \\ \hline \multirow{3}{*}{4} & Who & Unit & Who + are in the +[Location]? \\ \cline{2-4}  & Who are in the disaster relief team? \\ \hline \multirow{3}{*}{5} & When & Event & When + the + [Event] + will happen \\ \cline{2-4}  & & Who will the joint drill happen?