Generating [[Vector Embeddings]] for a query with an [[Embedding Model]] to compare to [[Document Embeddings]], after [[Query Transformation]].
Since a search query is already a single string, there is no need to convert it into one. We just have to apply a [[Embedding Model]] to that string. But what model? The simplest approach is to use the same model used for document strings, but this approach has drawbacks. It relies on queries being similar to document strings in vocabulary, format, size, and style, and can break down if this is not the case — such as when queries are significantly shorter than document strings. Ref. [[Symmetric & Asymmetric Semantic Search]].
When queries are substantially different from documents, there's some work to be done. One alternative is to train two models, one for documents and one for queries, in what is known as a [two-tower model](https://cloud.google.com/blog/products/ai-machine-learning/scaling-deep-retrieval-tensorflow-two-towers-architecture). Another approach is [[Query Transformation]], either using a [[Bag-of-documents Model]] or [[Hypothetical Document Embeddings (HyDE)]].
Failure to address the challenge of aligning document and query embeddings is often the root cause of poor embedding-based retrieval.