Prefix tuning adapts a frozen pretrained Transformer by prepending a small number of trainable continuous vectors (prefix tokens) and optionally inserting infix tokens, instead of updating the model's original weights. These extra tokens occupy slots inside the model's fixed maximum sequence length, leaving less room for the actual task input.
Implement a function prefix_tuning_tradeoff(d_model, max_sequence_length, l_p, l_i) that returns a dictionary with three quantities describing this trade-off:
trainable_params: the total number of trainable parameters introduced by the prefix and infix tokens (each token is a vector of size d_model).effective_seq_len: how many positions remain in the context window for the real task tokens after reserving slots for the prefix and infix tokens.prefix_fraction: the fraction (between 0 and 1) of the maximum sequence length consumed by the prefix and infix tokens.If the requested prefix and infix tokens together meet or exceed max_sequence_length, effective_seq_len should be 0 and prefix_fraction should be capped at 1.0.