llm Client-Side Only

Query-Key-Value (QKV) Numerical Playground

Interactive step-by-step matrix laboratory: inspect Q × Kᵀ dot products, division by √d_k, Softmax normalization, and weighted V sums.

Concept Breakdown: The Role of Query, Key, and Value Vectors

1. The YouTube Search Analogy

Query (Q) is what you type in the search bar. Key (K) is the title/tags of every video in the database. Value (V) is the actual video clip you watch.

2. Matching Query to Keys

The AI compares your Query against all Keys. The closer the match, the higher the score. It then pulls together a blend of the matching Values based on those scores.

3. Live Interactive Math

Edit any cell in the Q, K, or V tables below. Watch the dot product scores, softmax percentages, and final blended outputs update instantly!

QUERY MATRIX (Q)3 tokens × 2 dim
t1
t2
t3
KEY MATRIX (K)3 tokens × 2 dim
t1
t2
t3
VALUE MATRIX (V)3 tokens × 2 dim
t1
t2
t3
Step 1: Raw Dot Product ($Q \times K^T$)
1.400.991.01
0.822.720.26
0.980.480.74
Step 2: Scaled Scores ($/ \sqrt2 \approx 1.414$)
0.990.700.71
0.581.920.18
0.690.340.52
Step 3: Attention Weights (Softmax)
40%30%30%
18%70%12%
39%28%33%

Final Contextualized Output: $A \times V$ (3 Tokens × 2 Dim)

Each token vector now contains a weighted blend of all other token Values based on attention weights:

Updated Output Token t1:[1.40, 1.44]
Updated Output Token t2:[0.90, 2.33]
Updated Output Token t3:[1.42, 1.39]

Quick Reference & Instructions

Simple steps, pro tips, and execution details

1

Provide Inputs

Type, paste, or select your values in the form fields below.

2

Instant Live Analysis

Calculations and formatting happen automatically with zero delay as you type.

3

Copy or Use Output

Copy results or apply the clean output directly to your projects.

How It Works

Allows modifying small numerical matrix values to inspect intermediate products and see exactly how attention values are blended.

Formula & Logic

A=softmax(QKTdk),Output=AVA = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right), \quad \text{Output} = A \cdot V

Frequently Asked Questions

Common questions about calculations, assumptions, and edge cases.

Yes, Query-Key-Value (QKV) Numerical Playground is 100% free with unlimited calculations and zero paywalls or subscriptions.