# Query Matrix

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

## What is Query Matrix?

**In one sentence:** The query matrix is a grid of learned weights that turns each word's numbers into its query.

Every token starts as an embedding. Multiplying it by the query matrix creates the query vector for that token. The model learns the best values for this matrix during training, so it learns which questions each word should ask.

![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 Matrix?

In a model with 4,096-number embeddings, the query matrix might be 4,096 by 4,096 numbers.

## Why does Query Matrix matter?

These learned matrices are a big part of a model's parameters and its skill at attention.

## Related Concepts

- [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.
- [Key Matrix](https://getaimath.com/dictionary/key-matrix/): The key matrix is a grid of learned weights that turns each word's numbers into its key.
- [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.
- [Value Matrix](https://getaimath.com/dictionary/value-matrix/): The value matrix is a grid of learned weights that turns each word's numbers into the value it shares.
- [Query (Q)](https://getaimath.com/dictionary/query-q/): In attention, the query is a list of numbers that represents what a word is looking for in other words.
- [Attention Scores](https://getaimath.com/dictionary/attention-scores/): Attention scores are numbers that show how much each word should focus on every other word.

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