Files
papers/hanzo-search/sections/03-query-understanding.tex

69 lines
2.5 KiB
TeX

\section{Query Understanding}
\label{sec:query}
\subsection{Query Parsing}
Each query is analyzed to extract structured intent signals:
\begin{definition}[Query Representation]
A parsed query is a tuple $q' = (q_{\text{raw}}, q_{\text{expanded}}, c, e, l)$ where:
\begin{itemize}[leftmargin=1.1em]
\item $q_{\text{raw}}$: Original query string.
\item $q_{\text{expanded}}$: Expanded query with synonyms and related terms.
\item $c \in \mathcal{C}$: Intent class (factual, navigational, comparison, how-to, opinion, creative, computational).
\item $e$: Extracted entities (people, places, products, concepts).
\item $l$: Detected language.
\end{itemize}
\end{definition}
\subsection{Query Expansion}
We expand queries using three techniques:
\begin{enumerate}[leftmargin=1.4em]
\item \textbf{LLM expansion}: Prompt a fast model to generate 3--5 reformulations of the query, capturing alternative phrasings.
\item \textbf{PRF expansion}: Pseudo-relevance feedback from top-10 BM25 results, extracting discriminative terms via TF-IDF.
\item \textbf{Entity linking}: Link extracted entities to a knowledge graph, adding related concepts and properties.
\end{enumerate}
\begin{algorithm}[H]
\caption{Multi-Strategy Query Expansion}
\label{alg:expansion}
\begin{algorithmic}[1]
\Require Query $q$, expansion budget $k = 5$
\State $Q_{\text{llm}} \gets \text{LLM.Reformulate}(q, n=3)$
\State $D_{\text{prf}} \gets \text{BM25.TopK}(q, k=10)$
\State $Q_{\text{prf}} \gets \text{ExtractTerms}(D_{\text{prf}}, k=5)$
\State $E \gets \text{EntityLink}(q)$
\State $Q_{\text{entity}} \gets \text{ExpandEntities}(E)$
\State $q_{\text{expanded}} \gets q \cup Q_{\text{llm}} \cup Q_{\text{prf}} \cup Q_{\text{entity}}$
\State \Return $q_{\text{expanded}}$
\end{algorithmic}
\end{algorithm}
\subsection{Intent Classification}
We classify queries into seven intent categories using a fine-tuned DeBERTa-v3-base classifier~\cite{he2021debertav3} trained on 100K labeled queries:
\begin{table}[H]
\centering
\small
\begin{tabular}{lccl}
\toprule
\textbf{Intent} & \textbf{Freq.} & \textbf{F1} & \textbf{UI Component} \\
\midrule
Factual & 31.2\% & 94.1\% & Answer card \\
How-to & 18.7\% & 92.3\% & Step list \\
Comparison & 12.4\% & 91.8\% & Comparison table \\
Navigational & 11.9\% & 96.2\% & Link card \\
Computational & 8.3\% & 93.7\% & Calculator/chart \\
Opinion & 9.1\% & 87.4\% & Perspective cards \\
Creative & 8.4\% & 85.9\% & Free-form content \\
\bottomrule
\end{tabular}
\caption{Intent classification distribution and accuracy.}
\label{tab:intent}
\end{table}