{"id":1969,"date":"2026-10-28T09:12:15","date_gmt":"2026-10-28T09:12:15","guid":{"rendered":"https:\/\/www.interviewbit.com\/varsity\/blog\/?p=1969"},"modified":"2026-10-28T09:12:19","modified_gmt":"2026-10-28T09:12:19","slug":"self-attention","status":"publish","type":"post","link":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/","title":{"rendered":"Self-Attention vs Cross-Attention: A Worked Example"},"content":{"rendered":"\n<div class=\"wp-block-group vlf-insights is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"vlf-insights-title wp-block-paragraph\">Key Insights<\/p>\n\n\n\n<ul class=\"wp-block-list vlf-insights-list\">\n<li>Self-attention allows tokens to exchange information within the same sequence, creating context-aware representations.<\/li>\n\n\n\n<li>Cross-attention connects two sequences by using queries from one sequence and keys and values from another.<\/li>\n\n\n\n<li>Both mechanisms use scaled dot-product attention: query-key scores are scaled by the square root of the key dimension, passed through softmax, and used to combine value vectors.<\/li>\n\n\n\n<li>Multi-head attention runs several attention operations in parallel, allowing Transformers to learn different relationships between tokens.<\/li>\n\n\n\n<li>Masked self-attention uses a causal attention mask to prevent autoregressive decoders from accessing future positions during generation.<\/li>\n\n\n\n<li>In encoder-decoder Transformers, cross-attention allows decoder states to retrieve relevant information from encoder outputs; related mechanisms can also connect modalities in multimodal models.<\/li>\n\n\n\n<li>The attention score matrix has dimensions <img decoding=\"async\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAASCAYAAAApH5ymAAAABHNCSVQICAgIfAhkiAAAAAFzUkdCAK7OHOkAAAFbSURBVEiJ7dIxSFVRHMfxj8+SLEJ4FmSEED1ossHn0GDYGAmvxQaXCp\/Uc7KgBgdXwamhBnnQEM4KzQUtRQUOTQ5OLikkONSSW8M5Dw+XB\/eK4OL9Lpc\/5\/zu7\/f\/\/w8lJSWnm2tYRn+Xs1lMHNeggvPR5Csu4y4+Yw0DOfpf2MPrTMhnqONHjn4c3\/AUF7GETUyll6aFSXxEEw1cwk40yaMH82jjAlpY0X2qKYN4hEm8wXNcifp32cu92MbjWPfhD4YKBOyEnBO20C4QLmU66qqxfoKFzmElfmsx1Hqsbwqj3z2CUR8OcDb5bxHqeI\/9WI9hIxtwBB\/wNxF9KmjQgxe4gftCY2+FdedRwT2Hb\/UcHuJnNuBomhq38Ft4j7WccK9wFS\/xT1jx94Ihr2MYW0l9JuZqpiYbuJ0IZ2IXjRyDYSwKa83Swp0c\/QOsJvUgvghNVrsqSkpOmP\/ytjXKCpVkMwAAAABJRU5ErkJggg==\" alt=\"\"> for self-attention and <img decoding=\"async\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAYCAYAAAC8\/X7cAAAABHNCSVQICAgIfAhkiAAAAAFzUkdCAK7OHOkAAAHuSURBVFiF7dZPiE5hFMfxzzvjHbIxioWJKRoh0zSZRtNMitSIpJQNm9HYMNlQpmSWLNiwkZQFWZuVKZopJTIL5U+yo1kRyUJJSlic523eMX\/ufdVrDO93dc+5z3nO79zn3HMvNWrUqPEvUcRFrJ7hXheOVyPpUpzHQ6zEdtzDLSz7jf16U\/yaMl83Rs1cWIkjeCEKXYebGEdrVsKDaePRtMk+rMAbdFQsP9ghimhGD8YyxHcn4WdwAsfQiGtJUyb1mEBfshvwCasqlj7JNjwwWUgeLuEy6pJ9VZzorJQWtgjRw8negEd4m1\/vNOrxDYV0nWd9L67jOxZjF57lSXYAV8rswziVW+p0duIOmkRr3MfajJj1eCeEQztGshKVTmALHpf52\/BevA8teVUnekUf94n3aBynccPcRbTiNr4me6No603YPVfCQhLfVebrx9NUQCU04IKYZr\/Sg4E5Ys\/iaJndiZcYlK8FFwQT2F\/uWGiVfcATfCw56mZfO4UihkSr9Zvabn+SJrxOGobIX8AhfBazvROvqqEug4KYUO1iWp2rJHg4BdeJr+N80IwfYko1lpyLcgYvFxNmjxiN80Eb9mKz6IQvGMvbQnfFz1URz6siL5uOlHsEJ8WPX8UMiCfw15D3BEpsxZJqCPlv+Qmhp04mBxghtgAAAABJRU5ErkJggg==\" alt=\"\"> for cross-attention, where <img decoding=\"async\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAYCAYAAADKx8xXAAAABHNCSVQICAgIfAhkiAAAAAFzUkdCAK7OHOkAAADeSURBVDiN7dIhS4NRFMbx3zbdRBARXBCMA4NswaFNMBkW1mcx2GzWfQOLn8BmnrA4HJhspjGbgslgVGwGw72Ot\/juziAL\/tM9h\/PwPOdy+GfOWMY57lDFAW7Rw2qesINN3OAEbazjBc1priU84zjWZbxhY5pwKzqsxLqOQZ6gmBns4z3WTQxThDu4z\/QbeBX2rf0kLOAQD5n+GGfx\/Zjn\/HeUEucW0cUFPlEp5s9POMIH9rGLp9Rk16gIn3kJC4nCNeGaWsKhSI06wJWw6yg1ZpZTbM\/i+M0eln7jOOELoAsdcNDH47wAAAAASUVORK5CYII=\" alt=\"\"> and <img decoding=\"async\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAYCAYAAAAlBadpAAAABHNCSVQICAgIfAhkiAAAAAFzUkdCAK7OHOkAAADgSURBVDiN7dIxSoNBFATgTwOCgtiYQhARIloZIfEAVhYidimsLHICj+ERLHKABIKkFAUrO7HSzsJKUMFCbUWLXXAr\/5dOwWl2Z9jZ92b38Y8\/hBkc4RJ1bOECQ8xVmfexiDN0sYd5PKAdqV7DPQ4yn8IrFiLmtVxpNvN1nFaZJovDI7xl3sZ51NzCVaE38STlX\/nJPIFt3Bb6DQ7z\/q6qgyqs4hONUqwFzS\/SD5zkS\/CdOYJ3fOAYO6S8ESxJk\/eMR1yPUdSu1O6gFKNtb2IZ09gQHFtStH5eO+iJP\/RvxBcOkyEv6EYX3QAAAABJRU5ErkJggg==\" alt=\"\"> are the query and key sequence lengths.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Self-attention is a neural network mechanism that allows every token in a sequence to attend to other tokens in the same sequence to understand their meaning and context. Cross-attention, in contrast, allows tokens in one sequence to retrieve relevant information from another. Both use queries (Q), keys (K) and values (V), but the key difference lies in where these vectors originate.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding the self-attention vs cross-attention difference is essential to understanding how Transformers build contextual representations and connect information across sequences. This guide walks through a worked numerical example of the self-attention mechanism, applies the same calculation to cross-attention, and compares their inputs, calculations and practical uses.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1774\" height=\"887\" src=\"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention-in-transformers-illustrati.png\" alt=\"Self-attention vs cross-attention in Transformers, illustrating how tokens attend within the same sequence or across two sequences using Q, K and V matrices and attention score matrices.\" class=\"wp-image-1971\" srcset=\"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention-in-transformers-illustrati.png 1774w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention-in-transformers-illustrati-300x150.png 300w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention-in-transformers-illustrati-1024x512.png 1024w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention-in-transformers-illustrati-768x384.png 768w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention-in-transformers-illustrati-1536x768.png 1536w\" sizes=\"auto, (max-width: 1774px) 100vw, 1774px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Why is Attention Needed in Transformers?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Attention enables a Transformer to determine which tokens are relevant to a particular token and combine their information into context-aware representations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How does attention connect related tokens?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Consider the sentence: \u201cThe animal was tired because it ran.\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To interpret \u201cit,\u201d a model needs information about the earlier words, particularly \u201canimal.\u201d Attention allows a token&#8217;s representation to incorporate information from other relevant positions rather than processing every token independently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Boundary: Self-attention creates these connections within a sequence. The following calculations show how it works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How does Self-Attention Work Step by Step?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The self-attention mechanism projects the same input sequence into Q, K and V matrices. It calculates query-key similarity scores, applies softmax to obtain attention weights, and uses those weights to combine value vectors.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1795\" height=\"876\" src=\"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-mechanism-in-transformers-showing-how-input-t.png\" alt=\"Self-attention mechanism in Transformers, showing how input tokens are projected into queries, keys and values to calculate attention scores, apply softmax, and generate context-aware output representations.\" class=\"wp-image-1972\" srcset=\"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-mechanism-in-transformers-showing-how-input-t.png 1795w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-mechanism-in-transformers-showing-how-input-t-300x146.png 300w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-mechanism-in-transformers-showing-how-input-t-1024x500.png 1024w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-mechanism-in-transformers-showing-how-input-t-768x375.png 768w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-mechanism-in-transformers-showing-how-input-t-1536x750.png 1536w\" sizes=\"auto, (max-width: 1795px) 100vw, 1795px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">What do queries, keys and values represent?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Query (Q):<\/strong> Represents what a token is looking for.<\/li>\n\n\n\n<li><strong>Key (K):<\/strong> Represents the features used to match a token against a query.<\/li>\n\n\n\n<li><strong>Value (V):<\/strong> Contains the information combined to produce the output.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The projections are:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Q = XWQ<br>K = XWK<br>V = XWV<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here, X represents the input token representations, while WQ, WK and WV are learned projection matrices.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Worked example: Calculate self-attention using small matrices<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Consider a two-token sequence with the following deliberately simplified matrices:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Q = K=[[1, 0], [0, 1]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">V =\u00a0[[1, 0], [0, 2]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These matrices are illustrative; they are not trained model parameters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1: Calculate the raw attention scores.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Multiply Q by the transpose of K:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">QK\u1d40 = [[1, 0], [0, 1]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each token has a score of 1 for itself and 0 for the other token.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2: Apply scaled dot-product attention.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The self-attention formula is:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Attention(Q, K, V) = softmax(QK\u1d40 \/ \u221adk)V<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here, dk is the key-vector dimension, which is 2. Divide the scores by \u221a2:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">QK\u1d40 \/ \u221a2 \u2248 [[0.707, 0], [0, 0.707]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Scaling helps prevent large dot products from producing excessively concentrated softmax distributions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3: Apply row-wise softmax.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Softmax converts each row of scores into weights that sum to 1:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Attention weights \u2248 [[0.67, 0.33], [0.33, 0.67]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These rounded values indicate how much each token attends to both positions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 4: Multiply the weights by V.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[[0.67, 0.33], [0.33, 0.67]] \u00d7 [[1, 0], [0, 2]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Output \u2248 [[0.67, 0.66], [0.33, 1.34]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each output combines information from both value vectors. The first token assigns more weight to the first value, while the second assigns more weight to the second.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why is the score divided by the square root of the key dimension?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">As the key dimension increases, dot products can become large in magnitude. Large scores can make softmax distributions overly concentrated and produce small gradients. Dividing by \u221adk helps control their scale during training.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Boundary: This example demonstrates one attention head. Transformers can use multiple heads and masks to capture different relationships or restrict which tokens can interact.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What are Multi-Head Attention and Masked Self-Attention?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Multi-head attention runs multiple attention operations in parallel, while masked self-attention restricts which positions a token can access.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How does multi-head attention work?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Each head uses its own learned Q, K and V projections. Different heads can learn different relationships, such as nearby dependencies or longer-range contextual links. Their outputs are concatenated and passed through an output projection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, individual heads are not guaranteed to specialise in a particular relationship; their behaviour depends on what the model learns.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What does a causal mask do?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A causal attention mask prevents a token from attending to future positions. For three tokens, the allowed positions can be represented as:<br>[[1, 0, 0],<br>[1, 1, 0],<br>[1, 1, 1]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here, 1 means attention is allowed and 0 means it is blocked. In implementations, blocked scores are typically masked before softmax.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Masked self-attention is used in autoregressive decoders, including GPT-style models, so predictions do not use future tokens that would be unavailable during generation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Boundary: Masking changes which positions can contribute, not where Q, K and V originate. Cross-attention changes that source.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How does Cross-Attention Work?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Cross-attention uses queries from one sequence and keys and values from another. In a standard encoder-decoder Transformer, decoder states provide Q, while encoder outputs provide K and V.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1794\" height=\"877\" src=\"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/encoder-decoder-cross-attention-diagram-showing-decoder-stat.png\" alt=\"Encoder-decoder cross-attention diagram showing decoder states producing queries and encoder outputs producing keys and values.\" class=\"wp-image-1973\" srcset=\"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/encoder-decoder-cross-attention-diagram-showing-decoder-stat.png 1794w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/encoder-decoder-cross-attention-diagram-showing-decoder-stat-300x147.png 300w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/encoder-decoder-cross-attention-diagram-showing-decoder-stat-1024x501.png 1024w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/encoder-decoder-cross-attention-diagram-showing-decoder-stat-768x375.png 768w, https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/encoder-decoder-cross-attention-diagram-showing-decoder-stat-1536x751.png 1536w\" sizes=\"auto, (max-width: 1794px) 100vw, 1794px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">How does cross-attention work in an encoder-decoder Transformer?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In machine translation, the encoder processes a source sentence, such as \u201cThe cat sleeps.\u201d The decoder generates the target-language sentence while accessing relevant information from the encoded source.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The projections are:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Q = XdecoderWQ<br>K = XencoderWK<br>V = XencoderWV<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The same scaled dot-product attention formula applies. The key difference is that the query and key-value matrices come from different sequences.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">A small cross-attention example<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Consider one decoder query and two encoder positions:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Q = [[1, 0]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">K = [[1, 0], [0, 1]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">V = [[2, 0], [0, 4]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1: Calculate and scale the scores.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">QK\u1d40 = [[1, 0]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since dk = 2:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">QK\u1d40 \/ \u221a2 \u2248 [[0.707, 0]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2: Apply softmax.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Attention weights \u2248 \u00a0[[0.67, 0.33]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3: Multiply by V.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[[0.67, 0.33]] \u00d7 [[2, 0], [0, 4]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Output \u2248 [[1.34, 1.32]]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The decoder query assigns more weight to the first encoder position, while still incorporating information from the second. All decimal values in these examples are rounded approximations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Where is cross-attention used beyond translation?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Cross-attention is used in encoder-decoder tasks such as translation and summarisation. It can also connect different modalities in multimodal models, such as allowing text representations to attend to image features. The exact design varies, and not every multimodal architecture uses cross-attention in the same way.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Boundary: Both mechanisms use the same core calculation. Their difference lies in how the input representations are connected.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Self-Attention vs Cross-Attention: What Is the Difference?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The main self-attention vs cross-attention difference is the origin of Q, K and V. Self-attention derives all three from the same sequence, while cross-attention uses Q from one sequence and K and V from another.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Self-attention<\/th><th>Cross-attention<\/th><\/tr><\/thead><tbody><tr><td>Input source<\/td><td>One sequence<\/td><td>Two sequences or representations<\/td><\/tr><tr><td>Query (Q)<\/td><td>Same sequence as K and V<\/td><td>Querying sequence<\/td><\/tr><tr><td>Keys (K) and values (V)<\/td><td>Same sequence as Q<\/td><td>Separate sequence<\/td><\/tr><tr><td>Main purpose<\/td><td>Build context within a sequence<\/td><td>Transfer information across sequences<\/td><\/tr><tr><td>Typical use<\/td><td>Encoder attention; decoder masked attention<\/td><td>Encoder-decoder attention<\/td><\/tr><tr><td>Attention score matrix<\/td><td>Input length \u00d7 input length<\/td><td>Query length \u00d7 key\/value length<\/td><\/tr><tr><td>Example<\/td><td>Connecting words in a sentence<\/td><td>Decoder attending to source tokens<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">How can you identify which type of attention a model uses?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check where Q, K and V originate. If all three come from the same sequence, it is self-attention. If Q comes from one sequence and K and V from another, it is cross-attention.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A causal mask does not turn self-attention into cross-attention. It simply restricts which positions within the same sequence can contribute.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Boundary: These distinctions provide a practical way to recognise attention operations when studying Transformer architectures or reading their implementations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Self-attention builds contextual relationships within a sequence, whereas cross-attention allows one sequence to retrieve information from another. Both rely on Q\/K\/V projections, scaled dot-product attention and softmax, but differ in their input sources and typical uses. Working through the attention score matrix and output calculation makes this distinction easier to understand.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To explore these concepts alongside Transformer architecture and other Generative AI foundations, explore the <a href=\"https:\/\/www.interviewbit.com\/varsity\/iit-delhi\/generative-ai\"><strong>Generative AI programme by IIT Delhi<\/strong><\/a>, delivered on Varsity by InterviewBit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Can self-attention and cross-attention use the same attention formula?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. Both can use scaled dot-product attention. The difference is whether Q, K and V originate from one sequence or from separate sequences.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Does cross-attention always require an encoder-decoder architecture?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Encoder-decoder Transformers are a common example, but cross-attention can also connect different modalities or representations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Can the query and key\/value sequences have different lengths?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. The output has one row per query position, while the attention score matrix has one column per key position.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Why do attention weights add up to one?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Softmax normalises the scores across the available positions for each query, so the weights sum to one, subject to numerical rounding.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Does self-attention preserve the original token embeddings?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Not necessarily. It produces context-enriched representations by combining value vectors according to the attention weights.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Is masked self-attention the same as cross-attention?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Masked self-attention restricts access to positions within a sequence. Cross-attention connects queries from one sequence to keys and values from another.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">What happens if all attention scores are equal?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Softmax assigns equal weights to all unmasked positions. The output becomes the average of their value vectors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Does every Transformer layer contain cross-attention?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Encoder-only and decoder-only Transformers can use self-attention without a separate cross-attention layer. Standard encoder-decoder Transformers typically include cross-attention in the decoder.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">How does sequence length affect the attention matrix?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For self-attention with sequence length n, the score matrix contains n \u00d7 n entries. For cross-attention, it contains nq \u00d7 nk entries, where nq is the query length and nk is the key\/value length.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">What should I calculate first when solving an attention problem by hand?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Identify the origins and dimensions of Q, K and V. Then calculate QK\u1d40, scale the scores, apply softmax row-wise, and multiply the resulting weights by V.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/arxiv.org\/abs\/1706.03762\">Attention Is All You Need \u2014 Original Transformer Research Paper<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/nlp.seas.harvard.edu\/annotated-transformer\/\">The Annotated Transformer \u2014 Harvard NLP<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/nlp.seas.harvard.edu\/2018\/04\/03\/attention\">Scaled Dot-Product Attention \u2014 Formula and Implementation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.pytorch.org\/docs\/stable\/generated\/torch.nn.functional.scaled_dot_product_attention.html\">PyTorch Documentation \u2014 Scaled Dot Product Attention<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Key Insights Self-attention is a neural network mechanism that allows every token in a sequence to attend to other tokens in the same sequence to understand their meaning and context. Cross-attention, in contrast, allows tokens in one sequence to retrieve relevant information from another. Both use queries (Q), keys (K) and values (V), but the [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":1988,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1969","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-generative-ai"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"acf":{"reviewed_by":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Self-Attention vs Cross-Attention: A Worked Example<\/title>\n<meta name=\"description\" content=\"Understand self-attention vs cross-attention in Transformers with step-by-step Q\/K\/V matrix calculations, scaled dot-product attention, worked examples and a comparison table.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Self-Attention vs Cross-Attention: A Worked Example\" \/>\n<meta property=\"og:description\" content=\"Understand self-attention vs cross-attention in Transformers with step-by-step Q\/K\/V matrix calculations, scaled dot-product attention, worked examples and a comparison table.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/\" \/>\n<meta property=\"og:site_name\" content=\"Varsity Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-28T09:12:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-28T09:12:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1010\" \/>\n\t<meta property=\"og:image:height\" content=\"673\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Varsity on Behalf of CEP IIT Delhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Varsity on Behalf of CEP IIT Delhi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/\"},\"author\":{\"name\":\"Varsity on Behalf of CEP IIT Delhi\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#\\\/schema\\\/person\\\/7b5db9a94eddee529cd35968692d9c29\"},\"headline\":\"Self-Attention vs Cross-Attention: A Worked Example\",\"datePublished\":\"2026-10-28T09:12:15+00:00\",\"dateModified\":\"2026-10-28T09:12:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/\"},\"wordCount\":1677,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/self-attention-vs-cross-attention.webp\",\"articleSection\":[\"Generative AI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/\",\"url\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/\",\"name\":\"Self-Attention vs Cross-Attention: A Worked Example\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/self-attention-vs-cross-attention.webp\",\"datePublished\":\"2026-10-28T09:12:15+00:00\",\"dateModified\":\"2026-10-28T09:12:19+00:00\",\"description\":\"Understand self-attention vs cross-attention in Transformers with step-by-step Q\\\/K\\\/V matrix calculations, scaled dot-product attention, worked examples and a comparison table.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/self-attention-vs-cross-attention.webp\",\"contentUrl\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/self-attention-vs-cross-attention.webp\",\"width\":1010,\"height\":673,\"caption\":\"self-attention-vs-cross-attention\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/self-attention\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Self-Attention vs Cross-Attention: A Worked Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/\",\"name\":\"Varsity Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#organization\",\"name\":\"Varsity Blog\",\"url\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/varsity-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/varsity-logo.png\",\"width\":275,\"height\":64,\"caption\":\"Varsity Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/company\\\/varsity-by-interviewbit\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/#\\\/schema\\\/person\\\/7b5db9a94eddee529cd35968692d9c29\",\"name\":\"Varsity on Behalf of CEP IIT Delhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bdb12370d043ff980b2b8f1ccb67f5a1f0e333aaca46cc35358b1af8b1d98334?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bdb12370d043ff980b2b8f1ccb67f5a1f0e333aaca46cc35358b1af8b1d98334?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bdb12370d043ff980b2b8f1ccb67f5a1f0e333aaca46cc35358b1af8b1d98334?s=96&d=mm&r=g\",\"caption\":\"Varsity on Behalf of CEP IIT Delhi\"},\"description\":\"Varsity by InterviewBit, in collaboration with CEP IIT Delhi, creates industry-relevant learning programmes designed to help learners build practical, in-demand skills. Through this author profile, we publish articles that complement our courses covering curriculum-aligned topics, foundational concepts, emerging trends, and advanced insights. Our goal is to help learners deepen their understanding beyond the classroom and apply their knowledge confidently in real-world contexts.\",\"url\":\"https:\\\/\\\/www.interviewbit.com\\\/varsity\\\/blog\\\/author\\\/varsity-on-behalf-of-cep-iit-delhi\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Self-Attention vs Cross-Attention: A Worked Example","description":"Understand self-attention vs cross-attention in Transformers with step-by-step Q\/K\/V matrix calculations, scaled dot-product attention, worked examples and a comparison table.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/","og_locale":"en_US","og_type":"article","og_title":"Self-Attention vs Cross-Attention: A Worked Example","og_description":"Understand self-attention vs cross-attention in Transformers with step-by-step Q\/K\/V matrix calculations, scaled dot-product attention, worked examples and a comparison table.","og_url":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/","og_site_name":"Varsity Blog","article_published_time":"2026-10-28T09:12:15+00:00","article_modified_time":"2026-10-28T09:12:19+00:00","og_image":[{"width":1010,"height":673,"url":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention.webp","type":"image\/webp"}],"author":"Varsity on Behalf of CEP IIT Delhi","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Varsity on Behalf of CEP IIT Delhi","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/#article","isPartOf":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/"},"author":{"name":"Varsity on Behalf of CEP IIT Delhi","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#\/schema\/person\/7b5db9a94eddee529cd35968692d9c29"},"headline":"Self-Attention vs Cross-Attention: A Worked Example","datePublished":"2026-10-28T09:12:15+00:00","dateModified":"2026-10-28T09:12:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/"},"wordCount":1677,"commentCount":0,"publisher":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#organization"},"image":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention.webp","articleSection":["Generative AI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/","url":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/","name":"Self-Attention vs Cross-Attention: A Worked Example","isPartOf":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/#primaryimage"},"image":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention.webp","datePublished":"2026-10-28T09:12:15+00:00","dateModified":"2026-10-28T09:12:19+00:00","description":"Understand self-attention vs cross-attention in Transformers with step-by-step Q\/K\/V matrix calculations, scaled dot-product attention, worked examples and a comparison table.","breadcrumb":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/#primaryimage","url":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention.webp","contentUrl":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/10\/self-attention-vs-cross-attention.webp","width":1010,"height":673,"caption":"self-attention-vs-cross-attention"},{"@type":"BreadcrumbList","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/self-attention\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.interviewbit.com\/varsity\/blog\/"},{"@type":"ListItem","position":2,"name":"Self-Attention vs Cross-Attention: A Worked Example"}]},{"@type":"WebSite","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#website","url":"https:\/\/www.interviewbit.com\/varsity\/blog\/","name":"Varsity Blog","description":"","publisher":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.interviewbit.com\/varsity\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#organization","name":"Varsity Blog","url":"https:\/\/www.interviewbit.com\/varsity\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/08\/varsity-logo.png","contentUrl":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-content\/uploads\/2026\/08\/varsity-logo.png","width":275,"height":64,"caption":"Varsity Blog"},"image":{"@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/company\/varsity-by-interviewbit\/"]},{"@type":"Person","@id":"https:\/\/www.interviewbit.com\/varsity\/blog\/#\/schema\/person\/7b5db9a94eddee529cd35968692d9c29","name":"Varsity on Behalf of CEP IIT Delhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/bdb12370d043ff980b2b8f1ccb67f5a1f0e333aaca46cc35358b1af8b1d98334?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/bdb12370d043ff980b2b8f1ccb67f5a1f0e333aaca46cc35358b1af8b1d98334?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bdb12370d043ff980b2b8f1ccb67f5a1f0e333aaca46cc35358b1af8b1d98334?s=96&d=mm&r=g","caption":"Varsity on Behalf of CEP IIT Delhi"},"description":"Varsity by InterviewBit, in collaboration with CEP IIT Delhi, creates industry-relevant learning programmes designed to help learners build practical, in-demand skills. Through this author profile, we publish articles that complement our courses covering curriculum-aligned topics, foundational concepts, emerging trends, and advanced insights. Our goal is to help learners deepen their understanding beyond the classroom and apply their knowledge confidently in real-world contexts.","url":"https:\/\/www.interviewbit.com\/varsity\/blog\/author\/varsity-on-behalf-of-cep-iit-delhi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/posts\/1969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/comments?post=1969"}],"version-history":[{"count":3,"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/posts\/1969\/revisions"}],"predecessor-version":[{"id":1989,"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/posts\/1969\/revisions\/1989"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/media\/1988"}],"wp:attachment":[{"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/media?parent=1969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/categories?post=1969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.interviewbit.com\/varsity\/blog\/wp-json\/wp\/v2\/tags?post=1969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}