# Query (Q)

- **Canonical URL:** https://getaimath.com/dictionary/query-q/
- **Topics:** [Transformer Architecture](https://getaimath.com/dictionary/category/transformer-architecture/)
- **Last updated:** 2026-11-25

## What is Query (Q)?

**In one sentence:** In attention, the query is a list of numbers that represents what a word is looking for in other words.

Each word creates a query, which is like a question: "Who is relevant to me?" The query is compared with every other word's key to find good matches. Better matches mean more attention.

![Transformers & Attention: The Smart Highlighter — Simple cartoon diagram showing how a Transformer reads a whole sentence at once and shines a bright highlighter beam from the word "IT" back to "trophy" so it knows what "IT" means.](https://getaimath.com/diagrams/transformer-architecture.png)
*Napkin Diagram (Transformer Architecture): Older AI read word-by-word and often lost track of earlier words; a Transformer highlights which words connect to which.*

## What is an example of Query (Q)?

For the word "it," the query might effectively ask "Which earlier noun am I talking about?"

## Why does Query (Q) matter?

Queries are one-third of the Q, K, V system that powers attention.

## Related Concepts

- [Multi-Head Attention (MHA)](https://getaimath.com/dictionary/multi-head-attention-mha/): Multi-head attention runs several attention processes side by side, so the model can notice different kinds of relationships at once.
- [Key (K)](https://getaimath.com/dictionary/key-k/): In attention, a key is a list of numbers that describes what a word offers, so queries can find it.
- [Attention Mechanism](https://getaimath.com/dictionary/attention-mechanism/): An attention mechanism is a way for a model to focus on the most useful parts of its input when producing each piece of output.
- [Value (V)](https://getaimath.com/dictionary/value-v/): In attention, a value is the actual information a word passes along when another word pays attention to it.
- [Self-Attention](https://getaimath.com/dictionary/self-attention/): Self-attention lets every word in a sentence look at every other word and decide which ones matter most for understanding it.
- [Query Matrix](https://getaimath.com/dictionary/query-matrix/): The query matrix is a grid of learned weights that turns each word's numbers into its query.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/query-q/)
