Learn AI Math

Query Matrix

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.

What does Query Matrix look like?

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.

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.