Natural Language Processing
Let the query choose what contributes
BOTIE
Examples, experiments and workspace controls
Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.
Try your own inputs
Set both query coordinates to zero and inspect the attention shares. Then change just one source word's value. Can you explain its influence on the answer from the share that word receives? Keep the key dimension consistent with the vectors.
Context for this challenge
Produce the three attention weights in the / red / door order.
Let's return to translation. While producing one target word, the model may need one part of the source sentence; at the next step it may need another. Our source is 'the red door'. The key rows and value entries follow that word order. We will keep them fixed and change the query to see how the contribution from each source word changes. These invented vectors illustrate one value coordinate, not a trained translator.
Inspect the component calculation
Softmax(
Score vector: Divide(
Amount: Matrix times vector(
Rows of coefficients: Keys for the / red / door
Input vector: Translation step query
)
Divisor: Square root(
Squared value: Key dimension
)
)
)Examples and results
- Keys for the / red / door
0 0 1 0 0 1 - Translation step query
- 02
- 10
- Key dimension
2
- Required result
- 00.1636
- 10.6728
- 20.1636
Try a fresh construction
This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.
Stuck? Inspect a worked construction
The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.
Assumptions and test precision
This is a small construction problem. The lesson explains the assumptions and the parts of the full method that this example leaves out. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.
Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.
The query has no preference
This check uses the pieces from “Follow a translation query into its value mixture”.
BOTIE
- Translation step query
- 00
- 10
- Keys for the / red / door
0 0 1 0 0 1 - One value coordinate per source word
- 0-3
- 16
- 212
- Key dimension
2
Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.
Build a construction in the workspace above first. This case will test those pieces.
Why can the most attended word change without the output equalling that word's value?
Attention forms a weighted mixture rather than selecting exactly one source row.
This is a small construction problem. The lesson explains the assumptions and the parts of the full method that this example leaves out.
Work through the Python challenges →