Exercises — GPT configuration
Comprehension and code-reading exercises
← Back to the guided tour: Configuration du GPT
Check your understanding
What error do you get with
embedding_dim=10, num_heads=4? And withembedding_dim=12, num_heads=4?How many entries does the position table of a
context_length=256, embedding_dim=64configuration have?For a configuration with
vocab_size=50,context_length=32,embedding_dim=64,num_heads=4,num_layers=6, andmlp_hidden_dim=256, match each field to what it controls. What doesseedchange?Why should
embedding_dim=16.0andseed=-1be rejected even though the first value is numerically integral?Show answers and reasoning
10 % 4 == 2: divisibility fails, soValueErrorat construction. With12 % 4 == 0: accepted, and each head receives12/4 = 3columns.256 × 64 = 16384values, i.e. 16384 learned parameters — one per position and per dimension. This count is independent of the vocabulary and the head count.vocab_sizesets the token-table rows and the last logits dimension (V);context_lengthsets the maximum sequence length and position table;embedding_dimsets the residual-stream widthdand projection widths;num_headssplits that width intoHheads ofd/Hcolumns;num_layerssets the number of blocks;mlp_hidden_dimsets the MLP’s intermediate width.seedchanges initial values, not shapes or architecture.16.0is still a float: anintannotation neither converts nor validates a value at runtime. The seed must be a non-negative integer accepted bydefault_rng;-1is invalid and should fail at construction.