liveBook · Manning

Query

As explained in Deep Learning with Python, Third Edition

An attention query is a vector representation of the information sought by an input position, compared with key representations to determine which information to attend to.

In attention, a query represents what the model is looking for. It is compared with keys to score relevance; those scores weight the values that are combined. In sequence models, the query can come from the target sequence, while keys and values come from the source. section 15.3.1

Figure 15.6 Retrieving images from a database: the query is compared to a set of keys, and the match scores are used to rank values (images).
query key value

A photo-search analogy: compare the query with photo tags (keys), then use match scores to rank the photos (values). section 15.3.1

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines queries through the search analogy and explains their role in parameterized dot-product attention.
Examples
Uses photo search and target-to-source sequence attention as examples.
What you can do after
Build attention from scratch by scoring queries against keys and using the scores to combine values.
How it connects
Connects queries with keys, values, softmax, and dot-product attention.

Also explained in

Compare how 7 books explain query →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.